Managing Layered Storage With Stratis In Linux – RHEL 8/CentOS 8

In this study, you will learn what stratis in Linux is and how to configure stratis in Linux.

UNDERSTANDING THE SUBJECT MATTER

What Is Stratis In Linux

Stratis is a new local storage management technology in Linux. Stratis was introduced in RHEL 8 to further simplify storage solutions.

Compared to the traditional way of managing storage, and the LVM technology, storage solution has become easier with stratis.

Though stratis is still in its preview state and has its shortcomings, for example, having to be restricted to only one filesystem, xfs, as time goes on, storage management will be more flexible with stratis.

Using Stratis in Linux comes with great and easy configuration.

The Stratis technology has leveraged on the basic Red Hat Storage solutions such as the device-mapper, LVM, xfs, etc. As a matter of fact, if you know the LVM technology, you will easily grab the Stratis technology as well. The concept is similar.

For a better understanding, let’s analyze the Stratis technology with the diagram below

From the diagram above, you can see that the stratis technology ends at creating stratis file system which our data sits on.

Just as we have a volume group logically created from a block device or group of block devices in LVM, in stratis also, a stratis pool will be created from a block device or group of block devices, after which one or more stratis file systems will be created from a stratis pool.

A block device can be a LUN, partition, raid, etc.

What Is a Stratis filesystem

A stratis file system is a file system created from a stratis pool of block devices. A stratis file system as of when this article is written can only be formatted with the xfs filesystem and it is by default.

One advantage of stratis is that it uses a thin provisioning technology. The stratis file system automatically extends as the file system gets filled provided there is still free space in the pool compared to LVM where one will need to manually extend the Logical volume and the filesystem when it gets filled up.

If there is no free space in the stratis pool, a block device can be added to extend the pool size.

Stratis runs as a daemon called stratisd. The daemon must be up and running before stratis can be used.

To use stratis, the stratisd daemon has to be installed on your system, started and enabled.

Let’s see how all of these can be done below.


How To Verify If Stratisd Daemon Is Running

To Verify if stratisd is running, use the command,

[root@DRDEV1 ~]# systemctl status stratisd.service

● stratisd.service - Stratis daemon
   Loaded: loaded (/usr/lib/systemd/system/stratisd.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2020-11-16 15:50:15 GMT; 1 day 21h ago

How To Install stratisd In Linux

To install stratisd and its utilities, use the command,

[root@DRDEV1 ~]# yum install stratisd stratis-cli

Updating Subscription Management repositories.
Red Hat Enterprise Linux 8 for x86_64 - AppStream (RPMs)         4.3 kB/s | 4.5

How To Start stratisd in Linux

To start stratisd daemon, use the command,

[root@DRDEV1 ~]# systemctl start stratisd

How To Enable stratisd In Linux

To enable stratisd in Linux, use the command,

[root@DRDEV1 ~]# yum enable stratisd

How To Create a Stratis Pool In Linux

To create a stratis pool with one block device, use the command,

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

To create a stratis pool with more than one device, use the command,

#  stratis pool create <pool-name> /dev/<block-device1> /dev/<block-device2>

For example, to create the stratis pool with a name, (tekhour_pool) on the device, (sde and sdf), use the command,

[root@DRDEV1 ~]# stratis pool create tekhour_pool /dev/sde /dev/sdf

Verify that the stratis pool has been created.

[root@DRDEV1 ~]# stratis pool list

NOTE: When using stratis in Linux, the block devices should not contain a partition table on them.

You can verify by using the command,

# blkid -p /dev/<block-device>

If there is a partition table on any of the block devices, use the command below to clean up the disk

# wipefs -a /dev/<block-device>

OR

# shred -vfz -n 10 /dev/<block-device>

How To Delete / Remove a Stratis Pool In Linux

To delete a stratis pool in Linux, use the command,

# stratis pool destroy <pool-name>

For example, to delete a stratis pool with the name, (tekhour_pool), take the following steps.

1. unmont all the filesystems associated with the pool

[root@DRDEV1 ~]# umount /stratis/filesystem1
[root@DRDEV1 ~]# umount /stratis/filesystem2

2. Delete all the filesystems associated with the pool.

[root@DRDEV1 ~]# stratis filesystem destroy <pool-name> filesystem1 filesystem2

3. Delete the stratis pool

[root@DRDEV1 ~]# stratis pool destroy tekhour_pool

How To Add a Block Device To a Stratis pool / How To extend a Stratis Pool In Linux

To extend a stratis pool or add a block device to a stratis pool in Linux, use the command,

# stratis pool add-data <pool-name> </dev/block-device>

For example, to extend the stratis pool, (tekhour_pool) with the device (sdg), use the command,

[root@DRDEV1 ~]# stratis pool add-data tekhour_pool /dev/sdg

How To List Stratis Pools On The System In Linux

To list the available stratis pool on your Linux system, use the command,

[root@DRDEV1 ~]# stratis pool list

How To Create a Stratis Filesystem

To create a stratis file system, use the command,

# stratis filesystem create <pool-name> <filesystem>

OR

# stratis fs create <pool-name> <filesystem>

For example, to create a stratis file system with the name (tekour_fs) on the stratis pool (tekhour_pool), use the command,

[root@DRDEV1 ~]# stratis filesystem create tekhour_pool tekhour_fs

Verify if the stratis filesystem has been created.

[root@DRDEV1 ~]# stratis fs list

To restrict it to a pool name, use the command,

[root@DRDEV1 ~]# stratis fs list <pool-name>

How To List Stratis Filesystems On The System In Linux

To list the available stratis filesystems on a Linux system, use the command,

# stratis fs list

OR

# stratis filesystem list

To narrow it down to a particular pool, use the command

# stratis fs list <pool-name>

How To Remove or Delete a Stratis Filesystem In Linux

To delete a stratis filesystem in Linux, use the command,

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

For example, to delete a stratis filesystem with the name (tekhour_fs), take the following steps.

1. unmount all the filesystem sassociated with the pool.

[root@DRDEV1 ~]# umount /stratis/tekhour_fs

2. Delete the filesystem

root@DRDEV1 ~]# stratis filesystem destroy <pool-name> tekhour_fs

3. Verify that the filesystem has been deleted

[root@DRDEV1 ~]# stratis filesystem list <pool-name>

How To Create a Stratis Snapshot From a Stratis Filesystem In Linux

To create a stratis snapshot, use the command,

# stratis filesystem snapshot <pool-name> <filesystem-name> <snapshot-name>

For example, to create a snapshot (tekhour_snap) from the filesystem (tekhour_fs), and the pool (tekhour_pool), use the command,

[root@DRDEV1 ~]# stratis filesystem snapshot tekhour_pool tekhour_fs tekhour_snapshot

Verify if the snapshot has been created

[root@DRDEV1 ~]# stratis filesystem list tekhour_pool

How To Delete or remove a Stratis Snapshot In Linux

To delete or remove a stratis snapshot in Linux, use the command,

# stratis filesystem destroy <pool-name> <snapshot-name>

If the snapshot is mounted, unmount the snapshot by using the command,

# umount /stratis/<pool-name>/<snapshot-name>

How To Persistently Mount a Stratis filesystem In Linux

To persistently mount a stratis filesystem in Linux, take the following steps.

1. get the stratis filesystem UUID by using the command,

 lsblk --output=UUID /stratis/<pool-name>/<filesystem-name>

OR

blkid -p /stratis/<pool-name>/<filesystem-name>

2. input the UUID in the fstab file.

UUID=8bd74749-6c5a-4d25-bc1d-c033d60663e4 /mount-point    xfs    defaults,x-systemd.requires=stratisd.service 0 0

ACTION TIME

Having understood the stratis concept and terminologies, we should create a stratis filesystem/volume with an example.

Step By Step On How To Create a Volume / Filesystem In Linux Using Stratis

Create a filesystem from the devices sdb and sdc using stratis, mount it on /data22 and make it persistent accross reboot.

1. Verify if stratisd and stratis-cli are installed.

[root@DRDEV1 ~]# rpm -q stratisd stratis-cli

stratisd-2.1.0-1.el8.x86_64
stratis-cli-2.1.1-6.el8.noarch

2. install stratisd and its utilities if they aren’t installed

[root@DRDEV1 ~]# yum install stratisd stratis-cli

Updating Subscription Management repositories.
Red Hat Enterprise Linux 8 for x86_64 - AppStream (RPMs)         4.3 kB/s | 4.5 kB     00:01
Red Hat CodeReady Linux Builder for RHEL 8 x86_64 (RPMs)         5.9 kB/s | 4.5 kB     00:00
..............

3. verify stratisd status

[root@DRDEV1 ~]# systemctl status stratisd

● stratisd.service - Stratis daemon
   Loaded: loaded (/usr/lib/systemd/system/stratisd.service; enabled; vendor preset: enabled)
   Active: inactive (dead)
     Docs: man:stratisd(8)

4. if stratisd is not started, start stratisd service

[root@DRDEV1 ~]# systemctl start stratisd

5. enable startisd

[root@DRDEV1 ~]# systemctl enable stratisd

NB: you can use the command below to start and enable stratisd straightaway

# systemctl enable --now stratisd

6. verify stratisd again

[root@DRDEV1 ~]# systemctl status stratisd

● stratisd.service - Stratis daemon
   Loaded: loaded (/usr/lib/systemd/system/stratisd.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2020-11-16 15:50:15 GMT; 1min 1s ago
     Docs: man:stratisd(8)

7. create a stratis pool from the devices sdb and sdc

[root@DRDEV1 ~]# stratis pool create tekneed_pool /dev/sdb /dev/sdd

8. Verify that the pool has been created.

[root@DRDEV1 ~]# stratis pool list

Name                         Total Physical   Properties
tekneed_pool   5 GiB / 41.63 MiB / 4.96 GiB      ~Ca,~Cr

you can also verify the block devices the pool was created from

[root@DRDEV1 ~]# stratis blockdev list
[root@DRDEV1 ~]# stratis blockdev list tekneed_pool

Pool Name      Device Node   Physical Size   Tier
tekneed_pool   /dev/sdb              2 GiB   Data
tekneed_pool   /dev/sdd              3 GiB   Data

you can also do, lsblk

[root@DRDEV1 ~]# lsblk

9. create a stratis filesystem

[root@DRDEV1 ~]# stratis filesystem create tekneed_pool tekneed_fs

10. verify that the stratis filesystem has been created

[root@DRDEV1 ~]# stratis filesystem list

Pool Name      Name         Used      Created             Device                             UUID
tekneed_pool   tekneed_fs   546 MiB   Nov 16 2020 20:45   /stratis/tekneed_pool/tekneed_fs   8bd747496c5a4d25bc1dc033d60663e4
[root@DRDEV1 ~]#

11. create a mount point

[root@DRDEV1 ~]# mkdir /data22

12. Mount the filesystem

[root@DRDEV1 ~]# mount /stratis/tekneed_pool/tekneed_fs /data22

13. verify that the device has been mounted

[root@DRDEV1 ~]# df -h |grep data22

/dev/mapper/stratis-1-4edc930e626e4f30b7a4cfb0effbbaaa-thin-fs-8bd747496c5a4d25bc1dc033d60663e4  1.0T  7.2G 1017G   1% /data22

14. input the device UUID in the fstab file to make it persistent

get the filesystem UUID

[root@DRDEV1 ~]# lsblk --output=UUID /stratis/tekneed_pool/tekneed_fs

UUID
8bd74749-6c5a-4d25-bc1d-c033d60663e4

OR

[root@DRDEV1 ~]# blkid -p /stratis/tekneed_pool/tekneed_fs

/stratis/tekneed_pool/tekneed_fs: UUID="8bd74749-6c5a-4d25-bc1d-c033d60663e4" TYPE="xfs" USAGE="filesystem"

edit the fstab file

[root@DRDEV1 ~]# vim /etc/fstab
UUID=8bd74749-6c5a-4d25-bc1d-c033d60663e4 /data22    xfs    defaults,x-systemd.requires=stratisd.service 0 0

15. Do mount -a to ensure that the filesystem is properly mounted

[root@DRDEV1 ~]# mount -a

16. If you wish, you can restart your system

Let’s do a test.

From our explanation above, I have mentioned that the filesystem will automatically extend by itself, unlike the LVM technology where you will have to extend a logical volume and the filesystem.

Let’s put it into practice now.

1. Create a file called (tekneed_file) on the filesystem.

[root@DRDEV1 ~]# echo "This is tekneed file one" > /data22/tekneed_file
[root@DRDEV1 ~]# cat /data22/tekneed_file

2. verify the used filesystem size

[root@DRDEV1 ~]# stratis filesystem list tekneed_pool |grep tekneed_fs

tekneed_pool   tekneed_fs         546 MiB   Nov 16 2020 20:45   /stratis/tekneed_pool/tekneed_fs         8bd747496c5a4d25bc1dc033d60663e4
stratis in Linux

you can see that 546 MiB has been used.

3. Let’s add more files to the filesystem, about 2GB file

[root@DRDEV1 ~]# dd if=/dev/urandom of=/data22/tekneed_file bs=1M count=2048

4. Verify again if the filesystem automatically increase.

[root@DRDEV1 ~]# stratis filesystem list tekneed_pool |grep tekneed_fs
tekneed_pool   tekneed_fs         858 MiB   Nov 16 2020 20:45   /stratis/tekneed_pool/tekneed_fs         8bd747496c5a4d25bc1dc033d60663e4

so, you can see that a stratis filesystem automatically extends provided there is a free space in the pool.

You can also extend a stratis pool. Let’s see the step by step process of how to extend a stratis pool with an example.


How To Extend a Stratis Pool / Volume In Linux With Examples

*Extend the stratis pool with the name (tekneed_pool) with the device, sdc

1. verify that the pool exists.

[root@DRDEV1 ~]# stratis pool list
Name                        Total Physical   Properties
tekneed_pool   5 GiB / 1.41 GiB / 3.59 GiB      ~Ca,~Cr

2. Verify the block devices associated with the pool

[root@DRDEV1 ~]# stratis blockdev list tekneed_pool

Pool Name      Device Node   Physical Size   Tier
tekneed_pool   /dev/sdb              2 GiB   Data
tekneed_pool   /dev/sdd              3 GiB   Data

3. Add the block device to the stratis pool

[root@DRDEV1 ~]# stratis pool add-data tekneed_pool /dev/sdc

4. Verify that the pool has been added.

[root@DRDEV1 ~]# stratis blockdev list tekneed_pool

Pool Name      Device Node   Physical Size   Tier
tekneed_pool   /dev/sdb              2 GiB   Data
tekneed_pool   /dev/sdc              4 GiB   Data
tekneed_pool   /dev/sdd              3 GiB   Data
[root@DRDEV1 ~]# stratis pool list

Name                        Total Physical   Properties
tekneed_pool   9 GiB / 1.41 GiB / 7.59 GiB      ~Ca,~Cr

How To Remove a Block Device From a Stratis Pool With Examples

Unfortunately, as of when this article is written, there is no command to remove a block device from a stratis pool. (https://access.redhat.com/solutions/5041771).

Hence, make sure you plan before adding a block device to a startis pool.

You can drop your comments in the “leave a reply” box below when the command is available. I will be glad to learn from my fellow tekneeders. Thanks.

Moving forward, we will create a filesystem snapshot using stratis in Linux


How To Create a Filesystem Snapshot Using Stratis In Linux With Examples

Create a snapshot of the stratis filesystem with the name (tekneed_fs). The name of the snapshot should be (tekneed_snapshot).

N:B: creating a snapshot is creating an exact copy of a filesystem.

1. Verify that tekneed_fs exist.

[root@DRDEV1 ~]# stratis filesystem list |grep tekneed_fs

tekneed_pool   tekneed_fs         858 MiB   Nov 16 2020 20:45   /stratis/tekneed_pool/tekneed_fs         8bd747496c5a4d25bc1dc033d60663e4

2. create a snapshot of a stratis filesystem, use the command,

[root@DRDEV1 ~]# stratis filesystem snapshot tekneed_pool tekneed_fs tekneed_snapshot

3. Verify that the snapshot has been created.

[root@DRDEV1 ~]# stratis filesystem list

Pool Name      Name               Used      Created             Device                                   UUID
tekneed_pool   tekneed_fs         858 MiB   Nov 16 2020 20:45   /stratis/tekneed_pool/tekneed_fs         8bd747496c5a4d25bc1dc033d60663e4
tekneed_pool   tekneed_snapshot   858 MiB   Nov 19 2020 11:55   /stratis/tekneed_pool/tekneed_snapshot   686adc07361644cea9fb648fbc80e388

Let’s do a test

1. create a mount point for the snapshot.

[root@DRDEV1 ~]# mkdir /snapshot_mnt

2. mount the filesystem

[root@DRDEV1 ~]# mount /stratis/tekneed_pool/tekneed_snapshot /snapshot_mnt/

3. Verify that the filesystem has been mounted.

[root@DRDEV1 ~]# df -h |grep snapshot_mnt

/dev/mapper/stratis-1-4edc930e626e4f30b7a4cfb0effbbaaa-thin-fs-686adc07361644cea9fb648fbc80e388  1.0T  7.5G 1017G   1% /snapshot_mnt

4. Verify that the tekneed_file is present.

[root@DRDEV1 ~]# ls -l /snapshot_mnt/tekneed_file

-rw-r--r--. 1 root root 327155712 Nov 19 10:45 /snapshot_mnt/tekneed_file

To delete the snapshot, unmount the filesystem and delete the snapshot by using the commands below.

[root@DRDEV1 ~]# umount /snapshot_mnt
[root@DRDEV1 ~]# stratis filesystem destroy tekneed_pool tekneed_snapshot

In other articles on Linux storage, I will talk more on stratis in Linux.

Tutorial Video On Managing Layered Storage With Stratis In Linux

RHCSA 8 EX200 Exam Practice Question & Answer On Managing Stratis In Linux

Your feedback is welcomed. If you love others, you will share with others

Be the first to comment

Leave a Reply

Your email address will not be published.


*