LFCS: Storage (20%)
This section covers managing LVM, filesystems, remote storage, swap, automount, and monitoring storage performance.
1. LVM Storage
Learn
- Logical Volume Manager (LVM) basics: PV, VG, LV.
- Create, extend, reduce volumes.
Commands
# Create physical volume
sudo pvcreate /dev/sdb
# Create volume group
sudo vgcreate vg01 /dev/sdb
# Create logical volume
sudo lvcreate -L 10G -n lv01 vg01
# Extend logical volume
sudo lvextend -L +5G /dev/vg01/lv01
sudo resize2fs /dev/vg01/lv01
# Reduce logical volume (careful)
sudo umount /mnt
sudo e2fsck -f /dev/vg01/lv01
sudo resize2fs /dev/vg01/lv01 5G
sudo lvreduce -L 5G /dev/vg01/lv01
Exercises
- Create a new LVM on a spare disk.
- Extend the logical volume and verify size.
2. Virtual Filesystem Management
Learn
- Mount/unmount filesystems.
- Persistent mounts in
/etc/fstab.
Commands
# Mount filesystem
sudo mount /dev/sdb1 /mnt
# Unmount filesystem
sudo umount /mnt
# Add to /etc/fstab
/dev/sdb1 /mnt ext4 defaults 0 2
Exercises
- Mount a new disk temporarily.
- Add it to
/etc/fstabfor persistent mounting.
3. Create, Manage, Troubleshoot Filesystems
Learn
- Create ext4, xfs, btrfs filesystems.
- Check and repair filesystem errors.
Commands
# Create filesystem
sudo mkfs.ext4 /dev/sdb1
sudo mkfs.xfs /dev/sdb2
# Check filesystem
sudo fsck /dev/sdb1
# Repair filesystem
sudo fsck -y /dev/sdb1
Exercises
- Format a partition as ext4.
- Simulate a filesystem error and repair it.
4. Remote Filesystems & Network Block Devices
Learn
- Mount NFS, CIFS, or iSCSI shares.
- Manage remote storage connections.
Commands
# Mount NFS
sudo mount -t nfs server:/share /mnt
# Mount CIFS
sudo mount -t cifs //server/share /mnt -o username=user,password=pass
# iSCSI discovery
sudo iscsiadm -m discovery -t st -p 192.168.1.100
sudo iscsiadm -m node -l
Exercises
5. Swap Space
Learn
- Add, remove, and monitor swap.
Commands
# Create swap file
sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
# Permanent swap
echo "/swapfile none swap sw 0 0" | sudo tee -a /etc/fstab
# Monitor swap
swapon -s
free -h
Exercises
- Create a swap file and activate it.
- Remove swap file and update
/etc/fstab.
6. Filesystem Automounters
Learn
- Configure autofs to mount filesystems on access.
Commands
# Install autofs
sudo apt install autofs
# Configure map
sudo nano /etc/auto.master
# /mnt /etc/auto.nfs
sudo systemctl restart autofs
Exercises
- Configure automount for an NFS share.
- Test automatic mounting by accessing the directory.
7. Monitor Storage Performance
Learn
- Use tools to monitor disk I/O and performance.
Commands
# I/O statistics
iostat -x 2 3
# Disk usage
df -h
# Disk usage by directory
du -sh /var/log/*
# Monitor disk events
iotop -o
Exercises
- Check disk I/O using
iostat. - Identify large directories consuming storage.
Exam Tips
- Understand LVM creation, resizing, and removal.
- Know how to mount local and remote filesystems permanently.
- Be able to manage swap and monitor storage performance.