Home page of this blog

Monday, September 28, 2009

Ensuring data is written to pen drives in linux

Sometimes we copy data into pendrive from Ubuntu/Fedora or any other linux distribution.

Data is not written to usb pen drive immediately as it resides in main memory. If we remove the pen drive the data may not be there or only some part of data may be there which is called corrupted data.

If we try to unmount by right clicking the icon, we might get a dialog or a notification that data is being written and another prompt after the data is being written to indicate it is safe to remove the pen drive.
But it will be ugly to unmount and mount just to ensure data is written. Instead we can do it using commandline as follows.

sync

After typing this command in terminal, we need to wait for the command to complete. This will ensure any buffer in memory is actually flushed or synced to external devices like pendrives.

No comments:

Post a Comment