Manage LVM

TIPS & TRICKS

To search the contents of the man pages

# man -k searchterm 
# man -K searchterm

Configure LVM

To keep in mind:

  • Création de partition LVM
  • Création de PV (pour chaque partition)
  • Création de VG (Englobant 1 ou plusieurs PV)
  • Création de LV (Faisant partie d’un VG)
  • Formatage du LV dans un système de fichier
  • Création de répertoires pour monter les LV (1 LV = 1 Répertoire)
  • Rendre persistant dans /etc/fstab

Les PV:
Un simple fdisk pour partitionner, ajouter le type (t) lvm:

# fdisk /dev/sda

Les VG:
Groupement de PV:

# vgcreate VG_01 /dev/sda1 /dev/sda2 /dev/sdb1 /dev/sdb2
# vgcreate VG_02 --size 10G /dev/sdb3 /dev/sdc1
# vgextend VG_01 /dev/sdd6 /dev/sdd7
# vgreduce VG_01 /dev/sdd7
# vgdisplay

Les LV:
Contenus dans les VG:

# lvcreate --name LV_01 -L 10G VG_01
# lvcreate --name LV_02 -l 10 VG_01 // 10 extents
# lvextend /dev/VG_01/LV_02 -rL 10G // L'option -r est très importante
# lvextend /dev/VG_01/LV_02 -rl +10 // car elle permet également de
# lvreduce /dev/VG_01/LV_01 -rL -5G // resize le système de fichier
# lvreduce /dev/VG_01/LV_01 -rl -5 // mounté s'il existe déjà.
# lvdisplay

Point de montages:
Création des répertoires:

# mkdir /path/rep0...

Les répertoires seront monté sur les LV et auront besoin d’être formatés:

# mkfs.exta /path/rep01    // Pour du ext
# xfs_growfs /path/rep02 // Pour du xfs

Montage des volumes sur les répetoires:

# mount /dev/VG_01/LV_01 /path/rep01
# mount /dev/VG_01/LV_02 /path/rep02

Puis montés de façon permanente dans fstab:

# lvdisplay                // Donne le path du lv
# blkid /dev/VG_01/LV_01 // Donne l'UIID (et le filesystem)
# lsblk -fp // Idem

Dans fstab:

UUID=cdc115ce-aea6-4da5-adcd-4b945250cc18 /path/rep01 ext4 default 0 0
UUID=393b9eff-30df-403c-9abb-eb7afd9cea39 /path/rep02 xfs default 0 0

Configure LVM

| There is already an LVM mounted on /dev/myvg/mylv.
| We need to extend it by 500 MB.

Check if the VG have enought place (search for Free PE/Size line):

# vgdisplay myvg

Extend the existing LV:

# lvextend -L +500M /dev/myvg/mylv

Resize the filesystem:

# resize2fs /dev/myvg/mylv		// Ext4
# xfs_growfs /mount/point // xfs

Configure LVM 1

| Create a vdo named VDO1 of logical size 50GB (actual size 5GB) on sdd, under volume group VG1 and mount it at /vdo_m

# yum install lvm2 kmod-kvdo vdo // LKV
# lsblk // find disk to use
# su // elevate permissions
# pvcreate /dev/sdd // create physical volume
# vgcreate VG1 /dev/sdd // create volume group
# vgs // to verify
# lvcreate --type vdo --name VDO1 --size 5GB --virtualsize 50GB VG1
# lsblk // to verify
# mkfs.xfs -K /dev/VG1/VDO1
# mkdir /vdo_m
# vi /etc/fstab /dev/VG1/VDO1 /vdo_m xfs defaults 0 0
# mount -a // to verify

Configure LVM

| Create one logical volume engineering from a datastore volume group of size 30 Extents.
| Logical volume engineering from the datastore volume group extent should be 8 MiB.
| Format with ext3 file system and mount it permanently under /mnt/database (on /dev/sdb).

# lsblk
# fdisk -c /dev/sdb // p n p 2 Default +240m p t l 8e p w (240m = 240MiB)
# partprobe
# fdisk -l
# pvcreate /dev/sdb2
# pvs
# vgcreate -s 8MiB datastore /dev/sdb2
# vgs
# vgdisplay datastore
# lvcreate -l 30 -n engineering datastore
# lvs
# mkdir -p /mnt/database
# mkfs.ext3 /dev/datastore/engineering
# vim /etc/fstab // /dev/datastore/engineering /mnt/database ext3 defaults 0 0
# mount -a
# lsblk

Configure LVM 3

| Create a new physical volume with volume group in the name of datacontainer, the extent of VG should be 16MB.
| Also create new logical volume with name datacopy with the size of 50 extents and filesystem vfat mounted under /datasource.

Before any kind of operations on partitions it is good to know what we actually have in the system. The proper command to list all devices we can use is in order lsblk. Also You have to be sure what kind of partitioning scheme was used (MBR mostly used on older computers or GPT on computers that use UEFI).
I advise reading this article to get knowledge hot to find out what is going on in the system: https://www.binarytides.com/linux-command-check-disk-partitions/

You can issue:

# fdisk -l

It is possible that You will have to install this tool

# parted -l   

if the output for label/partition table contains DOS in any way then the partition table was configured using MBR.
If there is anything else - GPT. It is crucial to not mix them on one device (creating MBR partitions on GPT and vice versa)!

Creating new partition was described in question 017. Make sure that the type of partition is set to Linux LVM and that You run partprobe after it (to let kernel reread new partition table).

When we got the partition the first step is to create physical partition:

# pvcreate /dev/PARTITION_IDENTIFIER

Check if it was created

# pvdisplay

Physical partition can be assigned to the volume group.

# vgcreate -s 16M datacontainer /dev/PARTITION_IDENTIFIER

check if it was created

# vgdisplay

Now it is time to create logical volume (notice -l switch that allows specifying extents number):

# lvcreate -l 50 -n datacopy datacontainer

check if it was created

# lvdisplay

Creating filesystem can be done with mkfs with type flag or with specialized tool like below:

# mkfs.vfat /dev/datacontainer/datacopy

Now we create mount point for it and we provide entry in fstab file to make it permanent:

# mkdir /datasource

get UUID for created logical volume

# blkid

Edit /etc/fstab and append there below line

# UUID=UUUID_IDENTIFIER_COPIED_FROM_BLKID  /datasource vfat  defaults   0 0    

Save the file and check if everything works:

mount -a

Configure LVM

| Resize the logical volume /dev/datastore/engineering size to 20 extents.

# vgdisplay
# lvdisplay
# df -h /dev/datastore/engineering
# umount /mnt/database
# e2fsck -f /dev/datastore/engineering
# xfs_growfs /dev/datastore/engineering 80M # Ajustez en fonction de la taille calculée.
lvreduce -L 80M /dev/datastore/engineering

Si le système de fichier est en Ext, on peut directement tout faire en 1 seule commande:

# lvreduce -r -l -10 /dev/datastore/engineering  // -10 = reduces from 30 to 20

Remount

# mount /dev/datastore/engineering /point_de_montage
# df -h /dev/datastore/engineering

Configure LVM

| Create a volume group with name myvgex, and set 16M as a extends.
| And divided a volume group containing 50 extends on volume group lvext.
| Make it as ext4 file system, and mounted automatically under /mnt/lvext.

Create two Linux LVM as /dev/sda1 /dev/sda2

# fdisk /dev/sda

Create PV:

# pvcreate /dev/sda1 /dev/sda2

Create VG:

# vgcreate myvgex --physicalextentsize 16M /dev/sda1 /dev/sda2

lvcreate -n lvext –extents 50 myvgex
- In case of error in size, extend volume group as:
- fdisk /dev/sda to create Linux LVM as /dev/sda3
- pvcreate /dev/sda3
- vgextend myvgex /dev/sda3

now it should have suff. space

# lvcreate -n lvext --extents 50 myvgex
# mkfs.ext4 /dev/mapper/myvgex-lvext -L VGEXT
# blkid /dev/mapper/myvgex-lvext
# mkdir -p /mnt/lvext
# vim /etc/fstab
- LABEL="VGEXT" /mnt/lvext ext4 defaults 0 0
# mount -a
# systemctl daemon-reload

To Verify

reboot 

Configure LVM

| Create a xfs file system on a new logical volume of 100MB called lv_xfs.
| Mount it permanently with uuid under /xfs.

Before any kind of operations on LVM it is good to know what we actually have in the system. The proper command to list all
devices we can use is in order pvs, vgs and lvs. It shows all physical storages and devices, volume groups and logical volumes.

First we create a logical volume that is mentioned in the question and we create files system on it:

# lvcreate –size 100M –name lv_xfs /dev/vg

we can also use mkfs -type xfs /dev/vg/lv_xfs

# mkfs.xfs /dev/vg/lv_xfs

After that we have to perform all the steps for permanent mounting, starting with creation of mount point:

# mkdir /xfs

Then we edit fstab file in order to make mounting permanent:

# vi /etc/fstab
UUID=... /xfs xfs defaults 1 2

Finally we remount the discs by reloading fstab configuration using:

mount -a

Additional comment:

Make sure that You know the difference between partition label and file system name - https://superuser.com/questions/1099232/what-is-the-difference-between-a-partition-name-and-a-partition-label/1099292
and You do not confuse them.

When editing fstab file by hand we got much more control over mount options. Also pay attention to the fact that with provided solution we use ‘1 2’ values for
checking mount point integrity - the first one indicates how often the partition will be backed by dump program, the second one points to the level of integrity check when
mounting (0 means no check, 1 is applied only to the root partition).

Configure LVM

| Reduce the size of existing logical volume by 400MB.

First we list existing logical volumes:

# lvdisplay   

We should get the /dev… link to our logical volume. That is step one. In order to shrink the existing size of
logical volume it requires unmounting it to perform this operation:

# umount /MOUNT_POINT

It came the time to resize our logical volume:

# lvreduce -L -400M /dev/LINK_TO_LVM

Now we just remount the volume again and check if everything as it should be:

# mount -a
# lvdisplay

Configure LVM

| Extend the existing xfs file system to a total size of 200MB and add a label called myFS.

Before any kind of operations on LVM it is good to know what we actually have in the system. The proper command to list all devices we can use is in order pvs, vgs and lvs. It shows all physical storages and devices, volume groups and logical volumes.

Objectives require extending of logical partitions. The tricky part here is to remember that XFS filesystem (which is the default setting for RHEL) does not allow downsizing of XFS partition (the only possibility is to grow that volume). Be careful when reading LVM related questions.

When question is presented in a form we have in this task we can assume that the logical volume is less than given 200MB we have to set. Then we can use:

notice -r flag which indicates not only to resize logical volume but also filesystem on it

# lvextend -L 200M -r /dev/VOLUME_GROUP/LOGICAL_VOLUME

In order to give a logical volume a label we have to unmount it first, set a label and then mount it again:

# umount /LINK/TO/FILESYSTEM/MOUNT/POINT
# xfs_admin -L "myFS" /dev/VOLUME_GROUP/LOGICAL_VOLUME
# mount /LINK/TO/FILESYSTEM/MOUNT/POINT

Configure LVM

| Create a xfs file system on a new logical volume of 100MB called lv_xfs.
| Mount it permanently with uuid under /xfs.

Before any kind of operations on LVM it is good to know what we actually have in the system. The proper command to list all devices we can use is in order pvs, vgs and lvs. It shows all physical storages and devices, volume groups and logical volumes.

First we create a logical volume that is mentioned in the question and we create files system on it:

# lvcreate –size 100M –name lv_xfs /dev/vg

we can also use mkfs -type xfs /dev/vg/lv_xfs

# mkfs.xfs /dev/vg/lv_xfs

After that we have to perform all the steps for permanent mounting, starting with creation of mount point:

# mkdir /xfs

Then we edit fstab file in order to make mounting permanent:

# vi /etc/fstab
UUID=... /xfs xfs defaults 1 2

Finally we remount the discs by reloading fstab configuration using:

mount -a

Additional comment:

Make sure that You know the difference between partition label and file system name - https://superuser.com/questions/1099232/what-is-the-difference-between-a-partition-name-and-a-partition-label/1099292 and You do not confuse them.

When editing fstab file by hand we got much more control over mount options. Also pay attention to the fact that with provided solution we use ‘1 2’ values for
checking mount point integrity - the first one indicates how often the partition will be backed by dump program, the second one points to the level of integrity check when
mounting (0 means no check, 1 is applied only to the root partition).

Configure LVM

| Create a logical volume called lvol1 of size 300MB in vgtest volume group.
| Mount the Ext4 file system persistently to /mnt/mnt1.

# parted /dev/sdb   assume we are dealing with gpt partition scheme
_(parted)_ `mkpart
_(parted)_ name ` pv1
_(parted)_ file system type `xfs
_(parted)_ start ` 1mb
_(parted)_ end ` 3gb
_(parted)_ `print
**1 1MB 3000mb 2999MB pv1 xfs**
(parted)`set 1 lvm on
**1 1MB 3000mb 2999MB pv1 xfs lvm**
(parted)`q`
# udevadm settle
# pvcreate /dev/sdb1
# vgcreate vgtest /dev/sdb1
# lvcreate -n lvol1 -L 300m vgtest
# mkfs.ext4 /dev/vgtest/lvol1
# blkid /dev/vgtest/lvol1
# mkdir /mnt/mnt1
# echo "/dev/vgtest/lvol1 /mnt/mnt1 ext4 defaults 0 0" >> /etc/fstab
# mount -a
# mount | grep mnt1

Configure LVM

| Create a logical volume called lvswap of size 300MB in vgtest volume group.
| Initialize the logical volume for swap use.
| Use the UUID and place an entry for persistence.

# lvcreate -n lvswap -L 300m vgtest
# mkswap /dev/vgtest/lvswap
# echo "UUID=xxxx-xxxx-xxxx-xxxx-xxxx swap swap defaults 0 0" >> /etc/fstab
# swapon -a
# swapon --show

Configure LVM

| Create a New Logical Volume (LV-A) with a Size of 30 Extents that Belongs to the Volume Group VG-A (with a PE Size of 32M).
| After Creating the Volume, Configure the Server to Mount It Persistently on /mnt

# parted /dev/sdb
# set 4 lvm on
# pvcreate /dev/sdb4
# vgcreate --physicalextentsize 32M vg-a /dev/sdb4
# lvcreate -n lv-a -l 30 vg-1
# lvdisplay vg-1 #get the full path ov this volume -> `/dev/vg-1/lv-1
# mkfs.xfs /dev/vg-1/lv-1
# blkid /dev/vg-1/lv-1 #check the UUID, but we can also mount LVM using it's path /dev/vg-1/lv-1
# mkdir /mnt/lv-1-mnt
# echo "/dev/vg-1/lv-1 /mnt/lv-1-mnt xfs defaults 0 0" >> /etc/fstab
# mount -a
# mount | grep lv-1` # check if the mount has been successfu

Configure LVM

| Initialise one partition sdb1 (90MB) and one disk sdc (250MB) for use in LVM.
| Create a volume group called vgbook and add both physical volumes to it. Use the PE size of 16MB and list and display the volume group and the physical volumes

# fdisk /dev/sdb
# enter n => to add new part
# accept the default part
# accept the default starting sector
# For the ending sector , Enter The size of the part +90M
# press t => to change the type of part to Linux lvm
# 8e
# enter w => to write table to disk and exit
# partprobe => to inform the os part table change

# pvcreate /dev/sdc
# vgcreate vgbook /dev/sdb1 /dev/sdc -s 16M
# pvs
# pvdisplay
# vgs
# vgdisplay vgbook

Configure LVM

| Create two logical volumes, lvol1 and lvbook1, in the vgbook volume group. Use 120MB for lvol0 and 192MB for lvbook1. Display the details of the volume group and the logical volumes

# lvcreate --name lvol0 -L 120M vgbook 
# lvcreate --name lvbook1 -L 192 vgbook
# lvs
# lvdisplay /dev/vgbook/lvm_name

Configure LVM

| Add another partition sdb2 of size 158MB to vgbook to increase the pool of allocatable space.
| Initialise the new partition prior to adding it to the volume group. Increase the size of lvbook1 to 336MB.
| Display the basic information for the physical volumes, volume group, and logical volume

# fdisk /dev/sdb
# enter n
# accept the default part
# accept the default starting sector
# For the ending sector , Enter The size of the part +158M
# enter w
# partprobe
# pvcreate /dev/sdb2
# vgextend vgbook /dev/sdb2
# lvextend -L +144M /dev/vgbook/lvbook1
# lvs

Configure LVM

| Rename lvol0 to lvbook2. Decrease the size of lvbook2 to 50MB using the lvreduce command and then add 32MB with the lvresize command.
| Remove both logical volumes.
| Display the summary for the volume groups, logical volumes, and physical volumes

# lvrename /dev/vgbook/lvol0 lvbook2
# lvreduce -L -50M /dev/vgbook/lvbook2
# lvresize -L +32M /dev/vgbook/lvbook2
# lvremove /dev/vgbook/lvbook*
lvs, vgs, pvs

Configure LVM

| Uninitialise all three physical volumes - sdb1, sdb2, and sdb - by deleting the LVM structural information from them.
| Use the pvs command for confirmation.
| Remove the partitions from the sdd disk and verify that all disks are now in their original raw state

# vgremove vgbook
# pvremove /dev/sdb1 /dev/sdb2 /dev/sdc
# pvs
# wipefs -af /dev/sdb /dev/sdc
# lsblk

Configure LVM

| Create a new logical volume (LV-A) with a size of 30 extents that belongs to the volume group VG-A (with a PE size of 32M).
| After creating the volume, configure the server to mount it persistently on /mnt

# pvcreate /dev/sdb
# vgcreate vg-a /dev/sdb -s 32M
# lvcreate --name lv-a vg-a -l 30M
# mkfs.xfs /dev/vg-a/lv-a
# blkid
# echo "UUID=XXXX /mnt xfs defaults 0 0 ">> /etc/fstab

Configure LVM

| Create 2x100MB partitions on the /dev/sdb disk, initialise them separately with the Ext4 and XFS file system types
| - create mount points called /ext4fs and /xfs1
| - attach them to the directory structure, verify their availability and usage
| - mount them persistantly using their UUIDS

# fdisk /dev/sdb
# press m => list all the opts
# enter n => to add new part
# accept the default part
# accept the default starting sector
# For the ending sector , Enter The size of the part +100M
# press n => to add another part as above
# enter w => to write table to disk and exit
# partprobe => to inform the os part table change

File sys type :

# mkfs.ext4 /dev/sdb1
# mkfs.xfs /dev/sdb2

Create the moint point

# mkdir /ext4fs 
# mkdir /xfs1
# mount /dev/sdb1 /ext4fs
# mount /dev/sdb2 /xfs1
# blkid => to grep the UUID
# echo "UUID=xxxx /ext4fs ext4 defaults 0 0 " >> /etc/fstab
# echo "UUID=xxxx /xfs xfs defaults 0 0 " >> /etc/fstab
# mount -a

Configure LVM

| Create a volume group called vgfs comprised of a 160MB physical volume created in a partition on the /dev/sdb disk.
| The PE size for the volume group should be set at 16MB. Create 2 logical volumes called ext4vol and xfsvol of size 80MB each and initialise them with the Ext4 and XFS file system types.
| Ensure that both file systems are persistently defined using their logical volume device filenames.
| Create mount points /ext4fs2 and /xfsfs2, mount the file systems, and verify their availability and usage

Initialize the physical volume for use by LVM 
# pvcreate /dev/sdb
# pvs
# vgcreate vgfs /dev/sdb -s 16MB
# lvcreate --name ext4vol -L 80MB vgfs
# lvcreate --name xfsvol -L 80MB vgfs
# vgs
# mkfs.ext4 /dev/vgfs/ext4vol
# mkfs.xfs /dev/vgfs/xfsvol
# mount /dev/vgfs/ext4vol /ext4fs2
# mount /dev/vgfs/xfsvol /xfsfs2
# blkid => grep the UUID and add the appropriate lines in /etc/fstab
# df -hT

Configure LVM

| Grow the size of the vgfs volume group that was created above by adding another disk to it.
| Extend the ext4vol logical volume along with the file system it contains by 40MB

# vgextend vgfs /dev/sdc 
# lvextend -L +40 -r /dev/gvfs/ext4fs => -r : to extend the file system at the same time
# lvs

Configure LVM

| Mount the /common that exported in task 4 .
| Create a mount point called /local. Add the remote share to the file system table for persistence.
| Create a test file in the mount point and confirm the file creation on the NFS server
In server2:

# mkdir /local
# showmount -e server1 => or you can use the ip @ of the server
# mount server1:/ /local
# echo "server1:/common /local nfs _netdev 0 0" >> /etc/fstab
# mount -a
# echo "This message from server2 " >> /local/file

In server1:

# cat /common/file

Configure LVM

| Install the VDO software packages, start the VDO services, and mark it for autostart on subsequent reboots
| Create a volume called vdo-vol1 of logical size 16GB on the /dev/sdc disk (the actual size of /dev/sdc is 4GB).
| List the volume and display its status information.
| Show the activation status of the compression and de-duplication features

# dnf install vdo kmod-kvdo -y
# systemctl enable --now vdo
# vdo create --name vdo-vol1 --vdoLogicalSize 16G --device /dev/sdc
# vdo list => vdo-vol1
# vdo status --name vdo-vol1 | egrep -i "compression|deduplication"

Configure LVM

| Delete the vdo-vol1 volume that was created above and confirm the removal.
| Create a VDO volume called vdo1 of logical size 16GB on the sdc disk.
| Initialise the volume with the XFS file system type, define it for persistence using its device files, create a mount point called /xfsvdo1, attach it to the directory structure, and verify its availability and usage

# vdo remove --name vdo-vol1 --verbose
# vdo list
# wipefs -a /dev/sdc
# vdo create --name vdo1 --vdoLogicalSize 16G --device /dev/sdc
# vdo list
# mkfs.xfs -K /dev/mapper/vdo1
# mkdir /xfsvdo1
# blkid
# echo "UUID=XXXXX /xfsvdo1 xfs defaults,x-systemd.requires=vdo.service,discard 0 0">>/etc/fstab => if you forget the mount option : check the man vdo page
# mount -a
# cp -rf /etc/[a-f]* /xfsvdo1/
# vdostats --human-readable vdo1

Configure LVM

| Install the Stratis software packages, start the Stratis service, and mark it for autostart on subsequent system reboots

# # dnf install stratis-cli stratisd 
# # systemctl enable --now stratis

Configure LVM

| Create a new logical volume as required:
| - Name the logical volume as database, belongs to datastore of the volume group, size is 60 PE.
| - Expansion size of each volume in volume group datastore is 16MB.
| - Use ext3 to format this new logical volume, this logical volume should automatically mount to /mnt/database.

Create a disk partition

# fdisk /dev/vdb

Create a physical group (pv)

# pvcreate /dev/vdb4
Physical volume "/dev/vdb4" successfully created.

Create a volume group (vg)

# vgcreate qagroup -s 16M /dev/vdb4
# -s Extended block (PE) size of the physical volume on the volume group
Volume group "qagroup" successfully created

Create a logical volume (lv)

# lvcreate -n qa -l 60 /dev/qagroup
Logical volume "qa" created.

Formatting

# mkfs.ext3 /dev/qagroup/qa

View UUID

# blkid /dev/qagroup/qa
/dev/qagroup/qa: UUID="5ad7f2df-9749-4a46-adb6-853f3805d795" SEC_TYPE="ext2" TYPE="ext3"

Create /mnt/qa directory

# mkdir /mnt/qa

Make a permanent mount

# vim /etc/fstab
UUID="5ad7f2df-9749-4a46-adb6-853f3805d795" /mnt/qa ext3 defaults 0 0

load

# mount -a # Load all devices set in the file /etc/fstab
# df -h
/dev/mapper/qagroup-qa 929M 1.2M 880M 1% /mnt/qa

Configure LVM

| Set logical volume size
| Resize the logical volume vo and its file system to 230 MiB.
| Make sure the filesystem contents remain unchanged.
| Note: The partition size is rarely exactly the requested size, so a range of 230 MiB to 270 MiB is acceptable.

Query logical volume vo

# df -h
/dev/mapper/myvol-vo 175M 1.6M 160M 1% /reports

Expansion

# lvextend -L 250M /dev/mapper/myvol-vo #Expand logical volume space
Logical volume myvol/vo successfully resized.

Query formatting type (ext4)

# blkid | grep vo
/dev/mapper/myvol-vo: UUID="67994f68-d3e1-4686-8393-8df05149883f" TYPE="ext4"

Refresh according to type

# resize2fs /dev/mapper/myvol-vo

Verify

# df -h
/dev/mapper/myvol-vo 240M 2.1M 204M 1% /reports

Configure LVM

| - Create VDO volumes
| - Create a new VDO volume with the following requirements:
| - use unpartitioned disk
| - The name of the volume is vdough
| - The logical size of the volume is 50G
| - The volume is formatted with the xfs file system
| - The volume is mounted (at system boot) under /vbread

1. Search for the installation package
# yum search vdo
vdo.x86_64
kmod-kvdo.x86_64

2. Check the installation
# rpm -q vdo kmod
package vdo is not installed
kmod-25-16.el8.x86_64

3. Install
# yum install -y vdo.x86_64 kmod-kvdo.x86_64
Installed:
kmod-kvdo-6.2.2.117-65.el8.x86_64
vdo-6.2.2.117-13.el8.x86_64

Complete!

4.man vdo view format
# vdo create --name=vdough --device=/dev/vdc --vdoLogicalSize=50G

5. Formatting
# -K quick format (uppercase)

# mkfs.xfs -K /dev/mapper/vdough

6. Create a mount point
# mkdir /vbread

7. Find the UUID
# blkid
or
# blkid /dev/mapper/vdough
/dev/mapper/vdough: UUID="a1f68c65-cf38-4cc8-b508-860a2e90397c" TYPE="xfs"

8. Make a permanent mount, and then mount it through the network
# vim /etc/fstab
UUID="a1f68c65-cf38-4cc8-b508-860a2e90397c" /vbread xfs _netdev 0 0

9. load
# mount -a # Load all devices set in the file /etc/fstab

10.
# df -h
/dev/mapper/vdough 50G 390M 50G 1% /vbread

11. vdo is a service that needs to be set to start automatically at boot
# systemctl restart vdo
# systemctl enable vdo
# systemctl status vdo

Configure LVM

| Change the logical volume capacity named vo from 190M to 300M and the size of the floating range should set between 280 and 320. (This logical volume has been mounted in advance.)

Explanation: # vgdisplay -
(Check the capacity of vg, if the capacity is not enough, need to create pv , vgextend , lvextend)

# lvdisplay (Check lv)
# lvextend -L +110M /dev/vg2/lv2
# resize2fs /dev/vg2/lv2
mount -a

(Verify)

(Decrease lvm)

# umount /media
# fsck -f /dev/vg2/lv2
# resize2fs -f /dev/vg2/lv2 100M
# lvreduce -L 100M /dev/vg2/lv2
# mount -a
# lvdisplay (Verify)

OR -

# e2fsck -f /dev/vg1/lvm02
# resize2fs -f /dev/vg1/lvm02
# mount /dev/vg1/lvm01 /mnt
# lvreduce -L 1G -n /dev/vg1/lvm02
# lvdisplay (Verify)

Configure LVM

| Create a volume group, and set 16M as a extends and divided a volume group containing 50 extends on volume group lv, make it as ext4 file system, and mounted automatically under /mnt/data.

Answer : See explanation below.

Explanation:

# pvcreate /dev/sda7 /dev/sda8
# vgcreate -s 16M vg1 /dev/sda7 /dev/sda8
# lvcreate -l 50 -n lvm02
# mkfs.ext4 /dev/vg1/lvm02
# blkid /dev/vg1/lv1
# vim /etc/fstab
# mkdir -p /mnt/data
UUID=xxxxxxxx /mnt/data ext4 defaults 0 0
# vim /etc/fstab
# mount -a
# mount
(Verify)

Configure LVM

| Create a 512M partition, make it as ext4 file system, mounted automatically under /mnt/data and which take effect automatically at boot-start.

Answer : See explanation below.

Explanation:

# fdisk /dev/vda -
n
+512M
w
# partprobe /dev/vda
# mkfs -t ext4 /dev/vda5
# mkdir -p /data
# vim /etc/fstab
/dev/vda5 /data ext4 defaults 0 0
# mount -a

Configure LVM

| Create a volume group, and set 8M as a extends.
| Divided a volume group containing 50 extends on volume group lv (lvshare), make it as ext4 file system, and mounted automatically under /mnt/data.
| And the size of the floating range should set between 380M and 400M.

Answer : See explanation below.

Explanation: # fdisk -

# partprobe
# pvcreate /dev/vda6
# vgcreate -s 8M vg1 /dev/vda6 -s
# lvcreate -n lvshare -l 50 vg1 -l
# mkfs.ext4 /dev/vg1/lvshare
# mkdir -p /mnt/data
# vim /etc/fstab
/dev/vg1/lvshare /mnt/data ext4 defaults 0 0
# mount -a
# df -h

Configure LVM

| Adjust the size of the Logical Volume.
| Adjust the size of the vo Logical Volume, its file system size should be 290M. Make sure that the content of this system is complete.
| Note: the partition size is rarely accurate to the same size as required, so in the range 270M to 320M is acceptable.

Answer : See explanation below.

Explanation: Addition -
df -hT
lvextend -L +100M /dev/vg0/vo

Lvscan -

xfs_growfs /home/ //home is the mounted directory of the LVM, this step just need to do in the practice environment, and test EXT4 does not need this step. resize2fs /dev/vg0/vo// use this command to update in examination. df -hT

OR -

Subtraction -
e2fsck -f/dev/vg0/vo
umount /home
resize2fs /dev/vg0/vo // the final required partition capacity is 100M lvreduce -l 100M /dev/vg0/vo mount /dev/vg0/vo/home df -hT

Configure LVM

| Créez un volume logique de 500 Mo appelé lv_data dans le groupe de volumes vg_data, formatez-le en xfs, et montez-le sur /mnt/data.”

# lvcreate -L 500M -n lv_data vg_data
# mkfs.xfs /dev/vg_data/lv_data
# mkdir /mnt/data
# mount /dev/vg_data/lv_data /mnt/data
echo '/dev/vg_data/lv_data /mnt/data xfs defaults 0 0' | # tee -a /etc/fstab

Configure LVM

| Créez un volume logique de 1 Go nommé lv_backup en utilisant les disques /dev/sdc et /dev/sdd, formatez-le en ext4 et montez-le sur /mnt/backup.”

# pvcreate /dev/sdc /dev/sdd
# vgcreate vg_backup /dev/sdc /dev/sdd
# lvcreate -L 1G -n lv_backup vg_backup
# mkfs.ext4 /dev/vg_backup/lv_backup
# mkdir /mnt/backup
# mount /dev/vg_backup/lv_backup /mnt/backup
echo '/dev/vg_backup/lv_backup /mnt/backup ext4 defaults 0 0' | # tee -a /etc/fstab

Configure LVM

| Create a 2GB partition using /dev/sdb make it as ext4 file system and mounted automatically under /mnt/data at boot-start**

# fdisk /dev/sdb

command (m for help): press 'n' here
select (default p): Enter
partition number (1-4, default between 1-4): Enter
first sector(default): Enter
last sector, sector or +size (K,M,G,T,P)(default): +2G
command (m for help): press p for partition info
command (m for help): press w to save changes
# udevadm settle (to setup driver)
# mkfs.ext4 /dev/sdb1 (here sdb1 is partition in /dev/sdb)
# mkdir /mnt/data
# mount /dev/sdb1 /mnt/data

To mount a partition automatically under /mnt/data make the entry of partition in /etc/fstab file. use following command:

# vim /etc/fstab (add partition entry here)

Configure LVM

| Create a 2 GB gpt partition and format the partition with xfs and mount the device persistently

# lsblk		=> to list all the block device
# fdisk /dev/sdb
# press m => list all the opts
# enter g => to create a new gpt part
# enter n => to add new part
# accept the default part
# accept the default starting sector
# For the ending sector , Enter +2G
# enter w => to write table to disk and exit
# partprobe => to inform the os part table change

# mkfs.xfs /dev/sdb1
# blkid => to grep the uuid
# mkdir /mnt/task1
# echo 'UUID=xxxx /mnt/task1 xfs defaults 0 0' >> /etc/fstab
# mount -a

Configure LVM

| Assign partition type “msdos” to /dev/sdc for using it as an MBR disk. Create and confirm a 100MB primary partition on the disk

same steps created in task 1 expet the size and the type “msdos”

# enter o   => to create an MBR disk 

Configure LVM

| Delete the sdb1 partition that was created in Task1 above

# lsblk		=> to see the moint point 
# umount /mnt/task1 && comment the line in /etc/fstab
# mount -a
# fdisk /dev/sdb
# enter d => to remove the part
# press w => to save
# partprobe

Configure LVM

| Create a logical volume -
| Create a new logical volume as required:
| Name the logical volume as database, belongs to datastore of the volume group, size is 50 PE.
| Expansion size of each volume in volume group datastore is 16MB.
| Use ext3 to format this new logical volume, this logical volume should automatically mount to /mnt/database

Answer : See explanation below.

Explanation: fdisk -cu /dev/vda// Create a 1G partition, modified when needed partx ג€”a /dev/vda pvcreate /dev/vdax vgcreate datastore /dev/vdax ג€”s 16M lvcreateג€” l 50 ג€”n database datastore mkfs.ext3 /dev/datastore/database mkdir /mnt/database mount /dev/datastore/database /mnt/database/ df ג€”Th vi /etc/fstab
/dev/datastore /database /mnt/database/ ext3 defaults 0 0 mount ג€”a
Restart and check all the questions requirements.

Configure LVM

Create a volume group, and set the size is 500M, the size of single PE is 16M. Create logical volume named lv0 in this volume group, set size is 20 PE, make it as ext3 file system, and mounted automatically under data.

# fdisk /dev/vda
# pvcreate /dev/vda3
# vgcreate -s 16M vg0 /dev/vda3
# lvcreate -n lv0 -l 20 vg0
# mkfs.ext3 /dev/mapper/vg0-lv0
# mkdir /data
# /etc/fstab:
/dev/mapper/vg0-lv0 /data ext3 defaults 0 0
# mount -a
# mount | grep data

Configure LVM

| “Créez une partition de 1 Go sur un disque additionnel et formatez-la en ext4.
| Montez-la sur /data et assurez-vous qu’elle se monte automatiquement au redémarrage.”

# fdisk /dev/sdb  # Créer une partition
# mkfs.ext4 /dev/sdb1
# mkdir /data
# mount /dev/sdb1 /data
# '/dev/sdb1 /data ext4 defaults 0 0' | # tee -a /etc/fstab

Documentations

Internet
Git
ChatGPT

> Partager <