How to mount from command line like the Nautilus does?

Viewed 39584

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?

9 Answers

See the pmount command for usage information

Yes there is. It's called ivman and handles all HAL events. I start it when running ion3. I simply start ivman as a daemon process, but has added the program to my sudoers file:

cat /etc/sudoers
[...]
ivman {hostname}=(root) NOPASSWD: /sbin/init, /usr/sbin/hibernate
[...]

so that it can manage power settings as well.

I don't believe Gnome itself handles the mounting—it's HAL. So if HAL is running, you should be able to automount. I assume that pmount talks to HAL somehow, and that would be the way to handle unmounting. I hope this gets you started, at least.

You can also use gnome-mount for mounting / unmounting from the command line.

I plug in my USB device, type "gnome-volume-manager" and this seems to do what you require.

That would be "devkit-disks --mount /dev/sdxx" where xx is the letter and number of the partition to mount...

Related