Linux - FSTAB (file systems table)

About

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.

Management

/etc/fstab format

To get the structure for your system,

man fstab

See fstab

Example

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:

  • File system specifier — For disk-based file systems:
  • Mount point — Except for swap partitions, this field specifies the mount point (a directory) to be used when the file system is mounted
  • File system type — The type of file system present on the specified device (note that auto may be specified to select automatic detection of the file system to be mounted, which is handy for removable media units such as diskette drives)
  • Mount options — A comma-separated list of options that can be used to control mount's behavior
    • defaults
    • nofail: the system will not fail to boot if the disk is not present
  • Dump frequency — If the dump backup utility is used, the number in this field will control dump's handling of the specified file system
  • File system check order — Controls the order in which the file system checker fsck checks the integrity of the file systems

Read

The proper way to read records from fstab is to use the routines getmntent(3) or libmount.

cat /etc/fstab

Verification

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





Discover More
Card Puncher Data Processing
Azure - File Storage

one time mount:
Azure Diagnose Connection Linux Vm
Azure - SSH troubleshooting

When you can't connect to your machine via SSH. Go to the Azure Portal Select your machine Select “Diagnose and solve problems” Wait a little bit Select “I...
Linux - Adding storage without LVM

When you add a disk device to your system, you need to add this storage in your Linux environment When you improve the disk capacity of your Virtual Vmware Machine, you just need to configure the device...
Linux - File System

File system in a Linux Context. A file system is created on a partition The supported file systems include (but are not limited to): EXT2 EXT3 NFS ISO 9660 MSDOS VFAT The file system...
Linux - Mounting File Systems (CDROM, NFS, SMB, )

All files accessible in a Unix system are arranged in one big tree, the file hierarchy, rooted at /. These files can be spread out over several devices. The mount command serves to attach the file...
Linux - Samba - How to mount/map a Windows Share on Linux

Often you use a central Windows repository to save your installation file. In order to make them available to Linux, you can mount a Windows Share instead of to copy them. If you want to “map a drive”...
Linux - Shared Memory (SHM) (/dev/shm)

Shared memory (SHM) in Linux. The shared memory system can also be used to set permissions on memory. There are two different types of shared memory implementations: System V IPC, and BSD mmap....
Linux - Swap / Paging

swapping in an Linux Context. You created partitions of the type “swap” when you scheduled the hard disks during the installation of your Linux distribution. The Linux kernel usually does not require...



Share this page:
Follow us:
Task Runner