33

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?

5 Answers 5

35

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.

--mount-options=umask=022

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!

6
  • Is running this command on startup better than adding an entry to /etc/fstab?
    – Dan
    Sep 3, 2013 at 7:25
  • If adding to startup works, you don't have to add it in /etc/fstab
    – Anwar
    Sep 3, 2013 at 7:41
  • I am on ubuntu 14.04 LTS. A couple notes: I had to find startup applications in unity dashboard search. Had to install udisks via command line apt-get install udisks. Afterwards the selected answer method worked fine for me. Sep 3, 2014 at 21:56
  • udisks is not available in 16.04. It was changed to /usr/bin/udisksctl. I believe the apropriate command would be /usr/bin/udisksctl mount -b PATH/TO/DEVICE. Nov 9, 2016 at 18:30
  • @Blazej read the full answer. It was there
    – Anwar
    Nov 9, 2016 at 18:35
9

The udisks command does the same thing as nautilus

It comes installed by default and doesn't require any changes to your system files.

just add something like:

/usr/bin/udisks --mount /dev/disk/by-uuid/1313-F422

to your startup list.

https://help.ubuntu.com/community/AutomaticallyMountPartitions#udisks

1
  • Btw, at least in Xubuntu, it's a bit different: udisksctl mount -b /dev/disk/by-uuid/THE_UUID. udisksctl is in the udisks2 package and I don't have a udisks package.
    – janos
    Mar 29, 2014 at 7:42
7

I think simply you can add your partition configuration to /etc/fstab as well.

Basically get the partition name from command line either through sudo blkid or sudo fdisk -l SO add to your /etc/fstab with gksu gedit

The entry should look like this:

/dev/sd[ab]# /path_to/mount_point ntfs-3g defaults 0 0

where path to mount point may be something like /home/YourUserName/Windows. You may need to mkdir Windows. Then you can access windows partition in Windows folder inside your Home folder

1

simple - method is to install the pysdm package (in Gutsy) and then use System-Administration-Storage Device Manager without any manual editing of the fstab file, and disregard most of the instructions that follow.

check this site for any doubts

https://help.ubuntu.com/community/AutomaticallyMountPartitions

1

You could do this directly with the mount command.

Edit /etc/rc.local. This gets executed at startup after boot as root:

gksudo gedit /etc/rc.local

and put the mount code inside:

mount_at="/media/OS"
partition="/dev/sda3"

if [ ! -d $mount_at ] #create mound directory if it doesn't exist
then
  mkdir $mount_at
fi

mount -t ntfs $partition $mount_at

where $mount_at is the folder where you want to mount to, and $partition is the name of the partition. My windows partition is at "/dev/sda3" and not "/dev/sda1" because I have a Dell with other small system partitions. To check what is the name of your windows partition do:

sudo fdisk -l

which for me gives

Device Boot      Start         End      Blocks   Id  System
/dev/sda1            2048      206847      102400   de  Dell Utility
/dev/sda2   *      206848    30926847    15360000    7  HPFS/NTFS/exFAT
/dev/sda3        30926848   540132512   254602832+   7  HPFS/NTFS/exFAT
/dev/sda4       540133374   625141759    42504193    5  Extended
/dev/sda5       540133376   619132927    39499776   83  Linux
/dev/sda6       619134976   625141759     3003392   82  Linux swap / Solaris

So /dev/sda3 is the largest NTFS partition, probably the one you want.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .