How to Install Stratis to Manage Local Storage on RedHat8

How to Install Stratis to Manage Local Storage on RedHat8

Stratis is a local storage management solution for Linux Operating System and aims to ease the work of a system administrator by advanced storage options like snapshots, thin provisioning, pool-based management, monitoring, Tiering, etc. apart from being very simple to use.

Stratis is a user-space daemon that configures and monitors existing components from Linux’s device-mapper subsystem, as well as the XFS filesystem. Stratis Pool which is the central attraction of the Stratis tool is a collection of one or more local disks or partitions. Once the pool is created, administrators can create volumes.

Currently, Stratis supports block devices based on LVM Logical Volumes, mdraid, dm-multipath, iSCSI, and LUKS (crypto), as well as hard drives, SSDs, and NVMe storage devices.

Stratis of Elements
Stratis of Elements

Stratis Layers

Internally, Stratis uses the Backstore subsystem to manage the block devices, and the Thinpool subsystem to manage the pools. The Backstore subsystem has a data tier that maintains the on-disk metadata on block devices and detects and corrects data corruption. The cache tier uses high-performance block devices to act as a cache on top of the data tier.

The Thin pool subsystem manages the thin-provisioned volumes associated with the Stratis filesystems. This subsystem uses the dm-thin device-mapper driver to replace LVM on the virtual volume sizing and management. dm-thin creates volumes with a large virtual size, formatted with XFS, but with a small physical size. As the physical size nears full, Stratis enlarges it automatically.

stratis of layers
Stratis of Layers

Features:

  • Thin provisioning
  • Filesystem snapshots
  • Pool-based management
  • Monitoring

Stratis Terminologies:

When working with Stratis, you’ll often come across the following terminologies:

  • blockdev: This is a block device, such as a disk or a disk partition.
  • pool: A pool is composed of one or more block devices with a  fixed total size, equal to the size of the block devices.
  • filesystem: Each pool can contain one or more file systems, which store files. A filesystem does not have a fixed total size since it is thinly provisioned.  If the size of the data approaches the virtual size of the file system, Stratis grows the thin volume and the file system automatically.

Stratis Software components:

Stratis provides two software components:

  • stratisd daemon: This manages collections of block devices and provides a D-Bus API.
  • stratis-cli: This provides a command-line tool stratis which itself uses the D-Bus API to communicate with stratisd.

Step 1: Install Stratis on RHEL 8 / CentOS 8

RHEL 8 is distributed with stratisd and stratis-cli which can be easily installed using the yum package management tool.

[root@redaix ~]# yum install stratisd stratis-cli -y
Updating Subscription Management repositories.
Last metadata expiration check: 0:50:34 ago on Sun 31 May 2020 04:53:08 AM PDT.
Dependencies resolved.
===============================================================================================================================================================
 Package                                          Architecture           Version                        Repository                                        Size
===============================================================================================================================================================
Installing:
 stratis-cli                                      noarch                 2.0.0-1.el8                    rhel-8-for-x86_64-appstream-rpms                  60 k
 stratisd                                         x86_64                 2.0.0-4.el8                    rhel-8-for-x86_64-appstream-rpms                 1.2 M
Installing dependencies:
 python3-dbus-client-gen                          noarch                 0.4-1.el8                      rhel-8-for-x86_64-appstream-rpms                  26 k
 python3-dbus-python-client-gen                   noarch                 0.7-3.el8                      rhel-8-for-x86_64-appstream-rpms                  28 k
 python3-dbus-signature-pyparsing                 noarch                 0.03-2.el8                     rhel-8-for-x86_64-appstream-rpms                  19 k
 python3-into-dbus-python                         noarch                 0.06-2.el8                     rhel-8-for-x86_64-appstream-rpms                  27 k
 python3-justbases                                noarch                 0.9-6.el8                      rhel-8-for-x86_64-appstream-rpms                  45 k
 python3-justbytes                                noarch                 0.11-2.el8                     rhel-8-for-x86_64-appstream-rpms                  40 k

Transaction Summary
===============================================================================================================================================================
Install  8 Packages

You can get full package details using the rpm command:

[root@redaix ~]# rpm -qi stratisd stratis-cli
Name        : stratisd
Version     : 2.0.0
Release     : 4.el8
Architecture: x86_64
Install Date: Sun 31 May 202005:44:10 AM PDT
Group       : Unspecified
Size        : 4037577
License     : MPLv2.0
Signature   : RSA/SHA256, Tue 19 Nov 201909:19:51 AM PST, Key ID 199e2f91fd431d51
Source RPM  : stratisd-2.0.0-4.el8.src.rpm
Build Date  : Tue12 Nov 201906:21:20 AM PST
Build Host  : x86-vm-08.build.eng.bos.redhat.com
Relocations : (notrelocatable)
Packager    : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>
Vendor      : Red Hat, Inc.
URL         : https://github.com/stratis-storage/stratisd
Summary     : Daemon that manages block devices to create filesystems
Description :
Daemon that manages block devices to create filesystems.
Name        : stratis-cli
Version     : 2.0.0
Release     : 1.el8
Architecture: noarch
Install Date: Sun 31 May 202005:44:13 AM PDT
Group       : Unspecified
Size        : 184831
License     : ASL2.0
Signature   : RSA/SHA256, Tue 19 Nov 201909:19:46 AM PST, Key ID 199e2f91fd431d51
Source RPM  : stratis-cli-2.0.0-1.el8.src.rpm
Build Date  : Sun10 Nov 201909:37:36 AM PST
Build Host  : ppc-062.build.eng.bos.redhat.com
Relocations : (notrelocatable)
Packager    : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>
Vendor      : Red Hat, Inc.
URL         : https://github.com/stratis-storage/stratis-cli
Summary     : Command-line tool for interacting with the Stratis daemon
Description :
stratis provides a command-line interface (CLI) for
interacting with the Stratis daemon, stratisd. stratis
interacts with stratisd via D-Bus.

Step 2: Start Stratis services:

After installing Stratis packages, you’ll need to start the service and enable it.

[root@redaix ~]# systemctl start stratisd.service
[root@redaix ~]# systemctl enable stratisd.service --now

Step 3: Creating a Stratis pool

For this, you’ll require block devices which are not in use or mounted to create Stratis pool from. The block devices should be at least 1 GiB in size each.

[root@redaix ~]# lsblk
NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sr0          11:0    1 1024M  0 rom
nvme0n1     259:0    0   20G  0 disk
├─nvme0n1p1 259:1    0  300M  0 part /boot
├─nvme0n1p2 259:2    0    2G  0 part [SWAP]
└─nvme0n1p3 259:3    0 17.7G  0 part /
nvme0n2     259:4    0   20G  0 disk
nvme0n3     259:5    0    5G  0 disk
nvme0n4     259:6    0    5G  0 disk

I’ll create the first pool with single block device nvme0n2 and the other pool with two block devices nvme0n3 & nvme0n4

These block devices should not have a partition table, confirm with:

[root@redaix ~]# blkid -p /dev/nvme0n2
/dev/nvme0n2: UUID="3ddbc7bb-d3a2-4a38-88da-579cbfa7edaa" TYPE="vdo" USAGE="other"

If it has a partition table and you want to use it, first clear a device so that it can be used by Stratis.

[root@redaix ~]# wipefs -a /dev/nvme0n2
/dev/nvme0n2: 8 bytes were erased at offset 0x00000000 (vdo): 646d 76646f 303031
[root@redaix ~]# blkid -p /dev/nvme0n2
[root@redaix ~]# blkid -p /dev/nvme0n3
[root@redaix ~]# blkid -p /dev/nvme0n4
[root@redaix ~]#

Create a pool with one block device:

To create a pool with one block device /dev/nvme0n2 use:

[root@redaix ~]# stratis pool create mypool1 /dev/nvme0n2

List available pools with:

[root@redaix ~]# stratis pool list
Name                     Total Physical
mypool1  20 GiB / 37.64 MiB / 19.96 GiB

Step 4: Creating a filesystem from the pool

Once you have your pools ready, you can create a Stratis filesystem on a pool using the syntax:

#stratis fs create <pool_name> <filesystem_name>

Create a filesystem on mypool1

[root@redaix ~]# stratis fs create mypool1 myfs

Create filesystem on mypool2

[root@redaix ~]# stratis fs create mypool2 data
[root@redaix ~]# stratis fs create mypool2 web

To list created filesystems, use:

[root@redaix ~]# stratis fs list
Pool Name  Name  Used     Created            Device                 UUID
mypool1    myfs  546 MiB  May 31 2020 07:18  /stratis/mypool1/myfs  5cd703ee68224195aad2060c5d9ae9d1
mypool2    data  546 MiB  May 31 2020 07:20  /stratis/mypool2/data  f0a95a27dfe14d388d8b4724fd15ffc0
mypool2    web   546 MiB  May 31 2020 07:20  /stratis/mypool2/web   4c8a7463d0fc45628591d9e9ea545804

You can also limit output to specified pool:

[root@redaix ~]# stratis fs list mypool2
Pool Name  Name  Used     Created            Device                 UUID
mypool2    data  546 MiB  May 31 2020 07:20  /stratis/mypool2/data  f0a95a27dfe14d388d8b4724fd15ffc0
mypool2    web   546 MiB  May 31 2020 07:20  /stratis/mypool2/web   4c8a7463d0fc45628591d9e9ea545804

Step 5: Mounting a Stratis file system

To mount the file system, use the entries that Stratis maintains in the /dev/stratis/ directory. See examples below:

Create directories, /myfs. /data & /web

[root@redaix ~]# mount /stratis/mypool1/myfs /myfs
[root@redaix ~]# mount /stratis/mypool2/data /data
[root@redaix ~]# mount /stratis/mypool2/web /web

Check current mount points

[root@redaix ~]# df -Th | grep stratis
/dev/mapper/stratis-1-2a95bb640590433f864b4d322ddece10-thin-fs-5cd703ee68224195aad2060c5d9ae9d1 xfs       1.0T  7.2G 1017G   1% /myfs
/dev/mapper/stratis-1-5dc6d5aafd83443da8bd6adcecaf0b88-thin-fs-f0a95a27dfe14d388d8b4724fd15ffc0 xfs       1.0T  7.2G 1017G   1% /data
/dev/mapper/stratis-1-5dc6d5aafd83443da8bd6adcecaf0b88-thin-fs-4c8a7463d0fc45628591d9e9ea545804 xfs       1.0T  7.2G 1017G   1% /web

Add a persistent mount point to /etc/fstab

To configure persistent mount, get the UUID of the filesystem.

[root@redaix ~]# blkid -p /stratis/mypool1/myfs
/stratis/mypool1/myfs: UUID="5cd703ee-6822-4195-aad2-060c5d9ae9d1"TYPE="xfs"USAGE="filesystem"
[root@redaix ~]# blkid -p /stratis/mypool2/data
/stratis/mypool2/data: UUID="f0a95a27-dfe1-4d38-8d8b-4724fd15ffc0"TYPE="xfs"USAGE="filesystem"
[root@redaix ~]# blkid -p /stratis/mypool2/web
/stratis/mypool2/web: UUID="4c8a7463-d0fc-4562-8591-d9e9ea545804"TYPE="xfs"USAGE="filesystem"

Copy the printed UUID and add mount options to /etc/fstab file

[root@redaix ~]# echo "UUID=5cd703ee-6822-4195-aad2-060c5d9ae9d1 /myfs xfs defaults,x-systemd.requires=stratisd.service 0 0" | sudo tee -a /etc/fstab
UUID=5cd703ee-6822-4195-aad2-060c5d9ae9d1 /myfs xfs defaults,x-systemd.requires=stratisd.service 00

[root@redaix ~]# echo "UUID=f0a95a27-dfe1-4d38-8d8b-4724fd15ffc0 /data xfs defaults,x-systemd.requires=stratisd.service 0 0" | sudo tee -a /etc/fstab
UUID=f0a95a27-dfe1-4d38-8d8b-4724fd15ffc0 /data xfs defaults,x-systemd.requires=stratisd.service 00

[root@redaix ~]# echo "UUID=4c8a7463-d0fc-4562-8591-d9e9ea545804 /web xfs defaults,x-systemd.requires=stratisd.service 0 0" | sudo tee -a /etc/fstab
UUID=4c8a7463-d0fc-4562-8591-d9e9ea545804 /web xfs defaults,x-systemd.requires=stratisd.service 00

Stratis Administration Tasks & Commands

  • Add a disk to an existing pool
  • Create Stratis snapshots
  • Revert a Stratis file system to a previous snapshot
  • Removing a Stratis snapshot
  • Renaming  a file system
  • Removing a Stratis pool

Add a disk to an existing pool

Verify present disks

[root@redaix ~]# stratis blockdev
Pool Name  Device Node   Physical Size  Tier
mypool2    /dev/nvme0n3          5 GiB  Data
mypool2    /dev/nvme0n4          5 GiB  Data

To add another disk to the pool, use:

[root@redaix ~]# stratis pool add-data mypool2 /dev/nvme0n2

Verify post verification:

[root@redaix ~]# stratis blockdev
Pool Name  Device Node   Physical Size  Tier
mypool2    /dev/nvme0n2         20 GiB  Data
mypool2    /dev/nvme0n3          5 GiB  Data
mypool2    /dev/nvme0n4          5 GiB  Data

Create Stratis snapshots

Stratis Snapshot is a read/writeable thinly provisioned point-in-time copy of the source FS.

To create Stratis snapshot, use:

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

Example:

[root@redaix ~]# stratis fs snapshot  mypool2  web websnapshot-$(date +%Y-%m-%d)

Confirm:

[root@redaix ~]# stratis filesystem list mypool2
Pool Name  Name                    Used     Created            Device                                   UUID
mypool2    websnapshot-2020-05-31  546 MiB  May 31 2020 08:51  /stratis/mypool2/websnapshot-2020-05-31  e6f993bae71046bc9cd94f0a97cfa64b
mypool2    data                    546 MiB  May 31 2020 07:20  /stratis/mypool2/data                    f0a95a27dfe14d388d8b4724fd15ffc0
mypool2    web                     546 MiB  May 31 2020 07:20  /stratis/mypool2/web                     4c8a7463d0fc45628591d9e9ea545804

You can mount and operate Snapshot independent of the source file system.

[root@redaix ~]# mount /stratis/mypool2/websnapshot-2020-05-31 /mnt
[root@redaix ~]# cd /mnt
[root@redaix mnt]# ls
[root@redaix mnt]# touch test_file{1..10}
[root@redaix mnt]# ls
test_file1   test_file2  test_file4  test_file6  test_file8
test_file10  test_file3  test_file5  test_file7  test_file9

Revert a Stratis file system to a previous snapshot

It is possible to revert a Statis file system to the previously created snapshot. See below

First Unmount and remove the original file system:

[root@redaix mnt]# umount /web
[root@redaix mnt]# stratis filesystem destroy mypool2 web

Then create a copy of the snapshot under the name of the original file system:

[root@redaix mnt]# stratis filesystem snapshot mypool2 websnapshot-2020-05-31 web

Mount the snapshot & filesystem should contain the data we added to the snapshot

[root@redaix ~]# mount /stratis/mypool2/web /web
[root@redaix ~]# cd /web
[root@redaix web]# ls
test_file1   test_file2  test_file4  test_file6  test_file8
test_file10  test_file3  test_file5  test_file7  test_file9

Also change UUID on /etc/fstab to match new filesystem UUID.

[root@redaix web]# blkid -p /stratis/mypool2/web
/stratis/mypool2/web: UUID="e84d1fb6-6b6a-4653-acf1-4ef097c4971c"TYPE="xfs"USAGE="filesystem"
[root@redaix web]# grep web /etc/fstab
UUID=4c8a7463-d0fc-4562-8591-d9e9ea545804 /web xfs defaults,x-systemd.requires=stratisd.service 0 0

Removing a Stratis snapshot

To remove the snapshot, unmount the snapshot

[root@redaix ~]# umount /mnt

Now destroy the snapshot

stratis filesystem destroy <pool_name><snapshot_name>

Example:

[root@redaix ~]# stratis filesystem destroy mypool2 websnapshot-2020-05-31

Post Verification:

[root@redaix ~]# stratis filesystem list mypool2
Pool Name  Name  Used     Created            Device                 UUID
mypool2    web   546 MiB  May 31 2020 09:06  /stratis/mypool2/web   e84d1fb66b6a4653acf14ef097c4971c
mypool2    data  546 MiB  May 31 2020 07:20  /stratis/mypool2/data  f0a95a27dfe14d388d8b4724fd15ffc0

Renaming a file system

To rename a file system, use the below syntax:

stratis filesystem rename <pool_name><old_fsname><new_fsname>

The example below renames “web” filesystem to “backups”

[root@redaix ~]# stratis filesystem rename mypool2 web backups

Post verification:

[root@redaix ~]# stratis filesystem list mypool2
Pool Name  Name     Used     Created            Device                    UUID
mypool2    backups  546 MiB  May 31 2020 09:06  /stratis/mypool2/backups  e84d1fb66b6a4653acf14ef097c4971c
mypool2    data     546 MiB  May 31 2020 07:20  /stratis/mypool2/data     f0a95a27dfe14d388d8b4724fd15ffc0

Removing a Stratis Pool

To completely destroy a Stratis Pool, you need to:

  • Unmount all filesystems on the pool
  • Destroy the filesystems
  • Destroy the pool

In below example, we will destroy mypool1

List available filesystems

[root@redaix ~]# stratis filesystem list mypool1
Pool Name  Name  Used     Created            Device                 UUID
mypool1    myfs  546 MiB  May 31 2020 07:18  /stratis/mypool1/myfs  5cd703ee68224195aad2060c5d9ae9d1

Unmount the filesystem

[root@redaix ~]# umount /myfs

Destroy filesystem

[root@redaix ~]# stratis filesystem destroy mypool1 myfs

Destroy the pool

[root@redaix ~]# stratis pool destroy mypool1

Verify that the pool no longer exists

[root@redaix ~]# stratis pool list
Name                   Total Physical
mypool2  10 GiB / 1.11 GiB / 8.89 GiB

Remove /etc/fstab lines for destroyed filesystem

[root@redaix ~]# vi /etc/fstab

Reference:

Setting up Stratis file systems

That’s all friend’s

We are sure, you must have liked this tutorial and if you really do, please share it with your friends and colleagues. Also, do subscribe to our blog and follow us on all the social media channels for more updates

Leave a Reply

Your email address will not be published. Required fields are marked *