1

On CentOS (5.5 and others) I need to transfer quite big files to a FAT32 USB flash drive to get the data on a Windows 7 machine (each file is below 4GB, so I guess FAT32 shouldn't be an issue then).

When I click on "safely remove" and unplug the USB drive afterwards, files are often corrupted. The symbol for the drive is mostly still there but it showed, that it's "turned off" (same with using umount in terminal).

Is it mandatory that the symbol for the USB drive disappears? Are there other possibilities that I can really safely remove the flash drive?

/edit

What I just observed: Doing the rigtclick->safely remove more than one time, the symbol disappears. After unplugging and reconnecting to the USB port, the data is once again corrupted (I use md5sum to check this, because sometimes even the count of Bits is the same)...

3

It is mandatory to wait until icon of USB device disappears. While it is still there system is flushing file system buffers to your device.

You can also use sync from terminal/shell and wait for it to complete or you can use gnome-disks (also known as gnome-disk-utility or GNOME Disks or palimpsest) to safely sync and disconnect USB device from the system.

Cheers,

  • Please see my edit. I am not sure if the disappeared icon is a safe sign. And if you hit the safely remove button once, for bigger files the icon isn't disappearing (maybe it is, but it takes really a long time). – EverythingRightPlace Aug 29 '14 at 14:48
  • It is safe if icon goes away. The "safely remove" will flush the buffers and then disconnect usb device, which is safe for sure for the data. USB2 interface is not a speed demon. If there is a certain amount of data in filesystem cache it can take several or even tens of seconds before the icon disappears. Just be patient. – Scyld de Fraud Aug 29 '14 at 15:24
  • It's not only tens of seconds. It is tens of minutes which is too long in my opinion. – EverythingRightPlace Aug 29 '14 at 17:21
  • Many pen drives can only write at 4 MB/sec. I run iostat 5 and watch and wait until the i/o stops before trying to unmount the drive. – Mark Plotnick Aug 29 '14 at 22:39
2

The command 'sync' ensures that all data has been written to disk before returning. It is not generally needed when using a GUI, but in this case you might execute it in any terminal and do not remove the USB until you have a prompt again.

  • This is only possible as root. Isn't there a possibility for the standard user? I think sync flushes all system buffers. Is this even necessary? – EverythingRightPlace Aug 29 '14 at 12:23
  • @EverythingRightPlace sync works from any user. – Ruslan Aug 29 '14 at 15:37
  • 1
    @Gheesh sync is not enough to "safely remove" the device. You must unmount it, otherwise the FS may still be in not a good state after removing. In the best case on replug the FS driver will just reset the "unclean unmount" flag and replay journal if any, but in the worst case data may be corrupted, since you never know what happens between return from sync and unplugging. – Ruslan Aug 29 '14 at 15:39
  • @Rusian You're right, the filesystem must be unmounted. I was suggesting using sync before selecting "Safely remove" which unmounts it as a way of making sure that the unmounting is immediate and no background writing takes place. – Gheesh Aug 30 '14 at 10:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.