73

I want to know how to umount my USB drive via command line. I am using Ubuntu 12.04 LTS 32-bit.

student
  • 17,875
  • 31
  • 103
  • 169
Pranit Bauva
  • 986
  • 2
  • 8
  • 15

3 Answers3

93

Suppose your usb drive is mounted to /media/usb then it would be sufficient to do

sudo umount /media/usb

Suppose the your usb is /dev/sdb1 then you could also do

sudo umount /dev/sdb1

You may also have a look at the anwers of one of my questions, how to umount all attached usb devices with a single command: Umount all attached usb disks with a single command

student
  • 17,875
  • 31
  • 103
  • 169
9

You can also use

udisks --unmount /dev/sdb1

which does not require root.


For macOS:

diskutil umount /dev/sdb1
Jim Paris
  • 14,137
  • 5
  • 36
  • 35
  • This is the what I was looking for. Do the same unprivileged action the desktop does for mounting the device. TIL. – jgomo3 Oct 24 '18 at 00:16
  • udisks command is changed to udisksctl in debian derivatives (available in 'udisks2' package). `udisksctl unmount -b /dev/sdb1` – finn Feb 26 '19 at 13:44
  • 2
    Don't forget to power down the USB stick as well: `udisksctl unmount -b /dev/sdb1 && udisksctl power-off -b /dev/sdb` – vk5tu Jan 12 '20 at 08:38
3

Better than using sudo to unmount as root, just install the pmount package and do:

pumount /media/usb

As man pumount says:

NAME
       pumount - umount arbitrary hotpluggable devices as normal user

SYNOPSIS
       pumount [ options ] device

DESCRIPTION
       pumount  is  a wrapper around the standard umount program which permits
       normal users to umount removable devices without a matching  /etc/fstab
       entry.
beldaz
  • 131
  • 4
  • no `pumount` on my system, none in my package repo to install, either. – michael Oct 13 '16 at 08:36
  • @michael_n Do you have Ubuntu 12.04 LTS 32-bit, as in the OP question? – beldaz Oct 13 '16 at 08:47
  • ubuntu 16.04 -- at some point, pumount must either have been deprecated, did it come from a 3rd party repo? – michael Oct 13 '16 at 08:53
  • 2
    I see it -- one has to install `pmount` (which is why `pumount` wasn't matched when searching in in the package manager). http://manpages.ubuntu.com/manpages/xenial/man1/pumount.1.html – michael Oct 13 '16 at 08:54
  • @michael_n thanks, I've added mention of the package to help others in future. – beldaz Oct 13 '16 at 09:55