Wednesday, March 22, 2023

Learning Linux - Create and Configure File Systems(Part-5)

 In Part 4 of the Learning Linux blog series, we learned how to configure local storage on Linux systems. 

In part 5, We will learn and try to construct daily usage commands to create and configure Linux file systems.

- Create and configure file systems

    mkfs.xfs -L "BackupVolume" /dev/sdb (format disk with xfs file syetem with label)

    mkfs.xfs -i size 500 -L "BackupVolume" /dev/sdb (format disk with xfs file syetem with label and 500 Bypes inode size)

    mkfs.ext4 -L "BackupVolume" -N 500000 /dev/sdb2 (Format disk with ext4 fs with Label and 500K inode numbers)

    xfs_admin (Manage and Monitor xfs filesystem), tune2fs(Manage ext4 filesystem)


- Create, mount, unmount, and use vfat file systems

    vfat (virtual file allocation table)

        sudo fdisk /dev/vdb     t for type; b for w95 FAT32

        sudo mkfs.vfat /dev/vdb1 (Up to 2GB in size)

        sudo mkfs.vfat -F 32 /dev/vdb1  (2 GB and larger)


- Configure systems to mount file systems at or during boot

    sudo mkdir /mybackupvol (create the folder where you want to mount your new volume)

    sudo vi /etc/fstab -----> /dev/vdb1   /mybackupvol       xfs    defaults 0 0 (1st- Device path, 2- mount point, 3- filesystem, 4-(defaults mount option, It can be customize), 5- 0 =fs dump disabled, 6- 1 = root fs, 2 = other fs apart from root), 

    man fstab(for more help)

    sudo systemctl reboot

    sudo blkid  /dev/sda1 (To check the disk sda1's UUID value)


- Configure disk compression(RHEL8 and earlier python based)

    Enabling vdo(virtual data optimizer)

        sudo yum install vdo -y, sudo systemctl start vdo.service

    Using vdo with storage devices

        sudo vdo --create --name=vdo_storage --device=/dev/vdb --vdoLogicalSize=10G (Create vdo storage from physical disk)

        sudo vdostats --human-readable (Check the vdo devices status)

        sudo mkfs.xfs -K /dev/mapper/vdo_storage (Format the vdo device using xfs file system)

    Mounting vdo devices

        Fstab file example: /dev/mapper/vdo_storage /mnt/myvdo xfs _netdev,x-systemd,device-timout=0,x-systemd.requires=vdo.service 0 0 

    RHEL9: lvmvdo: vdo tool has been merged into lvm

        1. Create physical volume: sudo pvcreate /dev/vdb 

2. Create volume group: sudo vgcreate vdo_volume /dev/vdb 

3. Creating lv using vdo enabled: sudo lvcreate --type vdo -n vdo_storage -L 100%FREE -V 10G vdo_volume/vdo_pool1 

4. Create xfs filesystem: sudo mkfs.xfs -L /dev/vdo_volume/vdo_storage

    Create ext4 filesystem: sudo mkfs.ext4 -E nodiscard /dev/vdo_volume/vdo_storage

- Manage layered storage

    Stratis: It's a local storage management tool for Linux 

        Enabling Stratis: sudo yum install stratisd stratis-cli

Creating Stratis Storage Pool: sudo stratis pool create my-pool /dev/vdc  /dev/vdd, sudo stratis pool list (list pools), sudo stratis blockdev(list block devices)

Creating a stratis filesystem: sudo stratis fs create my-pool myfs1, sudo stratis fs(list fs), 

Mounting Stratis filesystem: FSTAB Example: /dev/stratis/my-pool/myfs1 /mnt/mystratis xfs x-systemd-requires=stratisd.service 0 0 

Adding storage device to the Stratis  pool: sudo stratis pool add-date my-pool /dev/vde 

File system snapshot with stratis: sudo stratis fs snapshot my-pool myfs1 myfs1-snapshot 

Mount snapshot:  sudo stratis fs rename developers devfs devfs-bad,  sudo stratis fs rename developers devfs-snapshot devfs, sudo umount /mnt/devstorage, sudo mount /mnt/devstorage

    Taking backup of filesystem:

        sudo stratis fs snapshot my-pool myfs1 myfs1-snapshot (Creating snapshot of stratis fs)

sudo stratis fs rename my-pool myfs1 myfs1-old (Rename current fs)

sudo stratis fs rename my-pool myfs1-snapshot myfs1 (Next, Rename the snapshot fs to previous fs name)

        sudo umount and mount again


-> echo "Thank you :)"