(Last Updated On: December 11, 2018)

This is the ultimate Stratis Local Storage Management cheatsheet. Stratis is the local storage manager for Linux. It provides managed file systems on top of pools of storage with additional features to the user. Stratis provides ZFS/Btrfs-style features by integrating layers Linux’s devicemapper subsystem, and the XFS filesystem.

Stratis gives you access to advanced storage features such as:

  • Thin provisioning
  • File system 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 Supported devices

Stratis works with the following  block devices:

  • iSCSI
  • LVM logical volumes
  • Device Mapper Multipath
  • hard drives
  • LUKS
  • SSDs
  • NVMe storage devices
  • mdraid

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.

Installing Stratis on Linux

Use below guides to Install Stratis on your Linux server:

Install and Use Stratis to Manage Local Storage on RHEL 8 / Fedora

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.

On my server, I have the following block devices:

# lsblk
NAME          MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sr0            11:0    1 1024M  0 rom  
vda           252:0    0   20G  0 disk 
├─vda1        252:1    0    1G  0 part /boot
└─vda2        252:2    0   19G  0 part 
  ├─rhel-root 253:0    0   17G  0 lvm  /
  └─rhel-swap 253:1    0    2G  0 lvm  [SWAP]
vdb           252:16   0   10G  0 disk 
vdc           252:32   0   10G  0 disk 
vdd           252:48   0   10G  0 disk 
vde           252:64   0   10G  0 disk

I’ll create the first pool with single block device /dev/vdb and the other pool with three block devices /dev/vdc,/dev/vdd,/dev/vdd

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

sudo blkid -p /<devicepath>

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

sudo wipefs -a /<devicepath>

Create a pool with one block device

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

sudo stratis pool create mypool1 /dev/vdb

List available pools with:

$ sudo stratis pool list
Name       Total Physical Size  Total Physical Used
mypool1                 10 GiB               52 MiB

Create a pool with three block device

Now let’s create another pool with three block devices /dev/vdc,/dev/vdd,/dev/vdd

sudo stratis pool create mypool2 /dev/vdc /dev/vdd /dev/vde

You should now have two pools:

$ sudo stratis pool list
Name       Total Physical Size  Total Physical Used
mypool1                 10 GiB               52 MiB
mypool2                 30 GiB               60 MiB

From the output, we can see that the size of the volume is the summation of all block devices raw storage.

Creating a filesystem from the pool

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

sudo stratis fs create <poolname>  <filesystemname>

See examples below.

Create a filesystem on mypool1
sudo stratis fs create mypool1 logs
Create a filesystem on mypool2
sudo stratis fs create mypool2  data
sudo stratis fs create mypool2  web

To list created filesystems, use:

$ sudo stratis fs list
Pool Name  Name  Used     Created            Device                     
mypool1    logs  546 MiB  Dec 11 2018 01:00  /dev/stratis/mypool1/logs  
mypool2    data  546 MiB  Dec 11 2018 01:04  /dev/stratis/mypool2/data

You can also limit output to specified pool:

$ sudo stratis fs list mypool2
Pool Name  Name  Used     Created            Device                     
mypool2    data  546 MiB  Dec 11 2018 01:04  /dev/stratis/mypool2/data  
mypool2    web   546 MiB  Dec 11 2018 01:06  /dev/stratis/mypool2/web

The lsblk output should look similar to below:

$ sudo lsblk 
NAME                                                                                        MAJ:MIN RM  SIZE RO TYPE    MOUNTPOINT
sr0                                                                                          11:0    1 1024M  0 rom     
vda                                                                                         252:0    0   20G  0 disk    
├─vda1                                                                                      252:1    0    1G  0 part    /boot
└─vda2                                                                                      252:2    0   19G  0 part    
  ├─rhel-root                                                                               253:0    0   17G  0 lvm     /
  └─rhel-swap                                                                               253:1    0    2G  0 lvm     [SWAP]
vdb                                                                                         252:16   0   10G  0 disk    
└─stratis-1-private-68bf465c93eb4aa98ed2264b38d8c42a-physical-originsub                     253:2    0  1.8G  0 stratis 
  ├─stratis-1-private-68bf465c93eb4aa98ed2264b38d8c42a-flex-thinmeta                        253:3    0   16M  0 stratis 
  │ └─stratis-1-private-68bf465c93eb4aa98ed2264b38d8c42a-thinpool-pool                      253:6    0  1.8G  0 stratis 
  │   ├─stratis-1-68bf465c93eb4aa98ed2264b38d8c42a-thin-fs-217bee04c2f14266b496eaada54a0311 253:12   0    1T  0 stratis 
  │   └─stratis-1-68bf465c93eb4aa98ed2264b38d8c42a-thin-fs-1f563ecb6e0c497ab3fc24d5b2e33fe1 253:13   0    1T  0 stratis 
  ├─stratis-1-private-68bf465c93eb4aa98ed2264b38d8c42a-flex-thindata                        253:4    0  1.8G  0 stratis 
  │ └─stratis-1-private-68bf465c93eb4aa98ed2264b38d8c42a-thinpool-pool                      253:6    0  1.8G  0 stratis 
  │   ├─stratis-1-68bf465c93eb4aa98ed2264b38d8c42a-thin-fs-217bee04c2f14266b496eaada54a0311 253:12   0    1T  0 stratis 
  │   └─stratis-1-68bf465c93eb4aa98ed2264b38d8c42a-thin-fs-1f563ecb6e0c497ab3fc24d5b2e33fe1 253:13   0    1T  0 stratis 
  └─stratis-1-private-68bf465c93eb4aa98ed2264b38d8c42a-flex-mdv                             253:5    0   16M  0 stratis 
vdc                                                                                         252:32   0   10G  0 disk    
vdd                                                                                         252:48   0   10G  0 disk    
vde                                                                                         252:64   0   10G  0 disk    
└─stratis-1-private-557de29f274a45d583c62cafbab8edd6-physical-originsub                     253:7    0  816M  0 stratis 
  ├─stratis-1-private-557de29f274a45d583c62cafbab8edd6-flex-thinmeta                        253:8    0   16M  0 stratis 
  │ └─stratis-1-private-557de29f274a45d583c62cafbab8edd6-thinpool-pool                      253:11   0  768M  0 stratis 
  ├─stratis-1-private-557de29f274a45d583c62cafbab8edd6-flex-thindata                        253:9    0  768M  0 stratis 
  │ └─stratis-1-private-557de29f274a45d583c62cafbab8edd6-thinpool-pool                      253:11   0  768M  0 stratis 
  └─stratis-1-private-557de29f274a45d583c62cafbab8edd6-flex-mdv                             253:10   0   16M  0 stratis

Mounting a Stratis file system

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

sudo mkdir /data
sudo mount /dev/stratis/mypool2/data /data

I’ll also mount /dev/stratis/mypool2/web

sudo mount /dev/stratis/mypool2/web /srv

Check currents mount points:

$ sudo df -hT | grep stratis

The output is:

Add a persistent mount point to /etc/fstab

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

# blkid -p /dev/stratis/mypool2/web
/dev/stratis/mypool2/web: UUID="7d3b49be-51d5-499c-b12b-b5ebe118c416" TYPE="xfs" USAGE="filesystem"

# blkid -p /dev/stratis/mypool2/data
/dev/stratis/mypool2/data: UUID="a6f40f25-140c-43e3-97af-e9e771f08a54" TYPE="xfs" USAGE="filesystem"

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

echo "UUID=7d3b49be-51d5-499c-b12b-b5ebe118c416 /srv xfs defaults 0 0" | sudo tee -a /etc/fstab
echo "UUID=a6f40f25-140c-43e3-97af-e9e771f08a54 /data xfs defaults 0 0" | sudo tee -a /etc/fstab

Test:

sudo umount /data
sudo umount /srv
sudo mount -a

Removing a Stratis file system

Before you can remove Stratis file system, you need to unmount it

sudo umount /mountpoint

Then destroy it:

sudo stratis filesystem destroy <poolname<  <filesystemname>

Example

sudo umount /srv
sudo stratis filesystem destroy mypool2 web

Confirm:

# sudo stratis filesystem list mypool2
Pool Name  Name  Used     Created            Device                     
mypool2    data  546 MiB  Dec 11 2018 01:04  /dev/stratis/mypool2/data

Add a disk to an existing pool

To add another disk to the pool, use:

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

Example:

sudo stratis pool add-data mypool1 /dev/vdf

Confirm:

$ sudo stratis pool list 
Name       Total Physical Size  Total Physical Used
mypool1                 20 GiB             1.12 GiB
mypool2                 30 GiB              606 MiB

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:

sudo stratis fs snapshot  mypool2  web websnapshot-$(date +%Y-%m-%d)

Confirm:

$ sudo stratis filesystem list mypool2
Pool Name  Name                    Used     Created            Device                                       
mypool2    web                     546 MiB  Dec 11 2018 01:06  /dev/stratis/mypool2/web                     
mypool2    websnapshot-2018-12-11  546 MiB  Dec 11 2018 03:34  /dev/stratis/mypool2/websnapshot-2018-12-11  
mypool2    data                    546 MiB  Dec 11 2018 01:04  /dev/stratis/mypool2/data

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

sudo  mount /dev/stratis/mypool2/websnapshot-2018-12-11 /mnt
for i in {1..10}; do sudo touch /mnt/$i.txt; done
ls /mnt
ls /srv
sudo umount /mnt

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:

sudo umount /srv
sudo stratis filesystem destroy mypool2 web

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

sudo  stratis filesystem snapshot mypool2  websnapshot-2018-12-11 web

Mount the snapshot

sudo mount /dev/stratis/mypool2/web /srv

This filesystem should contain the data we added to the snapshot

$ ls /srv/
10.txt     1.txt  3.txt  5.txt  7.txt  9.txt
1..10.txt  2.txt  4.txt  6.txt  8.txt

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

# blkid -p /dev/stratis/mypool2/web
/dev/stratis/mypool2/web: UUID="110b737f-2117-4624-8c97-c3def8b2a539" TYPE="xfs" USAGE="filesystem"

# grep srv /etc/fstab 
UUID=110b737f-2117-4624-8c97-c3def8b2a539 /srv xfs defaults 0 0

Removing a Stratis snapshot

To remove the snapshot, unmount the snapshot.

sudo unmount /snapmountpoint

Now destroy the snapshot:

sudo stratis filesystem destroy <poolname> <snapshotname>

Example:

sudo stratis filesystem destroy mypool2 websnapshot-2018-12-11

Check:

# sudo stratis filesystem list mypool2
Pool Name  Name  Used     Created            Device                     
mypool2    web   546 MiB  Dec 11 2018 03:58  /dev/stratis/mypool2/web   
mypool2    data  546 MiB  Dec 11 2018 01:04  /dev/stratis/mypool2/data

Renaming  a file system

To rename a file system, use the syntax:

$ sudo stratis filesystem rename <poolname> <old-fsname>  <new-fsname>

The example below renames logs filesystem to backups

sudo stratis filesystem rename mypool1  logs  backups

Confirm:

$ sudo stratis filesystem list mypool1
Pool Name  Name     Used     Created            Device                        
mypool1    backups  546 MiB  Dec 11 2018 01:00  /dev/stratis/mypool1/backups

Removing a Stratis pool

To completely destroy a Stratis pool, you need to:

  • Unmount all file systems on the pool
  • Destroy the file systems:
  • Destroy the pool

In below example, we will destroy mypool2

1. List available file systems

$ sudo stratis filesystem list mypool2
Pool Name  Name  Used     Created            Device                     
mypool2    data  546 MiB  Dec 11 2018 01:04  /dev/stratis/mypool2/data

2. Unmount the file systems

sudo umount /dev/stratis/mypool2/data

3. Destroy file system:

sudo stratis filesystem destroy mypool2 data

4. Destroy the pool

sudo stratis pool destroy mypool2

4. Verify that the pool no longer exists:

$ sudo stratis pool list
Name       Total Physical Size  Total Physical Used
mypool1                 20 GiB             1.12 GiB

6. Remove /etc/fstab lines for destroyed file system

sudo vim /etc/fstab