Learn how to – Configure Stratis Storage on Rocky Linux 8 | AlmaLinux 8.
Stratis is a local storage management service that makes it easy to manage pools from physical storage devices. It simplifies the setting up and managing of complex storage configurations as well as gives access to advanced features.
The chief concept of Stratis Storage is the pool. A pool is created from one or more local dicks/partitions. Volumes are then created in the pool. The Statis pool brings several features that include:
- File system snapshots
- Tiering
- Monitoring
- Thin provisioning
- Pool-based management
The technical terms used in Stratis Storage are:
- pool: consisting of one or more block devices. The total size of the pool is the sum of the block devices’ size.
- blockdev: this refers to the block devices. The supported block devices here are:
- DM Multipath
- LUKS
- HDDs and SSDs
- LVM logical volumes
- MD RAID
- iSCSI
- NVMe devices
- Filesystem: it is used to store files on the pool. A pool can contain one or more file systems. They are thinly provisioned and do not have a fixed total size. Its size grows as data is saved into it. Normally the file systems are formatted to XFS.
This guide provides a detailed demonstration of how to configure Stratis Storage on Rocky Linux 8 | AlmaLinux 8.
Before You Begin
This guide works best with the following:
- Rocky Linux 8 | AlmaLinux 8
- Block devices that are not in use/mounted. In this guide, we will use several disks attached to the system.
1. Install Stratis on Rocky Linux 8 | AlmaLinux 8
Stratis provides two packages, i.e
- stratisd daemon – the daemon responsible for creating and managing block devices as well as providing the DBUS API
- stratis-cli – the command line tool for Stratis
Now install Stratis on Rocky Linux 8 | AlmaLinux 8 using the command:
sudo dnf install stratisd stratis-cli
Dependency Tree:
Transaction Summary
================================================================================
Install 9 Packages
Total download size: 4.7 M
Installed size: 14 M
Is this ok [y/N]: y
Once installed, start and enable the Stratis service:
sudo systemctl enable --now stratisd
Check the status of the service:
$ systemctl status stratisd
● stratisd.service - Stratis daemon
Loaded: loaded (/usr/lib/systemd/system/stratisd.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2022-07-06 05:28:20 EDT; 5s ago
Docs: man:stratisd(8)
Main PID: 2487 (stratisd)
Tasks: 5 (limit: 23682)
Memory: 1.5M
CGroup: /system.slice/stratisd.service
└─2487 /usr/libexec/stratisd --log-level debug
Jul 06 05:28:20 localhost.localdomain systemd[1]: Starting Stratis daemon...
Jul 06 05:28:20 localhost.localdomain stratisd[2487]: [2022-07-06T09:28:20Z INFO libstratis::stratis::run] stratis daemon version 2.4.2 st>
...
2. Creating a Stratis pool
As said earlier, a pool can be created using one or more block devices. First, identify the disks:
$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 40G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 39G 0 part
├─rl-root 253:0 0 35G 0 lvm /
└─rl-swap 253:1 0 4G 0 lvm [SWAP]
sdb 8:16 0 10G 0 disk
sdc 8:32 0 10G 0 disk
sdd 8:48 0 10G 0 disk
sde 8:64 0 10G 0 disk
sdf 8:80 0 10G 0 disk
Here we have 5 secondary disks sdb, sdc, sdd, sde,sdf each with a 10GB capacity.
You need to wipe any file system, partition table ,or RAID signatures from all the block devices using the command with the syntax:
sudoo wipefs --all block-device1 block-device2
For example:
sudo wipefs --all /dev/sdX
Depending on your preferences, you can create a Stratis pool using one of the methods below:
A. Create a Stratis Pool using One Block Device
To create a Stratis pool from one block device, use the command with the following syntax:
sudo stratis pool create <pool-name> <block-device>
Replace the pool-name with the desired name of the pool and block-device with the disk. For example;
stratis pool create pool_1 /dev/sdX
Once created, verify this with the command:
$ sudo stratis pool list
Name Total Physical Properties UUID
pool_1 10 GiB / 37.63 MiB / 9.96 GiB ~Ca,~Cr 538cb5f5-c0a3-487e-aafa-8a21d589e11f
B. Create a Stratis Pool using Multiple Block Devices
To create a pool using multiple block devices, use the command with the syntax:
stratis pool create <pool_name> device-1 device-2 device-n
For example, creating another pool with sdc, sdd, sde.
sudo stratis pool create pool_2 /dev/sdc /dev/sdd /dev/sde
Once created, list the pools:
$ sudo stratis pool list
Name Total Physical Properties UUID
pool_1 10 GiB / 37.63 MiB / 9.96 GiB ~Ca,~Cr 538cb5f5-c0a3-487e-aafa-8a21d589e11f
pool_2 30 GiB / 45.64 MiB / 29.96 GiB ~Ca,~Cr b78ebb01-1142-4add-a3f9-57e2354b9d33
From the above output, you can agree that the total size of the pool is equal to the sum of the individual block device sizes.
C. Creating an encrypted Stratis pool
All the above methods are used to create an unencrypted Stratis pool. But if you need to create an encrypted Stratis pool that secures your data, you have to perform the following:
First, obtain the key set to use for the encryption.
$ sudo stratis key set --capture-key key-description
Enter key data followed by the return key: Enter Key and press Enter
Now using the key, create an encrypted Stratis pool using the command with the syntax:
sudo stratis pool create --key-desc key-description my-pool block-device
Here, key-description references to the kernel keyring created above. For example:
sudo stratis pool create --key-desc key-description pool_3 /dev/sdf
You can still create an encrypted pool with multiple block devices.
sudo stratis pool create --key-desc key-description my-pool block-device-1 block-device-2
Verify the creation:
$ sudo stratis pool list
Name Total Physical Properties UUID
pool_1 10 GiB / 37.63 MiB / 9.96 GiB ~Ca,~Cr 538cb5f5-c0a3-487e-aafa-8a21d589e11f
pool_2 30 GiB / 45.64 MiB / 29.96 GiB ~Ca,~Cr b78ebb01-1142-4add-a3f9-57e2354b9d33
pool_3 9.98 GiB / 37.63 MiB / 9.95 GiB ~Ca, Cr 816d1e4e-9675-45dc-81be-cee6cdb4d0f6
3. Creating a Filesystem on a Pool
With the pool created, you can proceed and create a filesystem on it. This can be achieved by executing a command with the below syntax:
sudo stratis fs create <poolname> <filesystemname>
For example:
sudo stratis fs create pool_1 filesystem-1
sudo stratis fs create pool_2 filesystem-2
sudo stratis fs create pool_3 filesystem-3
View the created file systems:
$ sudo stratis fs list
Pool Name Name Used Created Device UUID
pool_1 filesystem-1 545 MiB Jul 06 2022 05:35 /dev/stratis/pool_1/filesystem-1 b9b05db4-99a0-4036-ad5f-96de3f8a9c0a
pool_2 filesystem-2 545 MiB Jul 06 2022 05:36 /dev/stratis/pool_2/filesystem-2 77970ccc-2298-49ce-bfd0-adb7218c2418
pool_3 filesystem-3 545 MiB Jul 06 2022 05:36 /dev/stratis/pool_3/filesystem-3 f3b6276b-7daf-4756-ad8c-991a58cf0e20
You can also view the filesystem on an individual pool.
sudo stratis fs list <poolname>
For example:
$ sudo stratis fs list pool_1
Pool Name Name Used Created Device UUID
pool_1 filesystem-1 545 MiB Jul 06 2022 05:35 /dev/stratis/pool_1/filesystem-1 b9b05db4-99a0-4036-ad5f-96de3f8a9c0a
For a detailed view, you can use the command below:
lsblk
Sample Output:
You will notice some differences in the disk(s) in the encrypted pool. They have encryption using cryptsetup
library.
4. Mounting a Stratis Filesystem
In order to use the pool, you need to mount the filesystem. Create the mount points and mount the filesystems as illustrated:
For the first pool:
sudo mkdir /mnt/pool_1
sudo mount /dev/stratis/pool_1/filesystem-1 /mnt/pool_1
For the second pool
sudo mkdir /mnt/pool_2
sudo mount /dev/stratis/pool_2/filesystem-2 /mnt/pool_2
For the third pool:
sudo mkdir /mnt/pool_3
sudo mount /dev/stratis/pool_3/filesystem-3 /mnt/pool_3
For the filesystems to survive a reboot, you need to add them to the Fstab file. Identify the UUID of the filesystems
$ sudo lsblk --output=UUID /dev/stratis/pool_1/filesystem-1
UUID
b9b05db4-99a0-4036-ad5f-96de3f8a9c0a
$ sudo lsblk --output=UUID /dev/stratis/pool_2/filesystem-2
UUID
77970ccc-2298-49ce-bfd0-adb7218c2418
$ sudo lsblk --output=UUID /dev/stratis/pool_3/filesystem-3
UUID
f3b6276b-7daf-4756-ad8c-991a58cf0e20
Now use the obtained UUIDs to add the filesystems to the fstab file:
$ sudo vi /etc/fstab
UUID=b9b05db4-99a0-4036-ad5f-96de3f8a9c0a /mnt/pool_1 xfs defaults,x-systemd.requires=stratisd.service 0 0
UUID=77970ccc-2298-49ce-bfd0-adb7218c2418 /mnt/pool_2 xfs defaults,x-systemd.requires=stratisd.service 0 0
UUID=f3b6276b-7daf-4756-ad8c-991a58cf0e20 /mnt/pool_3 xfs defaults,x-systemd.requires=stratisd.service 0 0
Once the above changes have been made, reload the daemon.
sudo systemctl daemon-reload
After reboot, the encrypted pool will not be available. You need to unlock it to be able to see it. There is a detailed guide on how to use the encrypted Stratis pool:
5. Creating Stratis Snapshots
A snapshot creates a thinly provisioned copy of the filesystem at a given time. This can be created on Stratis using the command:
sudo stratis fs snapshot <poolname> <fsname> <snapshotname>
For example:
stratis fs snapshot pool_2 filesystem-2 mysnapshot
List the available snapshots:
$ sudo stratis filesystem list pool_2
Pool Name Name Used Created Device UUID
pool_2 mysnapshot 545 MiB Jul 06 2022 06:15 /dev/stratis/pool_2/mysnapshot 63f2c0f5-2bad-499e-ad54-af45306994cf
pool_2 filesystem-2 545 MiB Jul 06 2022 05:36 /dev/stratis/pool_2/filesystem-2 77970ccc-2298-49ce-bfd0-adb7218c2418
6. Reverting to a Stratis Snapshot
Once snapshots have been created, you can revert to them using the below steps:
First, unmount the original filesystem.
sudo umount /dev/stratis/pool_2/filesystem-2
Then copy the snapshot to the filesystem.
sudo stratis filesystem snapshot pool_2 mysnapshot block
Now mount the snapshot.
sudo mount /dev/stratis/my-pool/my-fs mount-point
For example:
sudo mount /dev/stratis/pool_2/filesystem-2 /mnt/pool_2
7. Removing a Stratis Filesystem
In order to remove a filesystem, you first need to unmount it:
For example:
sudo umount /mnt/pool_3
Then destroy the filesystem.
sudo stratis filesystem destroy <poolname> <filesystem-name>
For example:
sudo stratis filesystem destroy pool_3 filesystem-3
Verify this:
$ sudo stratis filesystem list pool_3
Pool Name Name Used Created Device UUID
There should be no filesystem on the pool.
8. Removing a Stratis Pool
After removing a filesystem, you can delete a pool using the command with the syntax:
sudo stratis pool destroy <poolname>
For example:
stratis pool destroy pool_3
Verify this with the command:
$ sudo stratis pool list
Name Total Physical Properties UUID
pool_1 10 GiB / 582.65 MiB / 9.43 GiB ~Ca,~Cr 538cb5f5-c0a3-487e-aafa-8a21d589e11f
pool_2 30 GiB / 1.64 GiB / 28.36 GiB ~Ca,~Cr b78ebb01-1142-4add-a3f9-57e2354b9d33
9. Adding a Disk to an Existing Stratis Pool
You can add a disk to an existing pool using the below command:
sudo stratis pool add-data <poolname> /<devicepath>
But remember, the block devices in the pool need to be either all encrypted or all unencrypted.
Wipe partitions on the disk:
sudo wipefs --all block-device
Proceed and add the block device. For example:
sudo stratis pool add-data pool_1 /dev/sdf
Verify this:
Closing Thoughts
That marks the end of this guide on how to configure Stratis Storage on Rocky Linux 8 | AlmaLinux 8. I hope this worked for you too.
See more:
Install and Use Stratis to Manage Local Storage on RHEL 8 / CentOS 8
Configure iSCSI Target and Initiator on CentOS 8 / RHEL 8
Install and Configure OpenMediaVault NAS Storage Server
Leave a Reply
You must be logged in to post a comment.