Fstab: Difference between revisions

From HPCWIKI
Jump to navigation Jump to search
 
Line 80: Line 80:
/opt/backups    /srv/nfs4/backups  none    bind                                0  0
/opt/backups    /srv/nfs4/backups  none    bind                                0  0
/var/www        /srv/nfs4/www      none    bind                                0  0
/var/www        /srv/nfs4/www      none    bind                                0  0
#SSHFS mount
user@host:/remote/dir  /local/mountpoint  fuse.sshfs  defaults  0  0


#NFS mount  
#NFS mount  

Latest revision as of 10:33, 2 January 2024

In linux, fstab (aka, file systems table) is a configuration table designed to mount and unmount file systems to a machine.

The fstab file is read by the mount command, which happens automatically at boot time to determine the overall file system structure, and thereafter when a user executes the mount command to modify that structure

Fstab syntax

fstab is a 6 column structure, where each column designates a specific parameter and must be set up in the correct order. [1]

Column Description
Device usually the given name or UUID of the mounted device (sda1/sda2/etc).
Mount Point designates the directory where the device is/will be mounted
File System Type shows the type of filesystem in use
Options lists any active mount options. If using multiple options they must be separated by commas.

fs-type independant options

  • defaults : default settings with rw,suid,dev,exec,auto,nouser,async
  • nofail : Do not stop system boot if disk mount failed.
  • atime/noatime/relatime/strictatime : (Linux-specific ) stat structure records when files are last accessed (atime), modified (mtime), and changed (ctime). atime (update on access), noatime (do not update), or (in Linux) relatime (update atime if older than mtime). Through Linux 2.6.29, atime was the default; as of 2.6.30, relatime is the default
  • auto/noauto: controls whether the partition is mounted automatically on boot (or not).
  • dev/nodev: Controls behavior of the interpretation of block special devices on the filesystem
  • exec/noexec: controls whether or not the partition can execute binaries. In the name of security, this is usually set to noexec.
  • sync/async: sync means it is done synchronously. Looking at the example fstab, this is the option used with the floppy.
  • ro/rw: controls read and write privileges - ro = read-only, where rw= read-write.
  • nouser/user/users:
    • user - permits any user to mount the filesystem. This automatically implies noexec, nosuid, nodev unless explicitly overridden.
    • nouser - only root can mount the filesystem.
    • users - every user in group users will be able to unmount the volume.

owner : Permit the owner of device to mount (Linux-specific)

  • suid/nosuid: Controls the behavior of the operation of suid, and sgid bits

fs-type dependent options

  • FAT, NTFS
    • windows_names : restricts the set of allowed characters for the volume to only those acceptable by Windows; though FAT/NTFS are the most common use cases, this feature is not specifically restricted to those filesystem types.
    • uid=n,gid=n : Sets the user identifier (uid), and group identifier (gid) for all files on the filesystem.
    • umask=nnn, dmask=nnn, fmask=nnn : Controls masking of filesystem nodes.
      • umask - user file creation
      • dmask - directory creation
      • fmask - for files only
  • NFS
    • addr=ip-address


For more information look at https://linux.die.net/man/5/fstab

Backup Operation(the first digit) this is a binary system, where

1 = dump utility backup of a partition. 0 = no backup

File System Check Order(second digit) 0 - do not check

1 - check immediately during boot 2 - check after boot

Example

# device-spec   mount-point     fs-type      options                        Backup check-order
LABEL=/         /               ext4         defaults                          1       1
/dev/sda6       none            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

# bind mount
/opt/backups    /srv/nfs4/backups  none     bind                                0   0
/var/www        /srv/nfs4/www      none     bind                                0   0

#SSHFS mount 
user@host:/remote/dir  /local/mountpoint  fuse.sshfs  defaults  0  0


#NFS mount 
192.168.33.10:/backups /backups   nfs   defaults,timeo=900,retrans=5,_netdev	0 0
192.168.33.10:/www /srv/www       nfs   defaults,timeo=900,retrans=5,_netdev	0 0

# Removable media
/dev/cdrom      /mnt/cdrom      udf,iso9660  noauto,owner,ro                   0       0

# NTFS Windows 7 partition
/dev/sda1       /mnt/Windows    ntfs-3g      quiet,defaults,locale=en_US.utf8,umask=0,noexec     0 0

# Partition shared by Windows and Linux
/dev/sda7       /mnt/shared     vfat         umask=000                                           0 0

# Mounting tmpfs
tmpfs           /mnt/tmpfschk   tmpfs        size=100m                                           0 0

# Mounting cifs
//cifs_server_name/ashare  /store/pingu    cifs         credentials=/root/smbpass.txt            0 0

# Mounting NFS
nfs_server_name:/store    /store          nfs          rw                                        0 0

References