Working with Systemd Mount Units

30 minutes
  • 3 Learning Objectives

About this Hands-on Lab

Systemd automatically manages mounts for entries that are listed in systemd, and allows you to manually create mount units. In this hands-on lab, you will be tasked with creating systemd mount and automount units.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Create a unit file for the data mount based on the information provided in the instructions and ensure that it is started and enabled.
  1. Create a unit file in /etc/systemd/system named mnt-data.mount with the following contents:
[Unit]
Description=Data mount

[Mount]
What=/dev/disk/by-uuid/filesystem_UUID
Where=/mnt/data
Type=xfs
Options=defaults

[Install]
WantedBy=multi-user.target
  1. Update the systemd manager configuration to include a new unit file:

systemctl daemon-reload

  1. Start and enable the mnt-data.mount unit:

systemctl enable mnt-data.mount --now

Create a unit file for the backup mount based on the information provided in the instructions.
  1. Create a unit file in /etc/systemd/system named mnt-backup.mount with the following contents:
[Unit]
Description=Backup mount

[Mount]
What=/dev/disk/by-uuid/filesystem_UUID
Where=/mnt/backup
Type=ext4
Options=ro

[Install]
WantedBy=multi-user.target
  1. Create a mountpoint for mnt-backup.mount at /mnt/backup:

mkdir /mnt/backup

  1. Update the systemd manager configuration to include a new unit file:

systemctl daemon-reload

Create an automount unit file for mnt-backup.mount based on the information provided in the instructions and ensure that it is started and enabled.
  1. Create a unit file in /etc/systemd/system named mnt-backup.automount with the following contents:
[Unit]
Description=Automount backup directory

[Automount]
Where=/mnt/backup
TimeoutIdleSec=600

[Install]
WantedBy=multi-user.target
  1. Update the systemd manager configuration to include new unit file:

systemctl daemon-reload

  1. Start and enable the mnt-backup.automount unit:

systemctl enable mnt-backup.automount --now

Additional Resources

You work as a Linux engineer and have been tasked with creating two new mount units on your host. The first mount unit should use the /dev/xvdg1 file system and be mounted on /mnt/data. The type of filesystem is XFS, and it should be mounted using the default options. The description should be "Data mount," and it should be wanted by the multi-user.target.

Once the unit file has been created, ensure that it is started and enabled. The second mount should use the /dev/xvdg2 file system and be mounted on /mnt/backup. The type of filesystem is ext4, and it should be mounted as read-only. The description should be "Backup mount," and it should be wanted by the multi-user.target. This file system should be automatically mounted using an automount unit with an idle timeout of 10 minutes. The description of the automount should be "Automount backup directory,” and it should be wanted by the multi-user.target. Once created, ensure that the automount is started and enabled.

Note:

  • All tasks should be performed as the root user.
  • All unit files should be created in /etc/systemd/system
  • The UUIDs of the filesystems will change with each attempt

What are Hands-on Labs

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.

Get Started
Who’s going to be learning?

How many seats do you need?

  • $499 USD per seat per year
  • Billed Annually
  • Renews in 12 months

Ready to accelerate learning?

For over 25 licenses, a member of our sales team will walk you through a custom tailored solution for your business.


$2,495.00

Checkout
Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!