How to mount from command line like the Nautilus does?

Andrea Francia picture Andrea Francia · Jan 27, 2009 · Viewed 35.4k times · Source

On my Ubuntu linux box I can easily mount USB connected drives or CDROM clicking on devices icons that I can found on the Desktop.

For example if I click on a USB connected drive icon the following things happen:

  • a /media/LABEL directory is automatically created (where LABEL is the label of the disk and may vary from disk to disk)
  • the filesystem on the device is mounted on /media/LABEL

This process is significantly different from mounting using the mount command. In particular:

  • you don't need to be root (or you don't need to modify /etc/fstab to allow ordinary user to mount the device)
  • the /media/LABEL directory is automatically created
  • the name of the directory changes according the volume label.

There is a command line command that behaves like the Gnome GUI mounting facilities does?

Answer

mwx picture mwx · May 12, 2011

What you are looking for is gio mount (it recently replaced gvfs-mount, which replaced gnome-mount).

There is a man page here or you can just type gio help mount for the details

The basic usage is:

gio mount --list --detail to get a list of mounted and mountable volumes

gio mount [-u] <volume> to [un]mount it, e.g. gio mount smb://server/share or gio mount WINDOWS.

Sadly, there seems to be a bug that results in a "Error mounting location: volume doesn't implement mount" message trying to mount by volume name, but gvfs-mount -d /dev/<devicename> might work.