Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 3 down vote accepted

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.

share|improve this answer
Thanks! Safely remove does the trick – thameera Oct 22 '10 at 8:29

The command sudo umount -a will unmount them all.

share|improve this answer

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.
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.