https://www.rosehosting.com/blog/fstab-options
Fstab options: What are they, and when should you use them?
What is fstab in Lunix? What are fstab options, and when should you use them? Our latest tutorial covers all the fstab details and everything you need to know about this file. Let’s get straight into it.
Table of Contents
What is fstab?
Fstab stands for files system table and is a system file found in the /etc directory on the Linux server. The fstab file lists the available disk partitions and other disk-related file systems.
The mount command reads it and automatically mounts most entries during system boot. A set of rules in the fstab command controls how the system treats different filesystems each time it introduces them. The system administrators handle the maintenance of the fstab command.
The structure of the fstab command
Fstab stands for files system table. The six-column structure of that table requires setting up parameters in each column in the correct order. We will explain the columns separately, and important to know is that they are as follows from left to right:
[Device] [Mount Point] [File System Type] [Options] [Dump] [Pass]
Let’s explain all these in more detail:
Device: The UUID of the mounted device. (sda, sdb, etc.)
Mount Point: Your root file system mounts the device on this directory. The names of the mount points must not have spaces between them.
File System Type: Type of file system. It can be vfat, ntfs, ext4, ext3, etc.
Options: Options depend on the file system. It lists any active mount options. If there are multiple options, they must be separated by commas.
Dump (Backup Operation): The backup operation can have two values, 0 OR 1. If the value is 0, then there is no backup. It is disabled. Otherwise, if it is 1, then the backup of the partition is enabled. System administrators set this field to 0, as it uses an obsolete method they should avoid.
Pass (File System Check Order): The file system check determines the partition checking order during system boot. If the value is 0, then the fsck (file system check) will not check the filesystem. If the value is higher than 0 and is 1, then the order check should be set for the root filesystem. The other partitions should be set with 2, etc.
The usage of the fstab command
System administrators use the fstab for internal devices, CD/DVD drives, and network shares. Additionally, system administrators can add removable devices to fstab. System administrators configure partitions listed in fstab to mount automatically during boot. Only root users can see and mount partitions not listed in fstab. As we already explained the structure of the fstab command, we will now look at the content of the /etc/fstab file. To do that, execute the following command:
cat /etc/fstab
You should get an output similar to this:
root@host:~# cat /etc/fstab # /etc/fstab: static file system information. # # Use 'blkid' to print the universally unique identifier for a # device; this may be used with UUID= as a more robust way to name devices # that works even if disks are added and removed. See fstab(5). # # systemd generates mount units based on this file, see systemd.mount(5). # Please run 'systemctl daemon-reload' after making changes here. # # # / was on /dev/vda1 during installation UUID=1fa0d2dd-2039-44cf-bd49-c2c765693d9a / ext4 errors=remount-ro 0 1 1 /dev/vda2 none swap sw 0 0
As you can see, the fstab has the following parameters:
Device: UUID=1fa0d2dd-2039-44cf-bd49-c2c765693d9a
Mount Point: /
File System Type: ext4
Options: errors=remount-ro
Dump (Backup Operation): 0
Pass (File System Check Order): 1
Useful Commands
There are some useful commands that you can use for listing drives, mounting, and creating mount points.
1. To get a list of all UUIDs, you can use the following command:
ls -l /dev/disk/by-uuid
You will get an output similar to this:
root@host:~# ls -l /dev/disk/by-uuid total 0 lrwxrwxrwx 1 root root 10 Aug 10 06:34 1fa0d2dd-2039-44cf-bd49-c2c765693d9a -> ../../vda1 lrwxrwxrwx 1 root root 10 Aug 10 06:34 706a6c4b-2cb1-4de0-899d-1e858ac12204 -> ../../vda2
2. To list the drivers and relevant attached partitions, you can use the command below:
sudo fdisk -l
Giving you an output similar to the below:
root@host:~# fdisk -l Disk /dev/vda: 80 GiB, 85899345920 bytes, 167772160 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0x076a3d03 Device Boot Start End Sectors Size Id Type /dev/vda1 * 2048 165675008 165672961 79G 83 Linux /dev/vda2 165675009 167772159 2097151 1024M 82 Linux swap / Solaris
3. To mount all file systems in /etc/fstab, you can use the following command:
sudo mount -a
4. To create a new mount point, using root privileges, you can use the command below:
sudo mkdir /path/to/mountpoint
5. To check the content of the fstab, we already mentioned the command in the previous paragraph:
cat /etc/fstab
Any other fstab options?
Of course. Though these are some basic fstab options for entry-level use on a Linux OS. If you have any other suggestions or questions, drop a comment down below and we’ll try to help out as soon as we can.
If you have issues using command-line code, you can always contact our technical support. All our fully-managed plans include 24/7 support, and our admins will help you immediately.
No comments:
Post a Comment