OpenSource For You

Auto mounting a partition in Linux

- —Vineeth Kartha, vineethkar­tha@ieee.org

The file that contains the data regarding the devices to be mounted at start-up is in /etc/fstab. To automatica­lly mount a partition, follow the steps given below.

First, create the directory in which your partition will be mounted. Create one directory per partition. I created the directory in /media. This directory is known as the ‘mount point’ for the partition.

To create the mount point, open up the terminal and type the following command:

sudo mkdir location_of_dir/name_of_dir

…or you can use Nautilus, the file manager, to create a folder.

If the directory is created in a location in which you need root privileges, use sudo. After creating the mount point, modify /etc/fstab as per your requiremen­ts. It is always advisable to create a backup of the /etc/fstab file before making any changes, because any error in that file can prevent your OS from booting.

Now, make changes in fstab to auto mount the HDD partition:

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 same order as done for the existing partitions.

The order should be as follows: the device name, the default mount point, the filesystem type, mount options, dump, and the fsck option.

The device name is the name of the HDD partition (such as /dev/sda5): the mount point is the full path of the directory where the partition is to be mounted. The file system type is the type of file system like ext4, fat, ntfs, etc. Mount options are normally given as defaults, while dump and fsck options are given as 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 the following command:

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

sudo mount -a

Save the file and in the command prompt, type the following:

Now, the partition will be automatica­lly mounted on every reboot.

 ??  ??

Newspapers in English

Newspapers from India