How to mount drive in /media/userName/ like nautilus does using udisks
The accepted answer does not really answer the question, namely how to mount and unmount hard drives using udisks like Nautilus does when clicking on a disk. The command you are looking for is udiskctl
.
It's super easy, and also works with encrypted disks!
Mounting (encrypted disk):
Unlock the disk:
$ udisksctl unlock -b /dev/sdb1
Unlocked /dev/sdb1 as /dev/dm-3.
Take note of the location of the unlocked device (here /dev/dm-3
). Then mount it automatically:
$ udisksctl mount -b /dev/dm-3
Mounted /dev/dm-3 at /media/jmiserez/samsung1000.
Unmounting (encrypted disk):
$ udisksctl unmount -b /dev/dm-3
Unmounted /dev/dm-3.
$ udisksctl lock -b /dev/sdb1
Locked /dev/sdb1.
For unencrypted disks, just leave out the lock/unlock command in the beginning and end.
As you can see except for /dev/sda5
as well as /dev/sda7
there is no entry of other partitions in /etc/fstab
. You can manually mount your partitions by following these steps.
First of all unmount all partitions before creating an entry point to
/etc/fstab
. You can use command:sudo umount /dev/sdaX
. Replace X with the partition number you want to unmount. Best way to unmount all is to use this command:sudo umount -a
Since you want to mount your partition at
/media/user/mount-drive
; you have to create the mount-point where you want to mount the partitions. Thus you've to create directories there in order to mount the partitions. Execute following in terminal to make the directories(mount point):sudo mkdir /media/user/sda1 /media/user/sda2 /media/user/sda3 /media/user/sda6
Replace
user
with your ubuntu user's name. i,ebsienn
I think.Now you have to make changes in
/etc/fstab
in order to mount your all partitions. Execute following commands to do so:sudo cp /etc/fstab /etc/fstab.orginal sudo nano /etc/fstab
go to the last line and add these lines:
UUID=8230744030743D6B /media/user/sda1 ntfs errors=remount-ro 0 1 UUID=60100EA5100E81F0 /media/user/sda2 ntfs errors=remount-ro 0 1 UUID=882C04092C03F14C /media/user/sda3 ntfs errors=remount-ro 0 1 UUID=13ea474a-fb27-4c91-bae7-c45690f88954 /media/user/sda6 ext4 errors=remount-ro 0 1
again replace
user
in/media/user/sdaX
with your ubuntu account name.A little explanation: UUID="contains the ID of your hard disk partitions, 1st is of
/dev/sda1
and 2nd is of/dev/sda2
partitions and so on.sudo blkid
command is very useful to get the partitions information like UUID, File-system type, partition entry etc.. So any one can use it to get their information./media/user/sda1
is the mount entry of 1st partition and so on. Remember why I created 4 directories above.ntfs
is the file system type of your 1st partition:/dev/sda1
. It may be something else also like:ext3
,ext4
,ntfs
,fat
etc, you can get the info fromsudo blkid
command as I mentioned above. others will be same for all types of file-system, it tells that if any error occurs thenremount the file system in read-only mode
this link is a great tutorial.press Ctrl+x to save and exit. Press y when prompt to save.
Now mount all partitions by executing this command:
sudo mount -a
If you want to mount any specific partition you can use:
sudo mount /dev/sda1
i,e to mount first partition and so on.
Now all your partitions will be mounted automatically when ever you start your system. You can check it by restart your system. :)
Reply if you need further assistance or if something goes wrong.
Edit
I forgot to saw the picture, actually you can create the folder name under /media/bseinn/
the name you want. For example /media/bseinn/data
can be created instead of /media/bseinn/sda3
; similarly /media/bseinn/ubuntudrive
can be created instead of /media/bseinn/sda6
. You've to give the same name in /etc/fstab
file. Hope you can understand.