Is umount $mountpoint
always enough to safely remove a single-partition USB drive on a modern GNU/Linux system? Or should I use sync && umount $mountpoint && sync
, or perhaps umount $mountpoint && udisks --detach $device
? I'd like to use the safest way possible, but on the other hand I don't want to introduce superfluous dependencies or delays into my program.
EDIT: Does umount calls sync to complete any pending writes indeed answers a part of this question (whether sync && umount $mountpoint && sync
provides any benefit over umount $mountpoint
), but not the whole question (whether udisks --detach $device
or some other command provides improved safety), so it's not an exact duplicate.
umount
is safe and doesn't need anything else, but of course, you have to check its return value to see if the command was effective. – xhienne Mar 27 '17 at 16:05