Mount drive through command line (as if I clicked on it in nautilus)

I'm writing a backup script in which I need to mount a drive in the media bay of my laptop.

I know that I can get the job done by messing with fstab and the mount command. Perhaps that's the easiest way. Anyway, I'm interested in the following:

  1. Initially the media bay drive is unmounted.

  2. I click on the drive in the side-panel in a nautilus window and the drive is mounted.

  3. I can access it at /media/baydrive.


My question:

Is there an easy way of performing step 2 from the command line? I.e., mount the drive to /media/<device name> without messing with fstab.


Try udisks --mount <device name>

To mount by partition label, you can do

udisks --mount /dev/disk/by-label/baydrive

The most equivalent (at least for ubuntu 14.4) is

udisksctl mount --block-device /dev/disk/by-label/baydrive
udisksctl unmount --block-device /dev/disk/by-label/baydrive

The difference between udisks and udisksctl is that udisks always mount under /media, while udisksctl mount where nautilus would, which is sometimes /media/${USER}


If you want this to be for your user and not root try this

udisksctl mount -b /dev/sdb2 

use the right name of your disk