Automatic partition mounting in GNU/Linux

Screenshot from 2013-05-10 12:12:30

After the installation of a GNU/Linux system by default the partitions are not automatically mounted. Nowadays GNU/Linux ditros are competing to improve the external appearance. As a result just one mouse-click is enough to mount a partition.Even though it can be set to automatically mount during system boot. Apart from these you can set permissions over the contents of a particular partition with the help of /etc/fstab file. Basic structure of fstab file is as follows.

# /etc/fstab: static file system information.
#
# Use ‘blkid’ to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc            /proc           proc    nodev,noexec,nosuid 0       0
# / was on /dev/sda10 during installation
UUID=3fc4638a-eeef-4315-91a6-fee625d5c428 /               ext4    errors=remount-ro 0       1
# swap was on /dev/sda8 during installation
UUID=0b1f3624-acef-4d85-ba88-34addf72df4c none            swap    sw              0       0

If you have a partition as /dev/sda1 with ntfs(vfat for FAT32) on the system, you can add that file system in the above file as follows and save the same. At your next reboot partition will be automatically mounted.

# /etc/fstab: static file system information.
#
# Use ‘blkid’ to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc            /proc           proc    nodev,noexec,nosuid 0       0
/dev/sda1       /media/vol1     ntfs    defaults        0       0
# / was on /dev/sda10 during installation
UUID=3fc4638a-eeef-4315-91a6-fee625d5c428 /               ext4    errors=remount-ro 0       1
# swap was on /dev/sda8 during installation
UUID=0b1f3624-acef-4d85-ba88-34addf72df4c none            swap    sw              0       0

Note:- For doing this automatic mount you must first create a /media/vol1 directory as a mount point (sudo mkdir /media/vol1).
For setting permissions on the partition you can edit the defaults entry to something like rw,noexec,exec,…
You can set permissions for a particular user using uid=<uid> and umask=<octadecimal_no>.

Advertisements

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 )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s