Skip to main content

LFCS: Storage (20%)

This section covers managing LVM,LVM, filesystems, remote storage, swap, automount, and monitoring storage performance.


Goals

Storage 20%

    Configure and manage LVM storage Manage and configure the virtual file system Create, manage, and troubleshoot filesystems Use remote filesystems and network block devices Configure and manage swap space Configure filesystem automounters Monitor storage performance

    1. Configure and Manage LVM Storage

    Learn

    • Logical Volume Manager (LVM) basics: PV,PV, VG,VG, LV.LV.
    • Create, extend, and reduce logical 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

    1. Create a new LVM on a spare disk.
    2. Extend the logical volume and verify the new size.

    2. Manage and Configure the Virtual Filesystem Management

    Learn

    • Mount/Mount and unmount filesystems.
    • PersistentConfigure persistent mounts inusing /etc/fstab.

    Commands

    # Mount filesystem
    sudo mount /dev/sdb1 /mnt
    
    # Unmount filesystem
    sudo umount /mnt
    
    # Add to /etc/fstab for persistent mounting
    /dev/sdb1 /mnt ext4 defaults 0 2
    

    Exercises

    1. Mount a new disk temporarily.
    2. Add it to /etc/fstab for persistent mounting.

    3. Create, Manage, and Troubleshoot Filesystems

    Learn

    • Create and repair filesystems (ext4, xfs, btrfs filesystems.btrfs).
    • Check and repairDiagnose filesystem errors.errors with fsck.

    Commands

    # Create filesystem
    sudo mkfs.ext4 /dev/sdb1
    sudo mkfs.xfs /dev/sdb2
    
    # Check filesystem integrity
    sudo fsck /dev/sdb1
    
    # Repair filesystem
    sudo fsck -y /dev/sdb1
    

    Exercises

    1. Format a partition as ext4.
    2. Simulate and repair a filesystem error and repair it.error.

    4. Use Remote Filesystems &and Network Block Devices

    Learn

    • Mount NFS,NFS, CIFS,CIFS, or iSCSI shares.
    • Manage remote storage connections.

    Commands

    # Mount NFS
    sudo mount -t nfs server:/share /mnt
    
    # Mount CIFS (SMB)
    sudo mount -t cifs //server/share /mnt -o username=user,password=pass
    
    # iSCSI discovery and login
    sudo iscsiadm -m discovery -t st -p 192.168.1.100
    sudo iscsiadm -m node -l
    

    Exercises

    1. Mount an NFS share.
    2. Connect to an iSCSI target.

    5. Configure and Manage Swap Space

    Learn

    • Add, remove, and monitor swap.swap space.

    Commands

    # Create swap file
    sudo fallocate -l 2G /swapfile
    sudo chmod 600 /swapfile
    sudo mkswap /swapfile
    sudo swapon /swapfile
    
    # PermanentMake swap permanent
    echo "/swapfile none swap sw 0 0" | sudo tee -a /etc/fstab
    
    # Monitor swap usage
    swapon -s
    free -h
    

    Exercises

    1. Create a swap file and activate it.
    2. Remove the swap file and update /etc/fstab.

    6. Configure Filesystem Automounters

    Learn

    • Configure autofs to mount filesystems onautomatically access.when accessed.

    Commands

    # Install autofs
    sudo apt install autofs
    
    # Configure mapauto.master
    sudo nano /etc/auto.master
    # Example entry:
    # /mnt /etc/auto.nfs
    
    # Restart autofs
    sudo systemctl restart autofs
    

    Exercises

    1. Configure automount for an NFS share.
    2. Test automatic mountingautomount by accessing the directory.

    7. Monitor Storage Performance

    Learn

    • Use tools to monitor disk I/O and performance.

    Commands

    # Display I/O statistics
    iostat -x 2 3
    
    # DiskShow disk usage
    df -h
    
    # Disk usage by directory
    du -sh /var/log/*
    
    # Monitor disk eventsactivity in real-time
    iotop -o
    

    Exercises

    1. Check disk I/O using iostat.
    2. Identify large directories consuming storage.storage space.

    🧪 Exam Tips

    • Understand LVM creation, resizing, and removal.removal.
    • Know how to mount local and remote filesystems permanently.permanently.
    • Be able to create and manage swap.
    Use autofs for automount configurations. Monitor storage performance and monitoridentify storageI/O performance.bottlenecks.