Domain 5Local StorageCORE

Configure local storage

MBR and GPT disk partitioning with fdisk and gdisk, LVM architecture (PVs, VGs, LVs), creating volume groups, and dynamically extending logical volumes.

Domain: Domain 5: Configure local storage•Updated: 2026-08-29
#LVM#Partitions#fdisk#gdisk#Physical Volumes#Volume Groups#Logical Volumes

Chapter 05: Storage Volumes - Command Reference

1. Disk & Partition Management

1.1 Listing Block Devices

Command Description Example
lsblk Lists all block devices in a tree view, showing size, type, and mount points lsblk
lsblk -f Lists block devices with filesystem information (type, UUID, label) lsblk -f
blkid Displays block device attributes including UUID, label, and filesystem type blkid
blkid /dev/sdb1 Shows attributes for a specific device blkid /dev/sdb1
cat /proc/partitions Shows in-memory partitioning information from the kernel cat /proc/partitions

1.2 MBR Partitioning (fdisk)

Command Description Example
fdisk /dev/sdb Opens fdisk interactive partitioning tool for MBR/GPT disks fdisk /dev/sdb
fdisk -l /dev/sdb Lists partition table of a disk without entering interactive mode fdisk -l /dev/sdb
fdisk -l Lists partition tables of all detected disks fdisk -l

Interactive fdisk subcommands (entered after running fdisk /dev/sdX):

Subcommand Description Example
m Display help menu (inside fdisk) m
n Create a new partition (inside fdisk) n → p (primary) / e (extended)
p Print the current partition table (inside fdisk) p
d Delete a partition (inside fdisk) d → partition number
t Change partition type (inside fdisk) t → 8e (LVM) / 82 (swap) / 83 (Linux)
l List all available partition types (inside fdisk) l
w Write changes to disk and exit (inside fdisk) w
q Quit without saving changes (inside fdisk) q
g Convert MBR to GPT partition table (inside fdisk) g
o Create a new empty MBR partition table (inside fdisk) o

1.3 GPT Partitioning (gdisk)

Command Description Example
gdisk /dev/sdc Opens gdisk interactive partitioning tool for GPT disks gdisk /dev/sdc
gdisk -l /dev/sdc Lists GPT partition table without entering interactive mode gdisk -l /dev/sdc

Interactive gdisk subcommands (entered after running gdisk /dev/sdX):

Subcommand Description Example
n Create a new GPT partition (inside gdisk) n → partition number → start → end → type (e.g., 8e00 for LVM)
p Print the current partition table (inside gdisk) p
d Delete a partition (inside gdisk) d → partition number
t Change partition type (inside gdisk) t → partition number → 8e00 (LVM) / 8200 (swap)
w Write changes to disk and exit (inside gdisk) w
q Quit without saving changes (inside gdisk) q

1.4 Parted Partitioning

Command Description Example
parted /dev/sdc Opens parted interactive partitioning tool parted /dev/sdc
parted /dev/sdc mklabel gpt Creates a GPT partition table on a disk (non-interactive) parted /dev/sdc mklabel gpt
parted /dev/sdc mklabel msdos Creates an MBR (DOS) partition table on a disk parted /dev/sdc mklabel msdos
parted /dev/sdc mkpart pri 1 200m Creates a partition named “pri” from 1MB to 200MB parted /dev/sdc mkpart pri 1 200m
parted /dev/sdc print Prints the partition table parted /dev/sdc print
parted /dev/sdc rm 1 Removes partition number 1 parted /dev/sdc rm 1

Interactive parted subcommands:

Subcommand Description Example
mklabel gpt Create GPT partition table (inside parted) mklabel gpt
mklabel msdos Create MBR partition table (inside parted) mklabel msdos
mkpart Create a new partition (inside parted) mkpart → name → fs_type → start → end
print Print partition table (inside parted) print
rm Remove a partition (inside parted) rm → partition number
quit Quit parted (inside parted) quit

1.5 Partition Table Refresh

Command Description Example
partprobe Manually re-reads the partition table from the kernel partprobe

2. File System Creation & Management

2.1 Creating File Systems (mkfs)

Command Description Example
mkfs.xfs /dev/sdb1 Formats a partition with the XFS file system (RHEL 9 default) mkfs.xfs /dev/sdb1
mkfs.ext4 /dev/sdb1 Formats a partition with the Ext4 file system mkfs.ext4 /dev/sdb1
mkfs.vfat /dev/sdb1 Formats a partition with the VFAT (FAT32) file system mkfs.vfat /dev/sdb1
mkfs -t ext4 /dev/sdb1 Formats a partition specifying the filesystem type with -t mkfs -t ext4 /dev/sdb1
mkfs /dev/sdb1 Formats with default Ext2 (not recommended) mkfs /dev/sdb1
mkfs.xfs -L mylabel /dev/sdb1 Creates XFS filesystem with a label mkfs.xfs -L mylabel /dev/sdb1
mkfs.ext4 -L mylabel /dev/sdb1 Creates Ext4 filesystem with a label mkfs.ext4 -L mylabel /dev/sdb1

2.2 Managing Ext4 File System Properties

Command Description Example
tune2fs -l /dev/sdb1 Lists all Ext4 file system properties and features tune2fs -l /dev/sdb1
tune2fs -o acl,user_xattr /dev/sdb1 Sets default mount options (ACL and extended attributes) tune2fs -o acl,user_xattr /dev/sdb1
tune2fs -o ^acl,user_xattr /dev/sdb1 Removes default mount options tune2fs -o ^acl,user_xattr /dev/sdb1
tune2fs -O has_journal /dev/sdb1 Enables a file system feature tune2fs -O has_journal /dev/sdb1
tune2fs -O ^has_journal /dev/sdb1 Disables a file system feature tune2fs -O ^has_journal /dev/sdb1
tune2fs -L mylabel /dev/sdb1 Sets a label on an Ext file system tune2fs -L mylabel /dev/sdb1
e2label /dev/sdb1 Shows the current label of an Ext file system e2label /dev/sdb1
e2label /dev/sdb1 mylabel Sets a label on an Ext file system e2label /dev/sdb1 mylabel

2.3 Managing XFS File System Properties

Command Description Example
xfs_admin -L mylabel /dev/sdb1 Sets a label on an XFS file system xfs_admin -L mylabel /dev/sdb1
xfs_admin -l /dev/sdb1 Shows the current label of an XFS file system xfs_admin -l /dev/sdb1

2.4 File System Resizing

Command Description Example
xfs_growfs /mnt Grows an XFS file system (online, mounted) xfs_growfs /mnt
resize2fs /dev/sdb1 Resizes an Ext4 file system to fill the partition resize2fs /dev/sdb1
resize2fs /dev/sdb1 500M Resizes an Ext4 file system to a specific size (must be unmounted for shrinking) resize2fs /dev/sdb1 500M

3. Mounting & Unmounting File Systems

3.1 Manual Mounting

Command Description Example
mount /dev/sdb1 /mnt Mounts a file system on a directory mount /dev/sdb1 /mnt
mount -t xfs /dev/sdb1 /mnt Mounts specifying the file system type mount -t xfs /dev/sdb1 /mnt
mount UUID="5d34b37c-..." /mnt Mounts a file system by its UUID mount UUID="5d34b37c-5d32-4790-8364-d22a8b8f88db" /mnt
mount LABEL=mylabel /mnt Mounts a file system by its label mount LABEL=mylabel /mnt
mount -a Mounts all file systems listed in /etc/fstab that are not already mounted mount -a
mount Lists all currently mounted file systems mount
mount | grep exercise Filters mounted file systems mount | grep exercise

3.2 Unmounting

Command Description Example
umount /dev/sdb1 Unmounts a file system by device name umount /dev/sdb1
umount /mnt Unmounts a file system by mount point umount /mnt

3.3 Mount Verification & Inspection

Command Description Example
df -h Shows disk space usage in human-readable format df -h
df -T Shows disk space usage with file system type df -T
findmnt Shows mounted file systems in a tree view findmnt
findmnt --verify Verifies /etc/fstab syntax and alerts on errors findmnt --verify
findmnt /mnt Shows information about a specific mount point findmnt /mnt

3.4 /etc/fstab Configuration

Command Description Example
cat /etc/fstab Displays the contents of the fstab file cat /etc/fstab
vim /etc/fstab Edits the fstab file to add persistent mount entries vim /etc/fstab

fstab entry format:

UUID=xxx    /mounts/data    xfs    defaults    0 0
/dev/sdb6   none            swap   defaults    0 0

3.5 Systemd Mount Units

Command Description Example
systemctl enable --now exercise.mount Enables and starts a systemd mount unit systemctl enable --now exercise.mount
systemctl status exercise.mount Shows the status of a systemd mount unit systemctl status exercise.mount
cat /run/systemd/generator/repo.mount Views auto-generated systemd mount file from fstab cat /run/systemd/generator/repo.mount

4. Swap Management

4.1 Swap Partition/File Creation

Command Description Example
mkswap /dev/sdb6 Formats a partition as swap space mkswap /dev/sdb6
mkswap /swapfile Formats a file as swap space mkswap /swapfile
dd if=/dev/zero of=/swapfile bs=1M count=100 Creates a 100 MiB swap file filled with zeros dd if=/dev/zero of=/swapfile bs=1M count=100

4.2 Swap Activation & Deactivation

Command Description Example
swapon /dev/sdb6 Activates a swap partition swapon /dev/sdb6
swapon /swapfile Activates a swap file swapon /swapfile
swapon --show Shows currently active swap devices swapon --show
swapoff /dev/sdb6 Deactivates a swap partition swapoff /dev/sdb6

4.3 Swap Information

Command Description Example
free -m Shows total, used, and free memory and swap in MB free -m
free -h Shows memory and swap in human-readable format free -h

5. Logical Volume Manager (LVM)

5.1 Physical Volume (PV) Management

Command Description Example
pvcreate /dev/sdd1 Initializes a disk or partition as an LVM physical volume pvcreate /dev/sdd1
pvcreate /dev/sdd1 /dev/sde1 Initializes multiple devices as physical volumes pvcreate /dev/sdd1 /dev/sde1
pvs Shows a summary of all physical volumes pvs
pvdisplay Shows detailed information about all physical volumes pvdisplay
pvdisplay /dev/sdd1 Shows detailed information about a specific PV pvdisplay /dev/sdd1
pvremove /dev/sdd1 Removes LVM metadata from a physical volume pvremove /dev/sdd1
pvmove /dev/sdd4 Moves used extents from a PV to other PVs in the VG pvmove /dev/sdd4
pvmove -v /dev/sdd4 /dev/sdd3 Moves extents from one PV to a specific target PV (verbose) pvmove -v /dev/sdd4 /dev/sdd3

5.2 Volume Group (VG) Management

Command Description Example
vgcreate vgdata /dev/sdd1 Creates a volume group from one or more PVs vgcreate vgdata /dev/sdd1
vgcreate -s 16 vgdata /dev/sdd1 Creates a VG with a custom physical extent size (16 MiB) vgcreate -s 16 vgdata /dev/sdd1
vgcreate -s 64 vg20 /dev/sdd Creates a VG with 64 MiB PE size vgcreate -s 64 vg20 /dev/sdd
vgs Shows a summary of all volume groups vgs
vgdisplay Shows detailed information about all volume groups vgdisplay
vgdisplay vgdata Shows detailed information about a specific VG vgdisplay vgdata
vgdisplay -v vgdata Shows verbose details including PV and LV info vgdisplay -v vgdata
vgextend vgdata /dev/sdd2 Adds a PV to an existing volume group vgextend vgdata /dev/sdd2
vgextend vg20 /dev/sdd1 /dev/sdc Adds multiple PVs to a volume group vgextend vg20 /dev/sdd1 /dev/sdc
vgreduce vgdata /dev/sdd4 Removes a PV from a volume group (after pvmove) vgreduce vgdata /dev/sdd4
vgremove vgdata Removes a volume group (must have no LVs or use -f) vgremove vgdata
vgremove -f vg20 Forcefully removes a VG along with its LVs vgremove -f vg20

5.3 Logical Volume (LV) Management

Command Description Example
lvcreate -n lvdata -L 5G vgdata Creates a 5 GiB logical volume named lvdata lvcreate -n lvdata -L 5G vgdata
lvcreate -n lvdata -l 100 vgdata Creates an LV with 100 logical extents lvcreate -n lvdata -l 100 vgdata
lvcreate -n lvdata -l 50%FREE vgdata Creates an LV using 50% of free VG space lvcreate -n lvdata -l 50%FREE vgdata
lvcreate -L 1G -n lvdemo vgdemo Creates a 1 GiB LV named lvdemo lvcreate -L 1G -n lvdemo vgdemo
lvcreate -l 100 -n webvol vg20 Creates an LV with 100 extents named webvol lvcreate -l 100 -n webvol vg20
lvs Shows a summary of all logical volumes lvs
lvdisplay Shows detailed information about all LVs lvdisplay
lvdisplay /dev/vgdata/lvdata Shows detailed info about a specific LV lvdisplay /dev/vgdata/lvdata
lvextend -r -L +1G /dev/vgdata/lvdata Extends an LV by 1 GiB and resizes the filesystem (-r) lvextend -r -L +1G /dev/vgdata/lvdata
lvextend -r -l +50%FREE /dev/vgdata/lvdata Extends an LV by 50% of free VG space and resizes FS lvextend -r -l +50%FREE /dev/vgdata/lvdata
lvextend -L +500M /dev/vgdemo/lvdemo /dev/sdd4 Extends LV using free extents from a specific PV lvextend -L +500M /dev/vgdemo/lvdemo /dev/sdd4
lvresize -r -L +1G /dev/vgdata/lvdata Resizes an LV by adding 1 GiB and resizes the FS lvresize -r -L +1G /dev/vgdata/lvdata
lvresize -r -l 75%VG /dev/vgdata/lvdata Resizes LV to 75% of total VG size (may shrink!) lvresize -r -l 75%VG /dev/vgdata/lvdata
lvresize -r -l +75%VG /dev/vgdata/lvdata Adds 75% of total VG size to the LV lvresize -r -l +75%VG /dev/vgdata/lvdata
lvresize -r -l +75%FREE /dev/vgdata/lvdata Adds 75% of free VG space to the LV lvresize -r -l +75%FREE /dev/vgdata/lvdata
lvreduce -L 80M /dev/vgdata/lvol0 Reduces an LV to 80 MiB (Ext4 only; unmount first!) lvreduce -L 80M /dev/vgdata/lvol0
lvremove /dev/vgdata/lvdata Removes a logical volume lvremove /dev/vgdata/lvdata
lvremove /dev/vg20/webvol Removes a specific LV from a VG lvremove /dev/vg20/webvol
lvrename vgdata lvdata lvnewname Renames a logical volume lvrename vgdata lvdata lvnewname

6. Stratis Storage Management

6.1 Stratis Installation & Service

Command Description Example
dnf install stratisd stratis-cli Installs the Stratis daemon and CLI tools dnf install stratisd stratis-cli
systemctl enable --now stratisd Enables and starts the Stratis daemon service systemctl enable --now stratisd
systemctl status stratisd Checks the status of the Stratis daemon systemctl status stratisd

6.2 Stratis Pool Management

Command Description Example
stratis pool create mypool /dev/sde Creates a Stratis pool from one or more block devices stratis pool create mypool /dev/sde
stratis pool list Lists all Stratis pools stratis pool list
stratis pool add-data mypool /dev/sdf Adds a block device to an existing Stratis pool stratis pool add-data mypool /dev/sdf
stratis pool add-data pool1 /dev/sdh Adds /dev/sdh to pool named pool1 stratis pool add-data pool1 /dev/sdh
stratis pool rename mypool newpool Renames a Stratis pool stratis pool rename mypool newpool
stratis pool destroy mypool Destroys a Stratis pool and all its file systems stratis pool destroy mypool
stratis blockdev list Lists all block devices used by Stratis pools stratis blockdev list

6.3 Stratis File System Management

Command Description Example
stratis fs create mypool stratis1 Creates a Stratis file system in a pool stratis fs create mypool stratis1
stratis fs list Lists all Stratis file systems stratis fs list
stratis fs list mypool Lists file systems in a specific pool stratis fs list mypool
stratis filesystem snapshot mypool stratis1 stratis1-snap Creates a snapshot of a Stratis file system stratis filesystem snapshot mypool stratis1 stratis1-snap
stratis filesystem list Shows statistics about current file system usage stratis filesystem list
stratis fs rename mypool stratis1 newname Renames a Stratis file system stratis fs rename mypool stratis1 newname
stratis fs destroy mypool stratis1-snap Destroys a Stratis file system or snapshot stratis fs destroy mypool stratis1-snap

6.4 Mounting Stratis File Systems

Command Description Example
mount /dev/stratis/mypool/stratis1 /stratis1 Mounts a Stratis file system manually mount /dev/stratis/mypool/stratis1 /stratis1
mount /dev/stratis/mypool/stratis1-snap /mnt Mounts a Stratis snapshot read-only mount /dev/stratis/mypool/stratis1-snap /mnt

fstab entry for Stratis (must use UUID):

UUID=xxx    /stratis1    xfs    defaults,x-systemd.requires=stratisd.service    0 0

7. VDO (Virtual Data Optimizer)

7.1 VDO Installation & Service

Command Description Example
dnf install vdo kmod-kvdo Installs the VDO software packages dnf install vdo kmod-kvdo
systemctl enable --now vdo Enables and starts the VDO service systemctl enable --now vdo
systemctl status vdo Checks the operational status of the VDO service systemctl status vdo

7.2 VDO Volume Management

Command Description Example
vdo create --name vdo-vol1 --device /dev/sdf --vdoLogicalSize 16GB --vdoSlabSize 128MB Creates a VDO volume with specified name, device, logical size, and slab size vdo create --name vdo-vol1 --device /dev/sdf --vdoLogicalSize 16GB --vdoSlabSize 128MB
vdo Lists all VDO volumes vdo
vdo status --name vdo-vol1 Shows detailed status and configuration for a VDO volume vdo status --name vdo-vol1
vdo remove --name vdo-vol1 Removes a VDO volume by name vdo remove --name vdo-vol1
vdostats Shows usage statistics for all VDO volumes vdostats
vdostats --human-readable Shows VDO statistics in human-readable format vdostats --human-readable
vdostats --verbose Shows detailed VDO statistics including compression and dedup ratios vdostats --verbose

Command Description Example
dnf install stratisd stratis-cli Installs Stratis packages dnf install stratisd stratis-cli
dnf install vdo kmod-kvdo Installs VDO packages dnf install vdo kmod-kvdo

Command Description Example
systemctl enable --now stratisd Enables and starts the Stratis daemon systemctl enable --now stratisd
systemctl enable --now vdo Enables and starts the VDO service systemctl enable --now vdo
systemctl status stratisd Checks the Stratis daemon status systemctl status stratisd
systemctl status vdo Checks the VDO service status systemctl status vdo
systemctl daemon-reload Reloads systemd configuration after editing unit files systemctl daemon-reload

10. General Utility Commands

Command Description Example
mkdir /mounts/data Creates a mount point directory mkdir /mounts/data
mkdir -p /mounts/data Creates a mount point directory (including parents) mkdir -p /mounts/data
dd if=/dev/zero of=/swapfile bs=1M count=100 Creates a file of specified size filled with zeros dd if=/dev/zero of=/swapfile bs=1M count=100
dd if=/dev/zero of=/mnt/bigfile bs=1M count=1100 Creates a large test file (used to verify multi-PV data) dd if=/dev/zero of=/mnt/bigfile bs=1M count=1100
cat /proc/partitions Displays kernel-tracked partition information cat /proc/partitions
reboot Reboots the system (to apply partition table changes if needed) reboot

Quick Reference: LVM Workflow

  1. Create partitions → fdisk /dev/sdd (set type to 8e for LVM)
  2. Initialize PV → pvcreate /dev/sdd1
  3. Create VG → vgcreate vgdata /dev/sdd1
  4. Create LV → lvcreate -n lvdata -l 50%FREE vgdata
  5. Format LV → mkfs.xfs /dev/vgdata/lvdata
  6. Mount LV → mount /dev/vgdata/lvdata /files
  7. Persist mount → Add entry to /etc/fstab
  8. Verify → lsblk, df -h, mount

Quick Reference: Stratis Workflow

  1. Install → dnf install stratisd stratis-cli
  2. Start service → systemctl enable --now stratisd
  3. Create pool → stratis pool create mypool /dev/sde
  4. Create FS → stratis fs create mypool stratis1
  5. Find UUID → stratis fs list
  6. Mount → Add UUID entry to /etc/fstab with x-systemd.requires=stratisd.service
  7. Verify → mount -a, stratis fs list

Quick Reference: VDO Workflow

  1. Install → dnf install vdo kmod-kvdo
  2. Start service → systemctl enable --now vdo
  3. Create volume → vdo create --name vdo1 --device /dev/sdf --vdoLogicalSize 16GB
  4. Verify → vdo, vdostats --human-readable
  5. Format & mount → mkfs.xfs /dev/mapper/vdo1, then mount normally