How to Install Stratis to Manage Layered Local Storage on RHEL 8

Stratis is one of the new features that ships with RHEL 8 distribution. Stratis is a local storage management solution that focuses on simplicity and improved usability while at the same time providing access to advanced storage features. It uses the XFS file system and grants you access to advanced storage capabilities such as:

  • Thin provisioning
  • File system snapshots
  • Tiering
  • Pool-based management
  • Monitoring

Basically, Stratis is a storage pool that is created from one or more local disks or disk partitions. Stratis helps a System administrator set up and manage complex storage configurations.

Before we proceed further, let us have a look at some of the technical terms you are bound to bump into as we go along:

  • pool: A pool is made up of one or more block devices. The total size of the pool is equal to the sum total of the block devices.
  • blockdev: As you might have guessed it this refers to block devices such as disk partitions.
  • Filesystem: A filesystem is a thinly provisioned layer which does not come as a total fixed size. The filesystem’s actual size grows as data is added. Stratis automatically grows the size of the filesystem as data size nears the virtual size of the file system.

Block devices that you can use with Stratis include:

  1. LVM Logical Volumes
  2. LUKS
  3. SSDs (Solid State Drives)
  4. Device Mapper Multipath
  5. iSCSI
  6. HDDs (Hard Disk Drives)
  7. mdraid
  8. NVMe storage devices

Software Components of Stratis

Stratis provides 2 software utilities:

  • Stratis-cli: This is the command-line tool that ships with Stratis.
  • Stratisd daemon: This is a daemon that creates and manages block devices and plays a role in providing a DBUS API.

How to Install Stratis on RHEL 8

Having looked at what Stratis is and defined a few terminologies. Let’s now install and configure Stratis on RHEL 8 distribution (also works on CentOS 8).

Install Stratis on RHEL 8

Let’s see how you can install Stratis on your RHEL 8 system, log in as root user and run the command.

# dnf install stratisd stratis-cli
Install Stratis in RHEL 8
Install Stratis in RHEL 8

To find more information about the installed packages run the command.

# rpm -qi stratisd stratis-cli
Verify Stratis Installation
Verify Stratis Installation

After the successful installation of Stratis, start the service by running the command.

# systemctl enable --now stratisd

To check the status of Stratis, run the command.

# systemctl status stratisd
Check Stratis Status
Check Stratis Status

Create a Stratis Pool

To create a Stratis pool you need block devices that are not in use or mounted. Also, it is assumed that Stratisd service is up and running. Additionally, the block devices that you are going to use need to be at least 1 GB in size.

On our RHEL 8 system, we have four additional block devices: /dev/xvdb, /dev/xvdc, /dev/xvdd, /dev/xvde. To display the block devices, run the lsblk command.

# lsblk
List Block Devices
List Block Devices

None of these block devices should have a partition table. You can confirm this using the command.

# blkid -p /dev/xvdb
Confirm Disks Partition Table
Confirm Disks Partition Table

If you get no output, then it means that your block devices do not have any partition table residing on them. However, in the event that a partition table exists, you can wipe it using the command:

# wipefs -a /<device-path>

Create a Stratis Pool from One Block Device

You can create a Stratis pool from a single block device using the syntax.

# stratis pool create <pool-name> <block-device>

For example to create a pool from /dev/xvdb run the command.

# stratis pool create my_pool_1 /dev/xvdb

To confirm the created pool run.

# stratis pool list
Create Stratis Pool from One Device
Create Stratis Pool from One Device

Create a Stratis Pool from Multiple Block Devices

To create a pool from multiple devices, use the syntax below listing all the devices on one line.

# stratis pool create <pool_name> device-1 device-2 device-n

To create a pool from /dev/xvdc, /dev/xvdd and /dev/xvde run the command.

# stratis pool create my_pool_2 /dev/xvdc /dev/xvdd/ /dev/xvde

Once again, list the pools available using the command.

# stratis pool list

At this point, you should have 2 pools: my_pool_1 and my_pool_2.

Create Stratis Pool from Multiple Devices
Create Stratis Pool from Multiple Devices

As you can see above, the hard disk space occupied by pool my_pool_2 is thrice that of the first pool which we created from only one block device with a memory of 10GB.

Create a Filesystem from a Pool

Having created your filesystem, you can create a filesystem from one of the pools using the syntax.

# stratis fs create <poolname> <filesystemname>

For instance, to create filesystem-1 and filesystem-2 from my_pool_1 and my_pool_2 respectively run commands:

# stratis fs create my_pool_1 filesystem-1
# stratis fs create my_pool_2 filesystem-2
Create Filesystem from a Pool
Create Filesystem from a Pool

To view the newly created filesystems, run the command.

# stratis fs list
List Filesystems in a Pool
List Filesystems in a Pool

To narrow down the results of a file system to one pool, run the command:

# stratis fs list <poolname>

For instance, to check the filesystem in my_pool_2 run the command.

# stratis fs list my_pool_2
Check Filesystem in Pool
Check Filesystem in Pool

Now, if you run the lsblk command, the output should be somewhat similar to the sample output below.

# lsblk
List All Block Devices
List All Block Devices

Mounting a Stratis Filesystem

We are now going to mount the existing filesystems in order to access them. First, create the mount points.

For the filesystem in the first pool, run the command:

# mkdir /data
# mount /stratis/my_pool_1/filesystem-1 /data

For the second filesystem in the second pool, run the command.

# mkdir /block
# mount /stratis/my_pool_2/filesystem-2 /block
Mount Stratis Filesystems
Mount Stratis Filesystems

To verify the existence of the current mount points run df command:

# df -Th | grep  stratis
Verify Stratis Mount Points
Verify Stratis Mount Points

Perfect! We can clearly see that our mount points are present.

Persistently Mount Stratis Filesystems

The mount points that we have just created cannot survive a reboot. To make them persistent, first obtain the UUID of each of the filesystems:

# blkid -p /stratis/my_pool_1/filesystem-1
# blkid -p /stratis/my_pool_2/filesystem-2
Find Filesystem UUID
Find Filesystem UUID

Now proceed and copy the UUID’s and mount point options to /etc/fstab as shown.

# echo "UUID=c632dcf5-3e23-46c8-82b6-b06a4cc9d6a7 /data xfs defaults 0 0" | sudo tee -a /etc/fstab
# echo "UUID=b485ce80-be18-4a06-8631-925132bbfd78 /block xfs defaults 0 0" | sudo tee -a /etc/fstab
Add Mount Points to fstab File
Add Mount Points to fstab File

For the system to register the new configuration run the command:

# systemctl daemon-reload

To verify the configuration works as expected, mount the filesystems.

# mount /data
# mount /block

Removing a Stratis Filesystem

To remove a filesystem, you need to, first of all, unmount the file system as shown.

# umount /mount-point

In this case, we shall have.

# umount /data

To destroy the filesystem, use the syntax:

# stratis filesystem destroy <poolname> <filesystem-name>

So, we shall have:

# stratis filesystem destroy my_pool_1 filesystem-1
Remove Stratis Filesystem
Remove Stratis Filesystem

To confirm the removal of the filesystem, issue the command.

# stratis filesystem list my_pool_1
Verify Stratis Filesystem Removal
Verify Stratis Filesystem Removal

From the output, we can clearly see that the filesystem associated with my_pool_1 has been deleted.

Adding a Disk to an Existing Stratis Pool

You can add a disk to an existing pool using the command:

# stratis pool add-data <poolname> /<devicepath>

For example, to add an additional disk /dev/xvdf, to my_pool_1, run the command:

# stratis pool add-data my_pool_1 /dev/xvdf
Add Disk to Existing Stratis Pool
Add Disk to Existing Stratis Pool

Notice that the size of my_pool_1 has double in size after adding the extra volume.

Create Stratis Snapshots

A snapshot is a thinly provisioned read and writes a copy of a filesystem at a given point in time.

To create a snapshot, run the command:

# stratis fs snapshot <poolname> <fsname> <snapshotname>

In this case, the command will be:

# stratis fs snapshot my_pool_2 filesystem-2 mysnapshot

You can append the data attribute -$(date +%Y-%m-%d) to the snapshot add the date tag as shown in the screenshot below.

To verify the creation of the snapshot, run the command:

# stratis filesystem list <poolname>

In this case, the command will be:

# stratis filesystem list my_pool_2
Create Stratis Filesystem Snapshots
Create Stratis Filesystem Snapshots

Reverting to a Previous Snapshot Using a Filesystem

To revert a Stratis filesystem to a previously created snapshot, first, unmount and destroy the original filesystem.

# umount /stratis/<poolname>/filesystem

In our scenario, this will be.

# umount /stratis/my_pool_2/filesystem-2

Then create a copy of the snapshot using the original file system:

# stratis filesystem snapshot <poolname> filesystem-snapshot filesystem

The command will be:

# stratis filesystem snapshot my_pool_2 mysnapshot-2019-10-24 block

Finally, mount the snapshot.

# mount /stratis/my-pool/my-fs mount-point

Removing a Stratis Snapshot

To remove the snapshot, first, unmount the snapshot.

# unmount /stratis/my_pool_2/mysnapshot-2019-10-24
Unmount Stratis Snapshot
Unmount Stratis Snapshot

Next, proceed and destroy the snapshot:

# stratis filesystem destroy my_pool_2 mysnapshot-2019-10-24
Remove Stratis Snapshot
Remove Stratis Snapshot

Removing a Stratis Pool

To remove a Stratis pool, follow the simple steps below.

1. List the filesystems that exist in the pool.

# stratis filesystem list <poolname>

2. Next, unmount all the filesystems in the pool.

# umount /stratis//filesystem-1
# umount /stratis//filesystem-2
# umount /stratis//filesystem-3

3. Destroy the filesystems.

# stratis filesystem destroy <poolname> fs-1 fs-2

4. And then, get rid of the pool.

# stratis pool destroy poolname

In this case, the syntax will be.

# stratis pool destroy my_pool_2
Remove Stratis Pool
Remove Stratis Pool

You can verify the pool list again.

# stratis pool list

Finally, remove the entries in the /etc/fstab for the filesystems.

We have come to the end of the guide. In this tutorial, we shed light on how you can install and use Stratis to manage layered local storage on RHEL. We do hope you found it useful. Give it a shot and let us know how it went.

Hey TecMint readers,

Exciting news! Every month, our top blog commenters will have the chance to win fantastic rewards, like free Linux eBooks such as RHCE, RHCSA, LFCS, Learn Linux, and Awk, each worth $20!

Learn more about the contest and stand a chance to win by sharing your thoughts below!

James Kiarie
This is James, a certified Linux administrator and a tech enthusiast who loves keeping in touch with emerging trends in the tech world. When I'm not running commands on the terminal, I'm taking listening to some cool music. taking a casual stroll or watching a nice movie.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

1 Comment

Leave a Reply

Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.