Wednesday, March 21, 2007

Auto mounting File Systems in Linux

Some Linux Distros (like Fedora Core 6 FC6) do not automatically mount the local file systems such as FAT/FAT32 systems that belong to the windows drive. To mount and unmount file systems you must be logged on as a root user or must have root privileges

Mounting Manually

First change to root

@localhost ~]$ su
Password: Password
root@localhost ]# mount -t Filesystem Device Directory

Mounting the file system manually is done by the mount command.

Filesystem is vfat for FAT/FAT32 File System.
Other filesystems that could be given can be found on

The Device can be got from System > Administration > Logical Volume Management which shows local hard drives and its name as

The Directory specifies which folder must the file system be mounted into. For example if you want to mount to mnt/hddC/ the device /dev/sda8 (FAT32) , the full command is

@localhost ~]$ su
root@localhost ]# mkdir /mnt/hddC
root@localhost ]# mount -t vfat /dev/sda8 /mnt/hddC

Install ntfs-3g module by yum install ntfs-3g

root@localhost ]# mount -t ntfs-3g /dev/sda5 /mnt/hddD -o force

Unmounting the File System

@localhost ~]$ su
root@localhost ]# umount /dev/sda8

Automatcially Mounting File Systems :

To automatically mount certain file systems, so that we do not want to do the same procedure each time the computer starts, we have to edit the
file. To edit the same you must have root access. Assuming you have root access to mount a local Filesystem, add the following line.

Device ID Mount Directory FileSystem Options

/dev/sda8 /mnt/sda1 vfat rw,umask=0000,uid=500,gid=500 0 0

where the uid=500, gid=500 must be replaced by the proper user ids which can be got from System > Administration > Users and Groups in Fedora Core 6.

Automounting NTFS
/dev/sda8  /mnt/hddD  ntfs-3g  default 0 0

Help me
I did this in Fedora Core 6. If any of you guys have any information on how to do the same on other linux distros , or if you have any other information, please post a comment.


Ketan said...

/etc/fstab is a typical linux thing and can be found on every distribution which caters to desktop... (not sure about embedded linux)..fstab --> file system table.

Check out

Anirudh said...

You can use fdisk to find out the partitions that you want to mount -

debian-indraprastha:~# fdisk -l

Disk /dev/sda: 40.0 GB, 40060403712 bytes
255 heads, 63 sectors/track, 4870 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 1912 15358108+ c W95 FAT32 (LBA)
/dev/sda2 1913 3960 16450560 f W95 Ext'd (LBA)
/dev/sda3 3961 4870 7309575 83 Linux
/dev/sda5 1913 3187 10241406 b W95 FAT32
/dev/sda6 3917 3960 353398+ 82 Linux swap / Solaris
/dev/sda7 3188 3916 5855661 83 Linux

and..when mounting fat32 partitions using the mount command, you don't have to specify the filesystem type. It will be autodetected. For eg:
debian-indraprastha:~# mount /dev/sda1 /disks/c