Automounting A partition in Ubuntu


Certain times we may have a hard disk that has several partitions and of which only one is related to the Installed ubuntu OS.

The remaining partitions have to be mounted each time you start your computer. I had faced such a situation where my music files and all other documents where on a separate partition and each time i had to mount them manually and provide my password (till ubuntu9.10, from ubuntu 10.04 they have not been prompting for password), I could not set my library location in banshee and i couldn’t do such configurations because each time i shutdown tat location is lost to the player, so i decided to set automount, this article will be helpful to all those who face any similar situation.

The file that contains the data regarding the devices to be mounted at startup are in /etc/fstab

Screenshot of /etc/fstab

First we have to create a directory to which our partition will be mounted  create one directory per partition. I created the directories in the directory /media

open up the terminal and type

sudo mkdir location_of_dir/name_of_dir

or you can use nautilus the file manager to create a folder.

If the the directory is created in a location where u need root privileges use sudo,

after that we can modify /etc/fstab, It is always advisable to create a backup of the /etc/fstab because any error in that file can prevent your OS from booting.

Once you have created the backup.

sudo gedit  /etc/fstab

open the /etc/fstab with a text editor of your choice with root privileges

In this file add the details in the order

<file system> <mount point>   <type>  <options>       <dump>  <pass>

Where filesystem can be obtained by checking the output of the command

mount -l

perform this operation when the required partition is mounted from that you will obtain the filesystem something like /dev/sda3 etc

Mount point is the directory you created specify full path.

type is the type of file system like ext4,fat,ntfs etc.

options is normally given as defaults and dump and pass is given 0

I had a partition /dev/sda5 and i created the directory /media/mydisk my partition was of type ext4, so to my /etc/fstab I added

/dev/sda5                  /media/mydisk      ext4      defaults      0      0     

Save the file and in command prompt type

sudo mount -a

If everything went well your partitons should be mounted by now now try restarting your compurter and you can still see that your partitions are amounted, and you are free you don’t have to mount them everytime.

Hope this will be helpfull to you.

Advertisements

About vineethkartha

Hi, I am Vineeth Kartha, I hold a Masters degree in Embedded Systems from BITS Pilani, Goa Campus. I currently work as a Software Developer. I am A free software promoter and electronics hobbyist. In my free time I do a little bit of birding and Wildlife photography. I love travelling, reading and blogging.

Posted on August 21, 2011, in Technical and tagged , , , , . Bookmark the permalink. Leave a comment.

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 )

Google+ photo

You are commenting using your Google+ 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 )

Connecting to %s

%d bloggers like this: