When a Linux system is newly-installed, all the disk partitions defined and/or created during the installation are configured to be automatically mounted whenever the system boots.
However, what happens when additional disk drives are added to a system after the installation is done? The answer is “nothing” because the system was not configured to mount them automatically. However, this is easily changed.
The answer lies in the /etc/fstab file. This file is used to control what file systems are mounted when the system boots, as well as to supply default values for other file systems that may be mounted manually from time to time.
To get the structure for your system,
man fstab
See fstab
The following is an example of an fstab file on a typical Linux system:
# device name mount point fs-type options dump-freq pass-num
LABEL=/ / ext3 defaults 1 1
/dev/hda6 swap swap defaults 0 0
none /dev/pts devpts gid=5,mode=620 0 0
none /proc proc defaults 0 0
none /dev/shm tmpfs defaults 0 0
# Removable media
/dev/cdrom /mount/cdrom udf,iso9660 noauto,owner,kudzu,ro 0 0
/dev/fd0 /mount/floppy auto noauto,owner,kudzu 0 0
# NTFS Windows XP partition
/dev/hda1 /mnt/WinXP ntfs-3g quiet,defaults,locale=en_US.utf8,umask=0 0 0
# Partition shared by Windows and Linux
/dev/hda7 /mnt/shared vfat umask=000 0 0
# mounting tmpfs
tmpfs /mnt/tmpfschk tmpfs size=100m 0 0
# mounting cifs
//pingu/ashare /store/pingu cifs credentials=/root/smbpass.txt 0 0
# mounting NFS
pingu:/store /store nfs rw 0 0
# with UUID
UUID=11fa2c88-c408-484e-b449-89b6505c6db5 /datadrive ext4 defaults,nofail 1 2
Each line represents one file system and contains the following fields:
The proper way to read records from fstab is to use the routines getmntent(3) or libmount.
cat /etc/fstab
To verify that the changes are correct, you can perform a mount command for all disk
mount -a
Or for one disk
mount /dev/sda2
mount: can't find /dev/sda2 in /etc/fstab or /etc/mtab