Howto setup fstab

    The purpose of this ducument is to show you the fstab and mount command.


    fstab basic

    The “/etc/fstab” can be used to define how disk partitions, or remote filesystems should be mounted into the filesystem. it contains the following fields separated by a space or tab:

     <file system>        <dir>         <type>    <options>             <dump> <pass>


    • file system - the partition or storage device to be mounted.
    • dir - the mountpoint where is mounted to.
    • type - the file system type of the partition or storage device to be mounted. Examples: ext4, btrfs, reiserfs, xfs, jfs, smbfs, iso9660, vfat, ntfs, swap and auto.
    • options the default mount options for the filesystem to be used.
    • dump - used by the dump utility to decide when to make a backup. The entries are 0 and 1. If 0, dump will ignore the file system; if 1, dump will make a backup.
    • pass - used by fsck to decide which order filesystems are to be checked. The entries are 0, 1 and 2. The file systems you want to have checked should have a 2. File systems with a value 0 will not be checked by the fsck utility.

    If you want to mount file systems automatically, you can modify fstab configuration. This assumes the partition(/dev/sdb1) is formated as ext4, Let`s auto mount it, add the following line to the fstab.

    /dev/sdb1    /path/to/mountpoint    ext4    defaults    0    0

    Howto identify filesystems

    $sudo lsblk -f


    All partitions and devices have a unique UUID. They are generated by filesystem utilities, when you create or format a partition.


    Basic usage

    The general mount command syntax to mount a device:

    $sudo mount -t type device destination_dir


    Mount a CD-ROM

    $sudo mount -t iso9660 -o ro /dev/cdrom /mnt

    Checking the mountpoints

    You can also use df command to view all the mount points.

    $sudo df
    [sudo] password for edwin: 
    Filesystem     1K-blocks      Used Available Use% Mounted on
    /dev/sda5       19092180   4361576  13737736  25% /
    none                   4         0         4   0% /sys/fs/cgroup
    udev             1979460         4   1979456   1% /dev
    tmpfs             398048      1092    396956   1% /run
    none                5120         0      5120   0% /run/lock
    none             1990228       144   1990084   1% /run/shm
    none              102400        28    102372   1% /run/user
    /dev/sda1         463844     36143    399234   9% /boot
    /dev/sda6       38314312   2394128  33950832   7% /var
    /dev/sda8       93628352  49393896  39455348  56% /opt

    Mount all the filesystem saved in “/etc/fstab”

    $sudo mount -a

    Unmount all the filesystems mentioned in “/etc/mtab”

    $sudo umount -a

    Mount an iso image into a directory

    $sudo mount -t iso9660 -o loop pdf_collections.iso /mnt

    Related articles

    comments powered by Disqus