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?*

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 need sudo.
  • 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 -n1 to call the umount 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.

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.