I have this portable hard disk with 4 partitions. When I need to safely remove the device I have to unmount each partition manually. Is there a way I can unmount all at once? Or is it suffice to unmount one partition only and remove the disk?
If you know the device file, say /dev/sdb, you can unmount all partitions of the device with the command:
sudo umount /dev/sdb?*
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.
sudo umount -a will unmount them all.
$ 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 need
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 use
xargs -n1to call the
umountcommand for each partition seperately.
umountfails because a partition is “busy”, but really it's not. The
-loption makes sure the drive is unmounted as soon as it's safe to do so.