Thursday, April 1, 2021

FSTAB , Linux




The /etc/fstab File

So far, we’ve seen several examples of the mount command to attach to various filesystems. However, the mounts won’t survive after a reboot.

For some filesystems, we may want to have them automatically mounted after system boot or reboot. The /etc/fstab file can help us to achieve this.


FSTAB File, You have to edit using Vi or VIM editor and enter 6 Fields separated by space and then save it

Make sure You take a back up of current/original FSTAB file


Table structure

The table itself is a 6 column structure, where each column designates a specific parameter and must be set up in the correct order. The columns of the table are as follows from left to right: 

  • 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: nothing trick here, shows the type of filesystem in use. 
  • Options: lists any active mount options. If using multiple options they must be separated by commas. 
  • Backup Operation: (the first digit) this is a binary system where 1 = dump utility backup of a partition. 0 = no backup. This is an outdated backup method and should NOT be used. 
  • File System Check Order: (second digit) Here we can see three possible outcomes.  0 means that fsck will not check the filesystem. Numbers higher than this represent the check order. The root filesystem should be set to 1 and other partitions set to 2

[root@ip-172-31-58-120 ec2-user]# blkid
/dev/xvda1: LABEL="/" UUID="74fc4c15-c86f-4c31-92f6-0df873546b85" TYPE="xfs" PARTLABEL="Linux" PARTUUID="ed868158-eb4b-43a5-8ed5-8b58aa998193"
/dev/xvdf: UUID="2008-11-19-03-48-46-00" LABEL="CDROM" TYPE="iso9660" PTUUID="4971ec01" PTTYPE="dos"

[root@ip-172-31-58-120 ec2-user]# lsblk -f
NAME  FSTYPE  LABEL UUID                                 MOUNTPOINT
xvda
xvda1 xfs     /     74fc4c15-c86f-4c31-92f6-0df873546b85 /
xvdf  iso9660 CDROM 2008-11-19-03-48-46-00               /media/census

[root@ip-172-31-58-120 census]# cat /etc/fstab
UUID=74fc4c15-c86f-4c31-92f6-0df873546b85    /            xfs     defaults,noatime  1   1
UUID=2008-11-19-03-48-46-00                 /media/census iso9660 defaults 0 0


No comments:

Post a Comment

Azure - Pipeline - Add Approver for Stage

https://learn.microsoft.com/en-us/azure/devops/pipelines/process/approvals?view=azure-devops&tabs=check-pass