Skip to content

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
  • Labs icon Lab
  • A Cloud Guru
Google Cloud Platform icon
Labs

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.

Google Cloud Platform icon
Labs

Path Info

Level
Clock icon Intermediate
Duration
Clock icon 30m
Published
Clock icon Jun 19, 2020

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.

Table of Contents

  1. Challenge

    Log in to the Lab Server and Gain `root` Access

    # sudo -i
    
  2. Challenge

    Format `xvdb`

    List the available system disks and format /dev/xvdb. Enter n for new partition, p for primary, and take the defaults. Type w 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.
    
  3. Challenge

    Create the File System and Directory for `dbadmin`

    # mkfs.xfs /dev/xvdb1
    
    # mkdir /dbadmin
    
  4. 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
    
  5. Challenge

    Format `xvdc`

    List the available system disks and format /dev/xvdc. Enter n for new partition, p for primary, and take the defaults. Type w 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.
    
  6. Challenge

    Create the File System and Directory for `www`

    # mkfs.xfs /dev/xvdc1
    
    # mkdir /www
    
  7. 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
    

The Cloud Content team comprises subject matter experts hyper focused on services offered by the leading cloud vendors (AWS, GCP, and Azure), as well as cloud-related technologies such as Linux and DevOps. The team is thrilled to share their knowledge to help you build modern tech solutions from the ground up, secure and optimize your environments, and so much more!

What's a lab?

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.

Provided environment for hands-on practice

We will provide the credentials and environment necessary for you to practice right within your browser.

Guided walkthrough

Follow along with the author’s guided walkthrough and build something new in your provided environment!

Did you know?

On average, you retain 75% more of your learning if you get time for practice.

Start learning by doing today

View Plans