- Lab
-
Libraries: If you want this lab, consider one of these libraries.
- Cloud

Configure /etc/fstab to Persistently Mount a File System
Learning to create file systems and persistently mount them across reboots is an essential skill for Linux administrators. In this lab, we format two new system disks and create filesystems on the newly-created disk partitions. Then we create the directories for the mount points and configure `/etc/fstab` to persistently mount the file systems so they are available on system startup.

Lab Info
Table of Contents
-
Challenge
Log in to the Lab Server and Gain `root` Access
# sudo -i
-
Challenge
Format `xvdb`
List the available system disks and format
/dev/xvdb
. Entern
fornew partition
,p
forprimary
, and take the defaults. Typew
to write the changes to the system.# lsblk # fdisk /dev/xvdb Welcome to fdisk (util-linux 2.23.2). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Device does not contain a recognized partition table Building a new DOS disklabel with disk identifier 0xae23de7b. Command (m for help): n Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): p Partition number (1-4, default 1): First sector (2048-4194303, default 2048): Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-4194303, default 4194303): Using default value 4194303 Partition 1 of type Linux and of size 2 GiB is set Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.
-
Challenge
Create the File System and Directory for `dbadmin`
# mkfs.xfs /dev/xvdb1
# mkdir /dbadmin
-
Challenge
Configure `xvdb1` to Be Persistently Mounted
Configure
/etc/fstab
to persistently mount the/dbadmin
file system as read-only. Mount the file system, verify it mounted successfully, and test creating a file in that directory.# blkid /dev/xvdb1
# vim /etc/fstab UUID:<YOURDEVICESUUID> /dbadmin xfs ro,defaults 0 0
# mount -a # df -h # cd /dbadmin # touch test touch: cannot touch ‘test’: Read-only file system
-
Challenge
Format `xvdc`
List the available system disks and format
/dev/xvdc
. Entern
fornew partition
,p
forprimary
, and take the defaults. Typew
to write the changes to the system.# lsblk # fdisk /dev/xvdc Welcome to fdisk (util-linux 2.23.2). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Device does not contain a recognized partition table Building a new DOS disklabel with disk identifier 0xae23de7b. Command (m for help): n Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): p Partition number (1-4, default 1): First sector (2048-4194303, default 2048): Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-4194303, default 4194303): Using default value 4194303 Partition 1 of type Linux and of size 2 GiB is set Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.
-
Challenge
Create the File System and Directory for `www`
# mkfs.xfs /dev/xvdc1
# mkdir /www
-
Challenge
Configure `xvdc1` to Be Persistently Mounted
Configure
/etc/fstab
to persistently mount the/www
file system. Mount the file system and verify it mounted successfully.# blkid /dev/xvdc1
# vim /etc/fstab UUID:<YOURDEVICESUUID> /www xfs defaults 0 0
# mount -a # df -h
About the author
Real skill practice before real-world application
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Learn by doing
Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.
Follow your guide
All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.
Turn time into mastery
On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.