Saturday, January 15, 2011

How to Auto mount partitions on boot in Fedora ?

Normally in windows when we login in we see all the partitions or drives e.g. c: d: etc. This was when I was a windows user, that means long time back I think more than a decade :). Now, when we login into fedora or ubuntu, we have to click the partitions to mount them, they are not automatically mounted. So, If you are looking for a method by which you can make them auto mount then here are steps: (for ubuntu you can get some utility, which will do the required task , but still you can follow this steps )

Step 1: open disk utility and note down the partition / drive labels and corresponding device names e.g. /dev/sda6 etc.
Disk Utility Partition Name and Label
Step 2: go to the terminal and either su or use sudo

Step 3: run the following commands
$cd /media/
$mkdir <drive label> e.g. mkdir Songs
the second command will create folder in the media directory. All the drives will be mounted in media only. So, if you are having 3 drives to mount then create 3 folders by their name. This is what I follow, name of the folder and partition : same. you can name the folders according to your wish also. That means if the partition label is "Softwares" then create a folder named "Softwares" , this is a easy way to avoid confusion between mounted partitions.

Step 4: open the fstab file which is located in /etc/ in any editor you want
e.g.
$vi /etc/fstab
OR
$gedit /etc/fstab

Step 5: Till now we having the names of the partitions with their respective drive letters (/dev/sdax) and folders created in /media/, this is where we will mount our volumes. We can mount the volume with different permissions, like only read permission to all users and write permission reserved for root, or read and write permission to every one etc.

Here is how my fstab looks like, before mounting the partitions:

#
# /etc/fstab
# Created by anaconda on Fri Nov  5 00:27:12 2010
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=8d1eeb21-4503-4e3f-b4d5-98ce1a7987dc /                       ext4    defaults        1 1
UUID=3c478764-9183-48e0-8676-2ca168d965cd /boot                   ext4    defaults        1 2
UUID=ea5c7972-26de-4f4e-81e0-4890f9942557 /home                   ext4    defaults        1 2
UUID=1b9dd3f0-bac2-407b-a5a8-2b496945d2b4 swap                    swap    defaults        0 0
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0


Now in the opened fstab file add new lines, e.g. we want to mount a ntfs partition named Songs , and we are having the drive letters as /dev/sda5, we want to give read write to every one, and we already created a folder named Songs in '/media'

add the line in the fstab file

/dev/sda5 /media/Songs   ntfs-3g defaults 0 0

which gives me:
#
# /etc/fstab
# Created by anaconda on Fri Nov  5 00:27:12 2010
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=8d1eeb21-4503-4e3f-b4d5-98ce1a7987dc /                       ext4    defaults        1 1
UUID=3c478764-9183-48e0-8676-2ca168d965cd /boot                   ext4    defaults        1 2
UUID=ea5c7972-26de-4f4e-81e0-4890f9942557 /home                   ext4    defaults        1 2
UUID=1b9dd3f0-bac2-407b-a5a8-2b496945d2b4 swap                    swap    defaults        0 0
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
/dev/sda5 /media/WareHouse ntfs-3g defaults 0 0
/dev/sda6 /media/Installations ntfs-3g defaults 0 0
/dev/sda7 /media/SoftwareWareHouse ntfs-3g  defaults 0 0
/dev/sda8 /media/GeekWareHouse ntfs-3g defaults 0 0
/dev/sda9 /media/AudioWareHouse ntfs-3g defaults 0 0
/dev/sda10 /media/VideoWareHouse ntfs-3g defaults 0 0

For fat partitions, use vfat instead of ntfs-3g. Now, you are all set to go, save the file, remount the partitions or reboot, and check your /media/directory.

For a detailed discription of fstab , you can refer to this link: underStand Fstab

I hope this will help you to auto mount your partitions.