TIPS & TRICKS
To search the contents of the man pages
# 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 |
Les LV:
Contenus dans les VG:
# lvcreate --name LV_01 -L 10G VG_01 |
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 |
Montage des volumes sur les répetoires:
# mount /dev/VG_01/LV_01 /path/rep01 |
Puis montés de façon permanente dans fstab:
# lvdisplay // Donne le path du lv |
Dans fstab:
UUID=cdc115ce-aea6-4da5-adcd-4b945250cc18 /path/rep01 ext4 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 |
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 |
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 |
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 |
# umount /mnt/database |
# e2fsck -f /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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
File sys type :
# mkfs.ext4 /dev/sdb1 |
Create the moint point
# mkdir /ext4fs |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
Create a volume group (vg)
# vgcreate qagroup -s 16M /dev/vdb4 |
Create a logical volume (lv)
# lvcreate -n qa -l 60 /dev/qagroup |
Formatting
# mkfs.ext3 /dev/qagroup/qa |
View UUID
# blkid /dev/qagroup/qa |
Create /mnt/qa directory
# mkdir /mnt/qa |
Make a permanent mount
# vim /etc/fstab |
load
# mount -a # Load all devices set in the file /etc/fstab |
# df -h |
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 |
Expansion
# lvextend -L 250M /dev/mapper/myvol-vo #Expand logical volume space |
Query formatting type (ext4)
# blkid | grep vo |
Refresh according to type
# resize2fs /dev/mapper/myvol-vo |
Verify
# df -h |
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 |
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) |
(Verify)
(Decrease lvm)
# umount /media |
OR -
# e2fsck -f /dev/vg1/lvm02 |
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 |
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 - |
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 |
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 - |
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 |
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 |
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 |
# udevadm settle (to setup driver) |
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 |
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 |
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 |
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 |
Documentations
Internet
Git
ChatGPT