Este conteúdo não está disponível no idioma selecionado.
Chapter 3. Creating a deduplicated and compressed logical volume
You can create an LVM logical volume that uses the VDO feature to deduplicate and compress data.
3.1. LVM-VDO deployment scenarios
You can deploy VDO on LVM (LVM-VDO) in a variety of ways to provide deduplicated storage for:
- block access
- file access
- local storage
- remote storage
Because LVM-VDO exposes its deduplicated storage as a regular logical volume (LV), you can use it with standard file systems, iSCSI and FC target drivers, or as unified storage.
Deploying Ceph Storage on LVM-VDO is currently not supported.
- KVM
You can deploy LVM-VDO on a KVM server configured with Direct Attached Storage.
- File systems
You can create file systems on top of a VDO LV and expose them to NFS or CIFS users with the NFS server or Samba.
- iSCSI target
You can export the entirety of the VDO LV as an iSCSI target to remote iSCSI initiators.
- Encryption
Device Mapper (DM) mechanisms such as DM Crypt are compatible with VDO. Encrypting a VDO LV volumes helps ensure data security, and any file systems above the VDO LV are still deduplicated.
ImportantApplying the encryption layer above the VDO LV results in little if any data deduplication. Encryption makes duplicate blocks different before VDO can deduplicate them.
Always place the encryption layer below the VDO LV.
3.2. The physical and logical size of an LVM-VDO volume
This section describes the physical size, available physical size, and logical size that VDO can utilize.
- Physical size
This is the same size as the physical extents allocated to the VDO pool LV. VDO uses this storage for:
- User data, which might be deduplicated and compressed
- VDO metadata, such as the UDS index
- Available physical size
This is the portion of the physical size that VDO is able to use for user data.
It is equivalent to the physical size minus the size of the metadata, rounded down to a multiple of the slab size.
- Logical Size
This is the provisioned size that the VDO LV presents to applications. It is usually larger than the available physical size. VDO currently supports any logical size up to 254 times the size of the physical volume with an absolute maximum logical size of 4 PB.
When you set up a VDO logical volume (LV), you specify the amount of logical storage that the VDO LV presents. When hosting active VMs or containers, Red Hat recommends provisioning storage at a 10:1 logical to physical ratio, that is, if you are utilizing 1 TB of physical storage, you would present it as 10 TB of logical storage.
If you do not specify the
--virtualsize
option, VDO provisions the volume to a1:1
ratio. For example, if you put a VDO LV on top of a 20 GB VDO pool LV, VDO reserves 2.5 GB for the UDS index, if the default index size is used. The remaining 17.5 GB is provided for the VDO metadata and user data. As a result, the available storage to consume is not more than 17.5 GB, and can be less due to metadata that makes up the actual VDO volume.
Additional resources
3.3. Slab size in VDO
The physical storage of the VDO volume is divided into a number of slabs. Each slab is a contiguous region of the physical space. All of the slabs for a given volume have the same size, which can be any power of 2 multiple of 128 MB up to 32 GB.
The default slab size is 2 GB to facilitate evaluating VDO on smaller test systems. A single VDO volume can have up to 8192 slabs. Therefore, in the default configuration with 2 GB slabs, the maximum allowed physical storage is 16 TB. When using 32 GB slabs, the maximum allowed physical storage is 256 TB. VDO always reserves at least one entire slab for metadata, and therefore, the reserved slab cannot be used for storing user data.
Slab size has no effect on the performance of the VDO volume.
Physical volume size | Recommended slab size |
---|---|
10–99 GB | 1 GB |
100 GB – 1 TB | 2 GB |
2–256 TB | 32 GB |
The minimal disk usage for a VDO volume using default settings of 2 GB slab size and 0.25 dense index, requires approx 4.7 GB. This provides slightly less than 2 GB of physical data to write at 0% deduplication or compression.
Here, the minimal disk usage is the sum of the default slab size and dense index.
You can control the slab size by providing the --config 'allocation/vdo_slab_size_mb=size-in-megabytes'
option to the lvcreate
command.
3.4. Installing VDO
This procedure installs software necessary to create, mount, and manage VDO volumes.
Procedure
Install the VDO software:
# dnf install lvm2 kmod-kvdo vdo
3.5. Creating an LVM-VDO volume
This procedure creates an VDO logical volume (LV) on a VDO pool LV.
Prerequisites
- Install the VDO software. For more information, see Installing VDO.
- An LVM volume group with free storage capacity exists on your system.
Procedure
Pick a name for your VDO LV, such as
vdo1
. You must use a different name and device for each VDO LV on the system.In all the following steps, replace vdo-name with the name.
Create the VDO LV:
# lvcreate --type vdo \ --name vdo-name --size physical-size --virtualsize logical-size \ vg-name
- Replace vg-name with the name of an existing LVM volume group where you want to place the VDO LV.
- Replace logical-size with the amount of logical storage that the VDO LV will present.
If the physical size is larger than 16TiB, add the following option to increase the slab size on the volume to 32GiB:
--config 'allocation/vdo_slab_size_mb=32768'
If you use the default slab size of 2GiB on a physical size larger than 16TiB, the
lvcreate
command fails with the following error:ERROR - vdoformat: formatVDO failed on '/dev/device': VDO Status: Exceeds maximum number of slabs supported
Example 3.1. Creating a VDO LV for container storage
For example, to create a VDO LV for container storage on a 1TB VDO pool LV, you can use:
# lvcreate --type vdo \ --name vdo1 --size 1T --virtualsize 10T \ vg-name
ImportantIf a failure occurs when creating the VDO volume, remove the volume to clean up.
Create a file system on the VDO LV:
For the XFS file system:
# mkfs.xfs -K /dev/vg-name/vdo-name
For the ext4 file system:
# mkfs.ext4 -E nodiscard /dev/vg-name/vdo-name
Additional resources
-
lvmvdo(7)
man page
3.6. Creating VDO volumes in the web console
Create a VDO volume in the RHEL web console.
Prerequisites
You have installed the RHEL 9 web console.
For instructions, see Installing and enabling the web console.
-
The
cockpit-storaged
package is installed on your system. - An LVM2 group from which you want to create VDO.
Procedure
Log in to the RHEL 9 web console.
For details, see Logging in to the web console.
- Click Storage.
Click the menu button,
, next to the LVM2 group in which you want to create a VDO volume.- Select VDO filesystem volume in the drop-down menu next to the Purpose field.
- In the Name field, enter a name of the VDO volume without spaces.
In the Logical Size bar, set up the size of the VDO volume. You can extend it more than ten times, but consider for what purpose you are creating the VDO volume:
- For active VMs or container storage, use logical size that is ten times the physical size of the volume.
- For object storage, use logical size that is three times the physical size of the volume.
For details, see Deploying VDO.
Select the Compression option. This option can efficiently reduce various file formats.
For details, see Changing the compression settings on an LVM-VDO volume.
Select the Deduplication option.
This option reduces the consumption of storage resources by eliminating multiple copies of duplicate blocks. For details, see Changing the deduplication settings on an LVM-VDO volume.
Verification
- Check that you can see the new VDO volume in the Storage section. Then, you can format it with a file system.
3.7. Formatting VDO volumes in the web console
VDO volumes act as physical drives. To use them, you must format them with a file system.
Formatting erases all data on the volume.
Prerequisites
You have installed the RHEL 9 web console.
For instructions, see Installing and enabling the web console.
-
The
cockpit-storaged
package is installed on your system. - A VDO volume is created.
Procedure
Log in to the RHEL 9 web console.
For details, see Logging in to the web console.
- Click Storage.
- Click the LVM2 volume group containing the VDO volume you want to format.
- Click the menu button, , at the end of the line with the VDO volume you want to format.
Click Format.
- In the Name field, enter the logical volume name.
- In the Mount Point field, add the mount path.
- By default, the web console rewrites only the disk header after you finish this dialog. The advantage of this option is the speed of formatting. If you check the Overwrite existing data with zeros option, the web console rewrites the whole disk with zeros. This option is slower because the program has to go through the whole disk. Use this option if the disk includes any sensitive data and you want to rewrite them.
In the Type drop-down menu, select a file system:
The default option, the XFS file system, supports large logical volumes, switching physical drives online without outage, and growing.
XFS does not support shrinking volumes. Therefore, you cannot reduce the size of a volume formatted with XFS.
- The ext4 file system supports logical volumes, switching physical drives online without outage, growing, and shrinking.
You can also select a version with the LUKS (Linux Unified Key Setup) encryption, which allows you to encrypt the volume with a passphrase.
- In the At boot drop-down menu, select when you want to mount the volume.
Click Format and mount or Format only.
Formatting can take several minutes depending on the used formatting options and the volume size.
Verification
- After a successful finish, you can see the details of the formatted VDO volume on the Storage tab and in the LVM2 volume group tab.
3.8. Extending VDO volumes in the web console
Extend VDO volumes in the RHEL 9 web console.
Prerequisites
You have installed the RHEL 9 web console.
For instructions, see Installing and enabling the web console.
-
The
cockpit-storaged
package is installed on your system. - The VDO volume is created.
Procedure
Log in to the RHEL 9 web console.
For details, see Logging in to the web console.
- Click Storage.
- Click your VDO volume in the VDO Devices box.
- In the VDO volume details, click the button.
- In the Grow logical size of VDO dialog box, extend the logical size of the VDO volume.
- Click Grow.
Verification
- Check the VDO volume details for the new size to verify that your changes have been successful.
3.9. Mounting an LVM-VDO volume
This procedure mounts a file system on an LVM-VDO volume, either manually or persistently.
Prerequisites
- An LVM-VDO volume exists on your system. For more information, see Creating an LVM-VDO volume.
Procedure
To mount the file system on the LVM-VDO volume manually, use:
# mount /dev/vg-name/vdo-name mount-point
To configure the file system to mount automatically at boot, add a line to the
/etc/fstab
file:For the XFS file system:
/dev/vg-name/vdo-name mount-point xfs defaults 0 0
For the ext4 file system:
/dev/vg-name/vdo-name mount-point ext4 defaults 0 0
If the LVM-VDO volume is located on a block device that requires network, such as iSCSI, add the
_netdev
mount option. For iSCSI and other block devices requiring network, see thesystemd.mount(5)
man page for information about the_netdev
mount option.
Additional resources
-
systemd.mount(5)
man page
3.10. Changing the compression settings on an LVM-VDO volume
By default, the compression of a VDO pool logical volume (LV) is enabled. To save CPU usage, you can disable it. Enable or disable compression by using the lvchange
command.
Prerequisites
- An LVM-VDO volume exists on your system.
Procedure
Check the compression status for your logical volumes:
# lvs -o+vdo_compression,vdo_compression_state LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert VDOCompression VDOCompressionState vdo_name vg_name vwi-a-v--- 1.00t vpool0 0.00 enabled online vpool0 vg_name dwi------- <15.00g 20.03 enabled online
Disable the compression for VDOPoolLV:
# lvchange --compression n vg-name/vdopoolname
If you want to enable the compression, use the
y
option instead ofn
.
Verification
View the current status of compression:
# lvs -o+vdo_compression,vdo_compression_state LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert VDOCompression VDOCompressionState vdo_name vg_name vwi-a-v--- 1.00t vpool0 0.00 offline vpool0 vg_name dwi------- <15.00g 20.03 offline
Additional resources
-
lvmvdo(7)
man page -
lvcreate(8)
man page
3.11. Changing the deduplication settings on an LVM-VDO volume
By default, the deduplication of a VDO pool logical volume (LV) is enabled. To save memory, you can disable deduplication. Enable or disable deduplication by using the lvchange
command.
Because of the way that VDO handles ongoing parallel I/O operations, a VDO volume continues to identify duplicate data within those operations. For example, if a VM clone operation is in progress and a VDO volume has many duplicate blocks in close proximity, then the volume can still achieve some amount of space savings by using deduplication. The index state of the volume does not affect the process.
Prerequisites
- An LVM-VDO volume exists on your system.
Procedure
Check the deduplication status for your logical volumes:
# lvs -o+vdo_deduplication,vdo_index_state LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert VDODeduplication VDOIndexState vdo_name vg_name vwi-a-v--- 1.00t vpool0 0.00 enabled online vpool0 vg_name dwi------- <15.00g 20.03 enabled online
Disable the deduplication for VDOPoolLV:
# lvchange --deduplication n vg-name/vdopoolname
If you want to enable the deduplication, use the
y
option instead ofn
.
Verification
View the current status of deduplication:
# lvs -o+vdo_deduplication,vdo_index_state LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert VDODeduplication VDOIndexState vdo_name vg_name vwi-a-v--- 1.00t vpool0 0.00 closed vpool0 vg_name dwi------- <15.00g 20.03 closed
Additional resources
-
lvmvdo(7)
man page -
lvcreate(8)
man page
3.12. Managing thin provisioning with Virtual Data Optimizer
It is possible to configure a thin-provisioned VDO volume to prepare for future expansion of the physical space, in order to address a condition where the physical space usage of the VDO volume is approaching 100%. Instead of using -l 100%FREE
in the lvcreate
operation, for example, use '95%FREE' to ensure that there is some reserved space for recovery later on if needed. This procedure describes how to resolve the following issues:
- The volume runs out of space
- The file system enters read-only mode
- ENOSPC reported by the volume
The best way to address high physical space usage on a VDO volume is to delete unused files, and discard the blocks used by these unused files either by using online discard or the fstrim
program. The physical space of a VDO volume can only be grown to 8192 slabs that is 16 TB for a VDO volume with the default slab size of 2 GB, or 256 TB for a VDO volume with the maximal slab size of 32 GB.
In all of the following steps, replace myvg and myvdo with the volume group and VDO name respectively.
Prerequisites
- Install the VDO software. For more information, see Installing VDO.
- An LVM volume group with free storage capacity exists on your system.
-
A thin-provisioned VDO volume using the
lvcreate --type vdo --name myvdo myvg -L logical-size-of-pool --virtualsize virtual-size-of-vdo
command. For more information, see Creating an LVM-VDO volume.
Procedure
Determine the optimal logical size for a thin-provisioned VDO volume
# vdostats myvg-vpool0-vpool Device 1K-blocks Used Available Use% Space saving% myvg-vpool0-vpool 104856576 29664088 75192488 28% 69%
To calculate the space savings ratio, use the following formula:
Savings ratio = 1 / (1 - Space saving%)
In this example,
-
there is approximately a
3.22:1
space savings ratio on a data set of about 80 GB. - Multiplying the data set size by the ratio would yield a potential logical size of 256 GB if more data with the same space savings were written to the VDO volume.
- Adjusting this number downward to 200 GB yields a logical size with a safe margin of free physical space, given the same space savings ratio.
-
there is approximately a
Monitor the free physical space in a VDO volume:
# vdostats myvg-vpool0-vpool
This command can be executed periodically to provide monitoring of the used and free physical space of the VDO volume.
Optional: View the warnings on physical space usage on a VDO volume by using the available
/usr/share/doc/vdo/examples/monitor/monitor_check_vdostats_physicalSpace.pl
script:# /usr/share/doc/vdo/examples/monitor/monitor_check_vdostats_physicalSpace.pl myvg-vpool0-vpool
When creating a VDO volume, the
dmeventd
monitoring service monitors the usage of physical space in a VDO volume. This is enabled by default when a VDO volume is created or started.Use the
journalctl
command to view the output ofdmeventd
in the logs while monitoring a VDO volume:lvm[8331]: Monitoring VDO pool myvg-vpool0-vpool. ... lvm[8331]: WARNING: VDO pool myvg-vpool0-vpool is now 84.63% full. lvm[8331]: WARNING: VDO pool myvg-vpool0-vpool is now 91.01% full. lvm[8331]: WARNING: VDO pool myvg-vpool0-vpool is now 97.34% full.
Remediate VDO volumes that are almost out of available physical space. When it is possible to add a physical space to a VDO volume, but the volume space is full before it can be grown, it may be necessary to temporarily stop I/O to the volume.
To temporarily stop I/O to the volume, execute the following steps, where VDO volume myvdo contains a file system mounted on the /users/homeDir path:
Freeze the filesystem:
# xfs_freeze -f /users/homeDir # vgextend myvg /dev/vdc2 # lvextend -l new_size myvg/vpool0-name # xfs_freeze -u /users/homeDir
Unmount the filesystem:
# umount /users/homeDir # vgextend myvg /dev/vdc2 # lvextend -l new_size myvg/vpool0-name # mount -o discard /dev/myvg/myvdo /users/homeDir
NoteUnmounting or freezing a filesystem with cached data will incur a write of the cached data, which may fill the physical space of the VDO volume. Consider the maximum amount of cached filesystem data when setting a monitoring threshold for free physical space on a VDO volume.
Blocks that are no longer used by a file system can be cleaned up by using the
fstrim
utility. Executingfstrim
against a mounted file system on top of a VDO volume may result in increased free physical space for that volume. Thefstrim
utility will send discards to the VDO volume, which are then used to remove references to the previously used blocks. If any of those blocks are single-referenced, the physical space will be available to use.Check VDO stats to see what the current amount of free space is:
# vdostats --human-readable myvg-vpool0-vpool Device Size Used Available Use% Space saving% myvg-vpool0-vpool 100.0G 95.0G 5.0G 95% 73%
Discard unused blocks:
# fstrim /users/homeDir
View the free physical space of the VDO volume:
# vdostats --human-readable myvg-vpool0-vpool Device Size Used Available Use% Space saving% myvg-vpool0-vpool 100.0G 30.0G 70.0G 30% 43%
In this example, after executing
fstrim
on the file system, the discards were able to return 65G of physical space to use in the VDO volume.NoteDiscarding volumes with lower levels of deduplication and compression will have a possibility of reclaiming physical space than discarding volumes with higher levels of deduplication and compression. A volume that has high levels of deduplication and compression may potentially require a more extensive cleanup to reclaim physical space than just simply discarding already unused blocks.