Last updated
Last updated
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.
lsblk -> to select a free disk to make 2 partition with lvm type.
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
lsblk again to verify the creation of /dev/sdc{1,2}
pvcreate /dev/sdc1 /dev/sdc2
pvdisplay
vgcreate myvg /dev/sdc1 /dev/sdc2 -s 16 => if you want to set the PE.
lvcreate -L 800M -n mylv myvg
mkfs.xfs /dev/mapper/myvg-mylv
mkdir /mnt/lvmp
blkid | grep myvg -> to get the UUID.
echo " UUID="..." /mnt/lvmp xfs defaults 0 0" >> /etfc/fstab
partx and then lsblk to verify.
If you wish to resize your lvm or your volume group do the following steps :
To extend the volume group by adding new physical voume : 1-1. pvcreate /dev/sdc3 1-2. vgextend myvg /dev/sdc3
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.
To reduce the logical volume : 3-1. lvreduce -r -L -500M /dev/myvg/mylv
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 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.
rpm -qa | grep stratis -> to verify if its installed
yum install stratisd stratis-cli -y -> to install
systemctl enable --now stratis -> to enable the stratisd service
lsblk -> to select two block device to use, assuming we selected (sdd,sde)
use wipefs -a /dev/<device> if it contains any partition. or you can use : shred -vfz -n 10 /dev/<device>
stratis pool create mystratis_pool /dev/sdd /dev/sde
stratis pool list -> to verify the stratis pool is created.
stratis blockdev list mystratis_pool, then do lsblk to verify
stratis fs create mystratis_pool mystratis_filesystem
stratis fs list mystratis_pool
mkdir /data -> to create mont point
blkid | grep stratis_pool and copy the UUID
echo " UUID=".." /data xfs defaults,x-systemd.requires=stratisd.service 0 0" >> /etc/fstab
mount -a; mount -> to verify
lsblk to verify
stratis fs snapshot mystratispool mystratis_fs mystratis_snapshot
mkdir /snapshot ; mount /mystratis_pool/mystratis_fs/mystratis_snapshot /snapshot
stratis pool add-data mystratis_pool /dev/sdf -> if you want to extend the stratis pool.
stratis fs destroy mystratis_pool mystratis_fs, requires umounting.
stratis pool init-cache <poolname> /dev/<devicename> => to add cache to pool, cache will collect the most used data for you.
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.
You can also mount the vdo using systemd.mounts. Find an example within /usr/share/doc/vdo/examples.
if you had an error while creating <vdo : ERROR - Found an existing signature on /dev/sdb at offset 512> -> this is safety check, telling you the volume seems to be already initialized, as possibly used. => to get rid of this error, simply insert this command line syntax : wipefs --all --force /dev/sdb
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.
Learn how to manage advanced storage such as lvm, stratis and vdo..