Managing Advanced Storage

Learn how to manage advanced storage such as lvm, stratis and vdo..

LVM :

Logical Volume Manager was introduced to add flexibility to the partition, as it allow us to dynamically grow a partition that in running out of disk. Let's learn how to make an lvm partition togerther. as the picture below shows, to create an lvm partition you'll need first physical volumes, grouped in a volume group, then divided into logical volumes.

  1. lsblk -> to select a free disk to make 2 partition with lvm type.

  2. fdisk /dev/sdc 2-1. n,primary,ENTER, ENTER, +1G, t,8e,p,w 2-2 n,primary,ENTER, ENTER, +1G, t,8e,p,w

  3. lsblk again to verify the creation of /dev/sdc{1,2}

  4. pvcreate /dev/sdc1 /dev/sdc2

  5. pvdisplay

  6. vgcreate myvg /dev/sdc1 /dev/sdc2 -s 16 => if you want to set the PE.

  7. lvcreate -L 800M -n mylv myvg

  8. mkfs.xfs /dev/mapper/myvg-mylv

  9. mkdir /mnt/lvmp

  10. blkid | grep myvg -> to get the UUID.

  11. echo " UUID="..." /mnt/lvmp xfs defaults 0 0" >> /etfc/fstab

  12. partx and then lsblk to verify.

If you wish to resize your lvm or your volume group do the following steps :

  1. To extend the volume group by adding new physical voume : 1-1. pvcreate /dev/sdc3 1-2. vgextend myvg /dev/sdc3

  2. To extend the logical volume : 2-1. lvextend -L +100M /dev/myvg/mylv 2-2. xfs_growfs /dev/myvg/mylv => xfs resize2fs /dev/myvg/mylv => ext. 2-3. lvresize -r -L +100M /dev/myvg/mylv.

  3. To reduce the logical volume : 3-1. lvreduce -r -L -500M /dev/myvg/mylv

  4. to create a snapshot : 4-1. lvcreate -s -L 150M -n mysnap /dev/myvg/mylv 4-2. mount it to use it. 4-3. to destroy the snapshot you'll have to umount it and then lvremove /dev/myvg/mysnap.

Stratis :

Stratis is the next generation local storage manager. it was introduced in RHEL8 and it uses xfs as the default file system. The amazing thing about stratis file system is auto extendable. If you understand how to use lvm, then you're good to start with stratis as both almost have the same technique.

For a better understanding, check the Stratis technology with the diagram below :

Moving forward now, lets learn how to use stratis.

  1. rpm -qa | grep stratis -> to verify if its installed

  2. yum install stratisd stratis-cli -y -> to install

  3. systemctl enable --now stratis -> to enable the stratisd service

  4. lsblk -> to select two block device to use, assuming we selected (sdd,sde)

  5. use wipefs -a /dev/<device> if it contains any partition. or you can use : shred -vfz -n 10 /dev/<device>

  6. stratis pool create mystratis_pool /dev/sdd /dev/sde

  7. stratis pool list -> to verify the stratis pool is created.

  8. stratis blockdev list mystratis_pool, then do lsblk to verify

  9. stratis fs create mystratis_pool mystratis_filesystem

  10. stratis fs list mystratis_pool

  11. mkdir /data -> to create mont point

  12. blkid | grep stratis_pool and copy the UUID

  13. echo " UUID=".." /data xfs defaults,x-systemd.requires=stratisd.service 0 0" >> /etc/fstab

  14. mount -a; mount -> to verify

  15. lsblk to verify

  16. stratis fs snapshot mystratispool mystratis_fs mystratis_snapshot

  17. mkdir /snapshot ; mount /mystratis_pool/mystratis_fs/mystratis_snapshot /snapshot

  18. stratis pool add-data mystratis_pool /dev/sdf -> if you want to extend the stratis pool.

  19. stratis fs destroy mystratis_pool mystratis_fs, requires umounting.

  20. stratis pool init-cache <poolname> /dev/<devicename> => to add cache to pool, cache will collect the most used data for you.

VDO :

Virtual Data Optimizer, Another advanced storage solution offered in rhel8. Focuses on storages the data in the most efficient way, with the concept of deduplicating and compressed storage tools. Mainly used in cloud and containerized environment, and provides a thin-provisioned. You can take a look at the diagram below for better understanding.

  • yum install vdo kmod-kvdo -> to install vdo service.

  • vdo create --name=vdo1 --device=/dev/sda --vdoLogicalSize=1T ->to create one.

  • mkfs.xfs -K /dev/mapper/vdo1 (-k = do not attempt to discard blocks).

  • udevadm settle -> to regesiter the new device in the kernel.

  • mkdir /vdo-data -> to create a mountpoint.

  • lsblk --output=UUID /dev/mapper/vdo1 -> to get the UUID.

  • vim /etc/fstab and insert this line. UUID="..." /vod-data xfs defaults,x-systemd.requires=vdo.service 0 0"

  • mount -a -> to verify mounting.

  • vdostats --hu.

circle-info

You can also mount the vdo using systemd.mounts. Find an example within /usr/share/doc/vdo/examples.

circle-exclamation

LUKS :

Linux Unified Key Setup, is a disk encryption specification created in 2004 by Clemens Fruhwirth in 2004. To setup a LUKS encrypted volume :

  • Create partition with parted.

  • crypetsetup luksFormat <devicename> -> to format the luks device.

  • crypetsetup luksOpen <devicename> <device_mapper_name>

  • mkfs.xfs <device_mapper_name> -> to format the device partition.

  • mkdir /encrypted

  • echo "/dev/mapper/<DEVICE> /encrypted xfs defaults 0 0" >> /etc/fstab.

  • crypetsetup luksAddKey <device_name> /home/secure.txt

  • echo "/encrypted /dev/<devicename> /home/secure.txt" >> /etc/cryptab. CRYPTTAB : crypttab describes encrypted block devices that are setup during system boot During boot, system will ask for password to mount /dev/mapper/myvol on /test1 directory. To setup automatic mount without password, add a key file for /dev/mapper/myvol. This has to be in /etc/crypttab as well. FORMAT : mount point partition name path to secretphrase.

Last updated