cancel
Showing results for 
Search instead for 
Did you mean: 
TudorRaduta
Community Manager
Community Manager
  • 232 Views

Scenario & a solution

Happy Friday! Let's work through a hands-on scenario.

Scenario: a new, unformatted 5 GiB disk has been added to your system. Your task is to:

  1. Create a new logical volume named lv_data01 that is 2 GiB in size.

  2. Place it in a new volume group named vg_database.

  3. Format the logical volume with the xfs file system.

  4. Ensure it's automatically mounted on /srv/data at boot.

Without looking at the man pages, what are the main commands (pvcreate, vgcreate, lvcreate, etc.) you would use in order to accomplish this? Let's map out the steps!

8 Replies
TudorRaduta
Community Manager
Community Manager
  • 231 Views

My first step would be to use lsblk to identify the device name of the new disk...

shashi01
Moderator
Moderator
  • 194 Views

# 1. Identify the new disk (e.g., /dev/sdb)
lsblk

# 2. Initialize the disk as a Physical Volume
pvcreate /dev/sdb

# 3. Create a Volume Group named 'vg_database'
vgcreate vg_database /dev/sdb

# 4. Create a 2 GiB Logical Volume named 'lv_data01'
lvcreate -L 2G -n lv_data01 vg_database

# 5. Format the Logical Volume with XFS filesystem
mkfs.xfs /dev/vg_database/lv_data01

# 6. Create the mount point directory
mkdir -p /srv/data

# 7. Get the UUID of the Logical Volume (for fstab)
blkid /dev/vg_database/lv_data01

# 8. Edit /etc/fstab to ensure automatic mounting at boot
vim /etc/fstab

# 9. Reboot the system to validate fstab mount
 systemctl reboot

# 10. Verify it's mounted
df -h /srv/data

Screenshot From 2025-09-26 16-24-25.png

bnhashmi
Cadet
Cadet
  • 59 Views

@shashi01I dont think so we need to reboot the system.

 

systemctl dameon-reload

mount -av

df -Th /srv/data 

shashi01
Moderator
Moderator
  • 49 Views

@bnhashmi 

Thanks for the suggestion! You're right that mount -a can be used to validate the /etc/fstab entry immediately.

However, the original task requires ensuring that the mount happens automatically at boot , and the most reliable way to confirm that is with a reboot, which simulates the real boot process.

So while mount -a is useful for quick validation, rebooting guarantees that everything works as expected during the actual system startup, which is what the question asked for

The question specifically asks:

"Ensure it's automatically mounted on /srv/data at boot."

That means the system must:

Read the /etc/fstab entry during boot.

Successfully mount the logical volume to /srv/data without manual intervention.

0 Kudos
Chetan_Tiwary_
Community Manager
Community Manager
  • 25 Views

@bnhashmi You are right that for this simple xfs disk/ LVM mounting , we dont need to reboot the system and mount -a will mostly check all the possible errors ( (bad device path, wrong UUID, missing filesystem driver, permission issues etc. )

You can also use nofail in the fstab for non critical entries. 

 

However, please recall that if you have fstab entries for a network device such as NFS, hot plugged devices like USB, multipath, or which needs a custom kernel driver /module which is not available early during boot, then ordering , dependencies or race conditions are there -  in this scenario a reboot is indeed the most reliable way to confirm the mount at boot time scenario.

In a systemd-based Linux, the system reads /etc/fstab (via systemd-fstab-generator) early in the boot process to convert fstab entries into .mount units in memory (in /run/systemd/generator/), which is then used by systemd to mount filesystems.

Chetan_Tiwary__0-1759254619693.png

https://www.man7.org/linux/man-pages/man8/systemd-fstab-generator.8.html 

0 Kudos
Chetan_Tiwary_
Community Manager
Community Manager
  • 127 Views

I would nominate @Trevor   @ARoumiantsev  for this challenge! 

Trevor
Commander Commander
Commander
  • 113 Views

Chetan,

I accept your nomination!!!  Bear with me on the submission of
my solution.  For the next 3 days, I'm a little engaged with a
Cybersecurity conference.  For sure, after I'm free, I've got to
take a bite of this!!

Trevor "Red Hat Evangelist" Chandler
Chetan_Tiwary_
Community Manager
Community Manager
  • 84 Views

sure @Trevor take your time !

0 Kudos
Join the discussion
You must log in to join this conversation.