Managing Advanced Storage
Nov 13, 2025
Advanced Storage Solutions
Creating a Logical Volume
- Create a partition of type
lvm - Create physical volume with
pvcreate /dev/partition - Create volume group with
vgcreate {vgroup} /dev/partition- Use the
-soption to define a non standard extent size
- Use the
- Create logical volume with
lvcreate -n {lv} -L 1G {vgroup}- Use
-linstead of-Lto specify the number of extents
- Use
- Create a filesystem
- Use
vgdisplayto get UUID and mount in fstab- Alternatively, use
/dev/lvgname/lvname, as these don’t change like device names
- Alternatively, use
Device Mapper and LVM Device Names
Resizing LVM Logical Volumes
- Use
vgsto verify that the volume group has unused disk space - Use
vgextendto add one or more PVs to the VG - Use
lvextend -r -L +1Gto grow the logical volume, including the filesystem it’s hosting (-r)resize2fsis a resize utility for ext filesystemsxfs_growfscan be used to grow an XFS filesystemlvextend -r -l +50%FREEwill use half the available free extents
- If the volume is mounted
df -hwill show the newly available space- Or
vgsorvgdisplay
- Or
Reducing a Volume Group
- Use
pvsto ensure that PFree > 0 - Use
pvmoveto moved extents from the volume being removed to the remaining volumes(s) - Use
vgreduceto complete the removal
Exercise
- Use fdisk to create 2 partitions, p1 and p2 for reference, with a size of 1G
each and set the type to
lvm - Create a volume group, demo, including only the first partition, p1
- Add a logical volume, vol1, of 500M to the group
- Add the second partition, p2, to the volume group
- Extend the logical volume, vol1, using extents from the second partition
- Put an ext4 filesystem on the logical volume
- Mount vol1 to /mnt and use
df -hto view - Use
dd if=/dev/zero of=/mnt/bigfile bs=1M count=1100to ensure data is on both physical volumes - Move all used extents from partition p2 to p1
- Print information for the physical volumes. Ensure that p2 is now unused.
- Remove p2 from the volume group
Solution
fdiskvgcreate vgdemo /dev/p1lvcreate -n vol1 -L 500Mvgextend vgdemo /dev/p2lvextend -n /dev/vgdemo/vol1 -L 250M /dev/p2mkfs.ext4 /dev/vgdemo/vol1mount /dev/vgdemo/vol1 /mntdd if=/dev/zero of=/mnt/bigfile bs=1M count=550pvmove -v /dev/p2 /dev/p1-v is for verbose, not required
pvsvgreduce vgdemo /dev/p1
Stratis Pools
dnf install stratisd stratis-cli
systemctl enable --now stratisd
stratis pool create mypool /dev/partition1
stratis pool list
stratis pool add-data mypool /dev/partition2
stratis blockdev list
stratis fs create mypool myfs
stratis fs list
mkdir /myfs
lsblk --output=UUID /dev/stratis/mypool/myfs >> /etc/fstab
Modify /etc/fstab
UUID=... /myfs xfs defaults,x-systemd.requires=stratisd.service 0 0"
Stratis Snapshots
dd if=/dev/zero of=/myfs/bigfile bs=1M count=2000
stratis pool list
stratis fs list
stratis fs snapshot mypool myfs myfs-snap
stratis fs list
rm /myfs/bigfile
mkdir /myfs-snap
mount /dev/stratis/mypool/myfs-snap /myfs-snap
ls -l /myfs-snap
umount /myfs-snap
stratis fs destroy mypool myfs-snap
Knowledge Check
- What is the minimal size of a stratis volume?
- What filesystem must a stratus volume have?
- Is a stratis snapshot a backup?
- What is contained in a stratis snapshot?
- If a volume group contains 1 physical volume of size 1G, is it possible to create a logical volume of size 1G in that group? Why or why not?
Answers
- 4G
- XFS
- No, a snapshot is a metadata copy that allows you to access the state of the snapshot at any time. It differs from a backup in that if the original volume is destroyed, the snapshot is also lost.
- Metadata
- No. One extent will be used for metadata in the logical volume. If it is specified that the logical volume should be 1G (255 extents), then the underlying physical volume needs at least 256 extents. So create a physical volume slightly larger than 1G, eg 1028M, for a logical volume of exactly 1G.
Lab Exercise: LVM
- Create a logical volume 1G in size with the name lvdata.
- Format lvdata with the XFS filesystem and mount it persistently on
/mounts/lvdata - Increase the size of lvdata by 100 extents
- Add another physical volume to the volume group that lvdata belongs and add a second 500M logical volume, lvfiles
- Put an ext4 filesystem on lvfiles and mount it persistently to
/mounts/lvfiles - Copy all files from /etc/ that have a name starting with b, c, or g to /mounts/files
- Create a snapshot of lvfiles and delete all files from
/mounts/lvfiles - Verify that you can still access these files from the snapshot
- Recover the lvfiles volume from its snapshot
Solution
- —
vgcreate vgroup /dev/sdb1 lvcreate vgroup -L 1G -n lvdata - —
mkfs.xfs /dev/vgroup/lvdata # get UUID and add to /etc/fstab - —
lvextend -r -l +100 -n vgroup/lvdata - —
lvextend vgroup /dev/sdb2 lvcreate vgroup -L 500M -n lvdata - —
mkfs.ext4 /dev/vgroup/lvfiles # get UUID and add to /etc/fstab - —
cp /etc/[bcg]* /mounts/lvfiles - —
lvcreate --snapshot -L 500M -n lvfiles-snap vgroup/lvfiles rm -rf /mounts/lvfiles/* - —
mount /dev/vgroup/lvfiles-snap /mnt ls -l /mnt - —
umount /mounts/lvfiles umount /mnt lvconvert --merge /dev/vgroup/lvfiles-snap mount -a ls -l /mounts/lvfiles
Lab Exercise: Stratis
To perform these tasks, attach a 20G disk to your lab virtual machine
- Create a 10G stratis pool with the attached disk, spool, containing 3 filesystems: files, programs, and stuff
- Mount these filesystems persistently on /mounts/files, /mounts/programs/, and /mounts/stuff
- Copy all files from /etc/ that have a name starting with b, c, or g to /mounts/files
- Create a snapshot of the files filesystem
- Delete all files from /mounts/files
- Verify that you can still access these files from the snapshot
- Clint Jordan