Auto mounting ext3/ext4 filesystem linux


To auto mount ext3/ext4 file filesystem on Linux we need to configure it on /etc/fstab file.

To configure /etc/fstab we need know hard disk name, filesystem type and on which path we want to mount.

To do this process you need to login as root or use sudo, since most of the commands are with root privilege.

Select hard disk name with fidisk -l command:

$ fdisk -l


Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x263745a1

Device Boot Start End Blocks Id System
/dev/sda1 * 2048 206847 102400 7 HPFS/NTFS/exFAT
/dev/sda2 206848 81922047 40857600 7 HPFS/NTFS/exFAT
/dev/sda3 81922048 245762047 81920000 7 HPFS/NTFS/exFAT
/dev/sda4 245764094 976771071 365503489 5 Extended
/dev/sda5 245764096 304355327 29295616 83 Linux
/dev/sda6 304357376 323887103 9764864 82 Linux swap / Solaris
/dev/sda7 323889152 976771071 326440960 83 Linux

From above output I will configure /dev/sda7 to mount automatically on boot.

Get filesytem type with following command:

$ file -sL /dev/sda7


/dev/sda7: Linux rev 1.0 ext4 filesystem data, UUID=5d91866d-17c4-4187-839e-0bf45619ca83 (needs journal recovery) (extents) (large files) (huge files)

From above output we can find that filesystem type as ext4.

Now decide the path on which you want to mount /dev/sda7. Here I am choosing past as /home2.

To mount as /home2 create /home2 directory with mkdir command.

Now open /etc/fstab file with any text editor and add following line of code then save and exit from it.

/dev/sda7 /home2 ext4 defaults 0 0

If your file system is ext3 then use ext3 instead of ext4 in above line.

Use following command to mount /home2:

$ mount /home2

Then check with df -h or ls /home2 command if its mounted or not.

This process will allow /home2 or /dev/sda7 to mount automatically on boot time.