Unmounting several partitions at once
If you know the device file, say /dev/sdb, you can unmount all partitions of the device with the command:
sudo umount /dev/sdb?*
The command sudo umount -a
should be avoided, because it would unmount also partitions you do not want to unmount at that moment.
By the way, I think that the gnome right click menu item "Safely remove" is the graphical best way to operate.
Use this:
$ ls /dev/sd𝑋?* | xargs -n1 umount -l
enzotib's answer (sudo umount /dev/sd𝑋?*
) is right, however
- Under newer versions of Ubuntu, portable drives should normally be mounted with user permissions (under
/media/$USER/drivename
), so you don't needsudo
. -
umount /dev/sd𝑋?*
will abort at any partition it fails to unmount (for instance, because it is not actually mounted!). To make sure all partitions are unmounted for which this is possible, you can usexargs -n1
to call theumount
command for each partition seperately. - Sometimes
umount
fails because a partition is “busy”, but really it's not. The-l
option makes sure the drive is unmounted as soon as it's safe to do so.
The command sudo umount -a
will unmount them all.