Skip to main navigation

# Blogs & News

Maintenance

# Where is /etc/fstab in Clear Linux?

Puneet Sethi

29 Oct, 2018

When you install a Clear Linux OS, you may notice that a fstab file does not exist under the /etc folder like you’d normally expect. You might ask:

> - Where is the fstab file?
> - How do I add additional drives or mount points?
> - How does the boot process know which partition is root (/) and swap?

In Clear Linux OS, the /etc/fstab file is non-existent by design. Clear Linux OS segregates user configuration from the OS distributed configuration. By avoiding placing anything in the /etc folder, Clear Linux OS enables a stateless OS architecture, which offers several benefits.

## fstab

/etc/fstab is a configuration file commonly found on Linux operating systems to describe where on the Linux filesystem hierarchy drive partitions or remote filesystems (exports) should be mounted.

So, how do you add a new mount point to your system with no /etc/fstab? Simple. Just because /etc/fstab doesn’t exist by default, doesn’t mean you can’t create it yourself.

1. First, you need to identify the local or remote filesystem you want to mount:

       sudo lsblk
       sudo df -h

   In the example below, we will mount a local secondary disk that is available: /dev/sdb
2. Then, create the /etc/fstab file with a privileged editor:

       sudoedit /etc/fstab

   NOTE: The `sudo` bundle needs to be installed for the `sudoedit` command to be available on Clear Linux OS.

   The expected formatting is that of a regular Linux fstab file. A simple example of an fstab entry is shown below. This can be copied into your /etc/fstab file and customized for your system. You should refer to the Linux man page on fstab for more details on the standard format and options:

       # [device-spec] [mount-point] [fs-type] [options] [dump] [pass]

       /dev/sdb	/home		btrfs		defaults	0 0

3. Reboot after creating the file above. And that’s it. By adding the fstab config file, it is automounted in Clear Linux OS at boot.

So, how does Clear Linux boot without /etc/fstab referencing the root or swap partitions?

## Automounting

The Clear Linux OS init process leverages some components from systemd for partition identification and mounting, simplifying the boot process and enabling a stateless design.

This is done seamlessly without needing any additional action from you. Let’s explore how:

1. The fstab-generator component parses the /etc/fstab file to create systemd mount units on the fly. This allows the well-known fstab format to continue being used by system administrators while systemd handles the conversions behind the scenes.
   You can verify the behavior by listing systemd units files which end in .mount:

       sudo systemctl list-units *.mount

2. The gpt-auto-generator component makes the root (/), boot EFI (/boot), and swap partitions discoverable to Clear Linux OS during the boot process. This is done by “tagging” these special partitions in the GUID Partition Table (GPT) instead of depending on a file on the filesystem or kernel boot parameters.
   You can verify this tagging by examining block device attributes with blkid:

       sudo blkid -p -s PART_ENTRY_NAME -s PART_ENTRY_TYPE /dev/sdb1

       /dev/sdb1: PART_ENTRY_NAME="root" PART_ENTRY_TYPE="4f68bce3-e8cd-4db1-96e7-fbcaf984b709"

3. The Discoverable Partition Specification denotes this UID code (4f68bce3-e8cd-4db1-96e7-fbcaf984b709) as Linux root filesystem for x86-64 systems.
   Another way to examine the GPT partition table is with the gdisk program, which comes in the storage-utils bundles, as shown below:

       $ sudo gdisk
       GPT fdisk (gdisk) version 1.0.4

       Type device filename, or press <Enter> to exit: /dev/sdb
       Partition table scan:
       (redacted)

       Command (? for help): i
       Using 1
       Partition GUID code: 4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709 (Linux x86-64 root (/))
       Partition unique GUID: 0000000-0000-0000-0000-000000000000
       First sector: 2048 (at 1024.0 KiB)
       Last sector: 209713151 (at 100.0 GiB)
       Partition size: 209711104 sectors (100.0 GiB)
       Attribute flags: 0000000000000000
       Partition name: 'root'

   The Partition GUID code output from the gdisk identifies the partition type as the Linux root filesystem for x86-64 systems.

Clear Linux OS takes advantage of systemd as an init process and the modern mounting and booting mechanisms it provides. This, in turn, allows Clear Linux to operate even when no /etc/fstab file is present..