Image
![IT Automation ebook](/sysadmin/sites/default/files/styles/image_cta/public/2021-07/SysAdminGuidetoITAutomation-e-book-medium.jpg?itok=8_5VlQhF)
Photo by Anete Lusina from Pexels
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:
kvdo
kernel module to compress data blocks using the LZ4 compression algorithm.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
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
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.
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