How to mount filesystems from the command line in Ubuntu 10.04 and 10.10

October 23, 2010

If you have recently tried to mount a filesystem in Ubuntu Lucid or Ubuntu Maverick from the command line in a Gnome friendly way you have probably run into some trouble.  The pre-Lucid methods involved the use of gnome-mount or pmount, but both of these utilities rely on HAL (the Hardware Abstraction Layer) which has been deprecated in favor of new functionality in udev, the Linux kernel, and gvfs.

You might ask why someone wouldn’t just want to use plain old mount and fstab to handle mounting.  Mount and fstab work great for behind the scenes filesystems you never need to unplug (such as external hard drives for automatic backups), but if you like to eject/safely remove/unmount your devices from the graphical interface in Ubuntu you will be out of luck.  Also, the mount command requires superuser privileges while the graphical methods in Ubuntu do not.

The solution is apparently the new gvfs-mount command, available through the gvfs-bin package.  While documentation on this utility is scant (no manpage!), devices can be mounted by executing:

gvfs-mount -d /dev/<devicename>

Note:  When I execute this command from a terminal, I am greeted by 4 “Critical” warnings about various failures.  Surprisingly, this does not mean the command didn’t work.  Check your Desktop or /mount for your device.

This command can be executed by non-root users, and the mounting appears to be handled in exactly the same manner as the graphical method (desktop shortcut, mounting as /mount/<disk label or UUID>).  Filesystems mounted with this command can be unmounted with a right-click from the Desktop or though the side pane in Nautilus.

Unmounting from the command line can be accomplished with this command:

gvfs-mount -u /media/<disk label or UUID>

For some reason, the -d switch with the /dev/<devicename> path does not appear to work.

Hopefully you have found this helpful.  If you found this useful, or if you have some tips on using gvfs-mount, or if you have a better way of doing this, please leave me a comment!

About these ads

5 Responses to “How to mount filesystems from the command line in Ubuntu 10.04 and 10.10”

  1. Ale London Says:

    i ve found this helpful. thanx!


  2. [...] the way nautilus does it. Just in case somebody's interested – you can see refer to the following: http://omegamormegil.wordpress.com/2…-04-and-10-10/ [...]

  3. stefanhendriks Says:

    This is helpful. Perhaps you could also explain how to do automounting (on boot up).

    Now I have to manually do this (or via Gnome) mount a partition (ntfs). I’d like to have it mounted on startup. Perhaps there is an easy way to do this. For now I am trying this via fstab.

  4. Hangman Says:

    I’m having a problem mounting a usb drive with this command under xmonad.

    $ gvfs-mount -d /dev/sdb1 /media/sandisk32g/
    No volume for device file /dev/sdb1
    $

    sdb1 is a ntfs partition and can be mounted normally on other systems. Am I missing anything here?


  5. This is very helpful, now I can mount at startup without using fstab. It is working for me with ext4 and ntfs partitions on hdd.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: