Image
How to configure disk compression in Red Hat Enterprise Linux 8
Learn how to use the Virtual Data Optimizer (VDO) in RHEL 8 to compress files and maximize the space available on physical storage.
Compression allows you to reduce the size of a file. By decreasing use of the inodes table, it means more files and folders can be stored, maximizing the space available on physical storage. In Linux, system administrators have used tools such as zip, tar, gzip, bzip2, and other open source utilities for this task.
Red Hat Enterprise Linux (RHEL) 8 introduced the Virtual Data Optimizer (VDO). This system compresses data dynamically. VDO is integrated into Logical Volume Management (LVM) in RHEL 9, but in RHEL 8, it has its own special toolchain. I'll cover that in this article. In a future article, I'll look at using LVM2 to create VDO volumes on RHEL 9.
VDO uses two kernel modules, kvdo
and uds
, to implement a three-stage compression scheme:
- Zero-Block Elimination (or thin provisioning): First, it verifies a VDO device exists and can use the underlying physical storage as and when necessary. VDO locates all data blocks containing zero bytes and records this information in metadata. Non-zero blocks are passed on to the next phase.
- Deduplication: This phase ensures that multiple repeated copies of data are eliminated, leaving only distinct data blocks on disk.
- Compression: This last phase uses the
kvdo
kernel module to compress data blocks using the LZ4 compression algorithm.
Install VDO in RHEL 8
Install VDO in RHEL 8 by installing the relevant packages:
$ sudo yum install vdo kmod-kvdo -y
Enable VDO using the vdo
command, which is a userspace command for interacting with VDO. To create a VDO volume called my_vdo
, based on the physical disk /dev/sdb
, with the logical space of 100 GB:
$ sudo vdo create --name=my_vdo \
--device=/dev/sdb --vdoLogicalSize=100G
Use VDO
The --vdoLogicalSize
flag defines the size the VDO volume presents to users. It's usually larger than the actual physical storage. If left unspecified, by default, it has a 1:1 ratio to the physical storage.
To list the VDO volumes created on your system, use the list
subcommand:
$ sudo vdo list
For details on a specific VDO, use the status
subcommand:
$ sudo vdo status --name=my_vdo
[ Free download: Advanced Linux commands cheat sheet. ]
Next, format the VDO volume with the XFS filesystem (or the filesystem of your choice). You can also use LVM to manage the volume. Here is an mkfs
example:
$ sudo mkfs.xfs -K /dev/mapper/my_vdo
Run udevadm
to register the new device:
$ sudo udevadm settle
Finally, mount the volume using the mount
command:
$ sudo mount /dev/mapper/my_vdo /mnt
Update the /etc/fstab
file to set the mount options for the device:
$ sudo mount /dev/mapper/vdo_kvm /mnt
You can then update the /etc/fstab
file for the new device with the mount options. In the example above, the /etc/fstab
entry will be:
$ sudo vim /etc/fstab
/dev/mapper/vdo_kvm /mnt xfs defaults 0 0
[ Free eBook: Manage your Linux environment for success. ]
Use the vdostats
command to display data deduplication and compression details on the mounted VDO filesystem:
$ sudo vdostats --human-readable
Better compression
With VDO, you don't have to compress files manually to conserve space. Instead, space is maximized by dynamic compression as data is created and modified. If you don't have VDO enabled on your RHEL 8 system, give it a try! If you're using RHEL 9 already, stay tuned for my next article.
Image
Use this guide to integrate the flexibility, scalability, and increased features of LVM into your server storage strategies. Traditional partitioning is good, but LVM is better.
Image
Learn how to use rsyslog and systemd-journald to get information about what's happening on your system.
Image
Learn how to use operators to manipulate standard inputs and outputs on your Linux system.
Evans Amoany
I work as Unix/Linux Administrator with a passion for high availability systems and clusters. I am a student of performance and optimization of systems and DevOps. I have passion for anything IT related and most importantly automation, high availability, and security. More about me