Inspect swap config in /etc/fstab
In this step, you will learn how to inspect the /etc/fstab
file to understand how swap space is configured to be automatically activated during system startup.
The /etc/fstab
file (file system table) is a configuration file that contains information about all the disk partitions and network shares that the system can mount. It tells the system which filesystems to mount, where to mount them, and with what options, including swap space.
When the system boots up, it reads /etc/fstab
to determine which filesystems and swap areas should be made available.
To view the contents of /etc/fstab
, we will again use the cat
command.
Open your terminal if it's not already open.
Type the following command and press Enter:
cat /etc/fstab
The output will show lines describing different filesystems and potentially a line for swap. Look for a line that mentions swap
in the filesystem type column.
The output might look something like this:
## /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 or removed. See fstab(5).
#
## <file system> <mount point> <type> <options> <dump> <pass>
/dev/sda1 / ext4 errors=remount-ro 0 1
/swapfile none swap sw 0 0
In this example output, the line /swapfile none swap sw 0 0
is the entry for the swap file.
Let's break down the columns for the swap entry:
/swapfile
: The file or device path for the swap space.
none
: The mount point. For swap, this is typically none
.
swap
: The filesystem type. This indicates it's a swap area.
sw
: Mount options. sw
is a common option for swap, meaning it should be swapped.
0
: Dump option. This is usually 0 for swap.
0
: Pass option. This is usually 0 for swap, meaning it's not checked during boot.
This entry in /etc/fstab
ensures that the /swapfile
is automatically activated as swap space every time the system starts.
By checking /etc/fstab
, you can see how your swap is configured for persistence across reboots.
Click Continue to complete this lab.