My Pages

Sunday, February 24, 2013

How to auto-mount drives on linux startup

For linux to automatically mount your drives on startup, you have to store some credentials on fstab file located on /etc/fstab.

1. First of all find out the drivename of the file (sda1,sda2, etc.)


$ cd /dev/disk/by-label
$ ls -l

(Here you can see the label of the drive by which you will know drivename of the drive you are going to automount)

For e.g. I am going to automount the drive Nirvik then its drivename to be noted is sda4.
lrwxrwxrwx 1 root root 10 Feb 25 07:42 Nirvik -> ../../sda4
lrwxrwxrwx 1 root root 10 Feb 25 07:42 System\x20Reserved -> ../../sda1


2. Now get the uuid of the drive Nirvik.



$ cd /dev/disk/by-uuid
$ ls -l


lrwxrwxrwx 1 root root 10 Feb 25 07:42 3E04DFA004DF5A0B -> ../../sda1
lrwxrwxrwx 1 root root 10 Feb 25 07:42 54B40149B4012F54 -> ../../sda4
lrwxrwxrwx 1 root root 10 Feb 25 07:42 6e9ed8e2-c007-4dbf-97f4-8894772cab17 -> ../../sda3
lrwxrwxrwx 1 root root 10 Feb 25 07:42 B298E70B98E6CCC3 -> ../../sda2

Now i got the uuid of the drive Nirvik as highlighted above for sda4.


3. Create a directory to mount the drive

$ sudo mkdir /media/E

4. Store this uuid in the file /etc/fstab.


$ gedit /etc/fstab (this will open the fstab file as a text file with gedit application)


5. Enter the credentials with as:


UUID=54B40149B4012F54 /media/nirvik/E ntfs defaults,umask=007,gid=46 0 0

Here in the 1st column I have set the UUID of the drive, in the 2nd column the directory to mount, in the 3rd the file system, mount options in the 4th, dump options in the 5th and fsck option in the 6th.

6. Reboot and you are done



No comments:

Post a Comment