Ubuntu – Automatically mount NTFS drive when I login

11.10automountdual-bootwindows 7

I use Ubuntu 11.10 and Windows7 dual boot with Ubuntu as my primary OS.

Every time I need to access a document I need to mount the respective drive, though this is not at all tiresome, still, is there any way that drives becomes automatically mounted when I login?

Best Answer

Notice: If you are using Ubuntu 14.04 and later, Don't forget to check the note at the end of the answer

Go to the Startup Applications, by Clicking right-top corner Settings icon ---> Startup Applications.

enter image description here

The click on the Add button, Write a name for this operation such as "Mount ntfs drives", then in command input box, write this udisks --mount /dev/sda2, to automount the ntfs partition.

Note: You need to replace the /dev/sda2 with your actual NTFS partition number.

You can get this number by this command:

sudo blkid

Below is the output of this command in my computer.

/dev/sda1: UUID="89b18940-d5ff-4ce1-a85a-42cdd0369016" UUID_SUB="57d79ff6-7b53-44bc-82ec-ef783a23efc3" TYPE="btrfs" 
/dev/sda2: LABEL="Main" UUID="A80C1BD70C1B9F7E" TYPE="ntfs" 
/dev/sda3: LABEL="Work" UUID="01CCB271A80A07E0" TYPE="ntfs" 
/dev/sda5: LABEL="Free" UUID="CA9A-4F0A" TYPE="vfat" 
/dev/sda6: LABEL="Ubuntu" UUID="364126ac-01c9-4dd2-ab19-eecc733a9640" TYPE="ext4" 
/dev/sda7: LABEL="Free2" UUID="ed26eebb-524b-4533-869a-9dbd2b92bd64" TYPE="xfs" 
/dev/sda8: UUID="312d4cd9-21a9-4c0d-aa34-26230e70fa89" TYPE="swap" 

For Mounting with Executable permission

For those of you (like me) who wants to have executable permission to be set upon mounting, so that you can have options for execute a file with double-clicking , Add this extra bit of options with udisks command.


So, the total line for /dev/sda2 should be like this (tested on 13.04)

udisks --mount /dev/sda2 --mount-options=umask=022

Caution: If you are a bit worried with security, you may choose not to have this functionality.

Note: Change for Ubuntu 14.04 and later

If you are using Ubuntu 14.04 or newer versions, You may notice that udisks packages is no longer available there. Yes, it is replaced by udisksctl package. So, You need to use udisksctl instead of udisks. It is basically do the same things, but syntax is more easier.

The mount command is --

udisksctl mount -b /dev/sda2 

(in the case your targeted partition is /dev/sda2) Here, -b is indicating that it is a block device

To enable executable permission ---

udisksctl mount -b /dev/sda2 -o umask=022

(Here -o indicating that following are options for udisksctl).

You can access the man page of udisksctl with man udisksctl command or read it online here!

Related Question