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:
Create a new logical volume named lv_data01
that is 2 GiB in size.
Place it in a new volume group named vg_database
.
Format the logical volume with the xfs file system.
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!
My first step would be to use lsblk
to identify the device name of the new disk...
# 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
Red Hat
Learning Community
A collaborative learning environment, enabling open source skill development.