4

I once unmounted an USB device using Ubuntu or Debian file manager, and when the icon next to the drive that shows it is mounted disappeared I immediately pulled the USB device out. Turns out that Linux was still writing some data on the USB device on the time I pulled it out.

Is this a file manager specific question? Can this happen when you unmount via command-line, too, or does the shell block until the device is save to pull out?

3 Answers 3

5

You can always check if data is being written to unmounted device using iostat for example:

iostat -p /dev/sde1 1

where you specify device (/dev/sde1 in the example), and statistics refresh interval.

2
  • 1
    Just building on this answer, I had to pass the block name, not partition, and the output (to me) is much easier to read by using watch. So, I used watch iostat -p /dev/sdb which worked perfectly to see how the system was still writing to my USB stick. Mar 31, 2020 at 10:28
  • Do be clear, the relevant value is kB_wrtn/s (or kB_wrtn), and we want it to consistently be 0, right (there's no reason for it to be ever above 0 when the device is successfully unmounted)?
    – tim
    Jan 28, 2023 at 10:09
1

For the last question (command line):

On command line the umount command waits until the files are stored and the filesystem is really unmounted. Personally I prefer to use the command eject on USB devices: this command will unmount and then power off the USB device (so the led is off and I know for sure I can remove the device). Both commands will return only when their job is terminated.

In general you can check the led. If it is blinking, data are being stored. You can give also the command mount to see if the device is attached.

2
  • I checked with both umount and eject that they make programs who are writing to the USB device crash and output "device busy" or similar. When no write operation is running, you might be right. Do you maybe know how I could recreate a situation where not all files were written to the USB device, but the commands umount and eject work?
    – mkdrive2
    Feb 13, 2016 at 21:53
  • 1
    "Device busy" means that some other programs have files (or directories) open in the USB device. Note: a filemanager that is in a USB directory keeps open such directory. For the additional question: use a USB pen (so slow) and copy a very big file (e.g. installation image of a linux distribution): it take one minute or so to write, so you have time to test umount or eject. Feb 14, 2016 at 6:43
0

You could check in terminal using ls /dev/sd*. If the device file for your USB drive still exists, then probably it is still writing some data.

3
  • I unmounted a USB device with sudo umount /dev/sdXn, but it is still listed with ls /dev/sdX*, even though nothing is being written to the USB device.
    – mkdrive2
    Feb 13, 2016 at 17:08
  • Try detach using udisks (you should install it first though) with sudo udisks --detach /dev/sdX
    – comepradz
    Feb 13, 2016 at 17:16
  • After an umount the device should be still there. For harddisk it is common to umount and mount the same device/partition without rebooting. The device will disappear only if an eject is given, after the umount. Feb 13, 2016 at 18:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .