When adding storage to a Linux server, system administrators often use commands like pvcreate, vgcreate, lvcreate, and mkfs to integrate the new storage into the system. Stratis is a command-line tool designed to make managing storage much simpler. It creates, modifies, and destroys pools of storage. It also allocates and deallocates filesystems from the storage pools.
Instead of an entirely in-kernel approach like ZFS or Btrfs, Stratis uses a hybrid approach with components in both user space and kernel land. It builds on existing block device managers like device mapper and existing filesystems like XFS. Monitoring and control is performed by a user space daemon.
Stratis tries to avoid some ZFS characteristics like restrictions on adding new hard drives or replacing existing drives with bigger ones. One of its main design goals is to achieve a positive command-line experience.
Install Stratis
Begin by installing the required packages. Several Python-related dependencies will be automatically pulled in. The stratisd package provides the stratisd daemon which creates, manages, and monitors local storage pools. The stratis-cli package provides the stratis command along with several Python libraries.
# yum install -y stratisd stratis-cli
Next, enable the stratisd service.
# systemctl enable --now stratisd
Note that the “enable –now” syntax shown above both permanently enables and immediately starts the service.
After determining what disks/block devices are present and available, the three basic steps to using Stratis are:
- Create a pool of the desired disks.
- Create a filesystem in the pool.
- Mount the filesystem.
In the following example, four virtual disks are available in a virtual machine. Be sure not to use the root/system disk (/dev/vda in this example)!
# sfdisk -s /dev/vda: 31457280 /dev/vdb: 5242880 /dev/vdc: 5242880 /dev/vdd: 5242880 /dev/vde: 5242880 total: 52428800 blocks
Create a storage pool using Stratis
# stratis pool create testpool /dev/vdb /dev/vdc # stratis pool list Name Total Physical Size Total Physical Used testpool 10 GiB 56 MiB
After creating the pool, check the status of its block devices:
# stratis blockdev list Pool Name Device Node Physical Size State Tier testpool /dev/vdb 5 GiB In-use Data testpool /dev/vdc 5 GiB In-use Data
Create a filesystem using Stratis
Next, create a filesystem. As mentioned earlier, Stratis uses the existing DM (device mapper) and XFS filesystem technologies to create thinly-provisioned filesystems. By building on these existing technologies, large filesystems can be created and it is possible to add physical storage as storage needs grow.
# stratis fs create testpool testfs # stratis fs list Pool Name Name Used Created Device UUID testpool testfs 546 MiB Apr 18 2020 09:15 /stratis/testpool/testfs 095fb4891a5743d0a589217071ff71dc
Note that “fs” in the example above can optionally be written out as “filesystem”.
Mount the filesystem
Next, create a mount point and mount the filesystem.
# mkdir /testdir # mount /stratis/testpool/testfs /testdir # df -h | egrep 'stratis|Filesystem' Filesystem Size Used Avail Use% Mounted on /dev/mapper/stratis-1-3e8e[truncated]71dc 1.0T 7.2G 1017G 1% /testdir
The actual space used by a filesystem is shown using the stratis fs list command demonstrated previously. Notice how the testdir filesystem has a virtual size of 1.0T. If the data in a filesystem approaches its virtual size, and there is available space in the storage pool, Stratis will automatically grow the filesystem. Note that beginning with Fedora 34, the form of device path will be /dev/stratis/<pool-name>/<filesystem-name>.
Add the filesystem to fstab
To configure automatic mounting of the filesystem at boot time, run following commands:
# UUID=`lsblk -n -o uuid /stratis/testpool/testfs` # echo "UUID=${UUID} /testdir xfs defaults 0 0" >> /etc/fstab
After updating fstab, verify that the entry is correct by unmounting and mounting the filesystem:
# umount /testdir # mount /testdir # df -h | egrep 'stratis|Filesystem' Filesystem Size Used Avail Use% Mounted on /dev/mapper/stratis-1-3e8e[truncated]71dc 1.0T 7.2G 1017G 1% /testdir
Adding cache devices with Stratis
Suppose /dev/vdd is an available SSD (solid state disk). To configure it as a cache device and check its status, use the following commands:
# stratis pool add-cache testpool /dev/vdd # stratis blockdev Pool Name Device Node Physical Size State Tier testpool /dev/vdb 5 GiB In-use Data testpool /dev/vdc 5 GiB In-use Data testpool /dev/vdd 5 GiB In-use Cache
Growing the storage pool
Suppose the testfs filesystem is close to using all the storage capacity of testpool. You could add an additional disk/block device to the pool with commands similar to the following:
# stratis pool add-data testpool /dev/vde # stratis blockdev Pool Name Device Node Physical Size State Tier testpool /dev/vdb 5 GiB In-use Data testpool /dev/vdc 5 GiB In-use Data testpool /dev/vdd 5 GiB In-use Cache testpool /dev/vde 5 GiB In-use Data
After adding the device, verify that the pool shows the added capacity:
# stratis pool Name Total Physical Size Total Physical Used testpool 15 GiB 606 MiB
Conclusion
Stratis is a tool designed to make managing storage much simpler. Creating a filesystem with enterprise functionalities like thin-provisioning, snapshots, volume management, and caching can be accomplished quickly and easily with just a few basic commands.
See also Getting Started with Stratis Encryption.
Oscar
Which is the future of Stratis when Btrfs has been choosne as Fedora’s and Systemd-homed’s default filesystem ? Thanks!
tabowling
Btrfs is only the default for new installs of the Workstation/Desktop edition. Fedora Server still defaults to LVM + XFS. Btrfs never made it out of technology preview status in Red Hat Enterprise Linux (RHEL) 7 and was dropped from RHEL 8 completely in favor of Stratis as the preferred, long term storage layer solution.
For more future info, follow:
https://stratis-storage.github.io/
https://twitter.com/StratisStorage
https://stratis-storage.github.io/StratisSoftwareDesign.pdf
https://www.redhat.com/en/blog/whats-new-rhel-8-file-systems-and-storage
https://lwn.net/Articles/755454/
Oscar
Thanks. Yes, I know. But you’d recognize that recent Fedora’s decision to move to Btrfs is a little astonishing knowing the facts you’ve listed. I mean it’s seems to be a crossroad here.
tabowling
Correct. The Fedora community sometimes makes different decisions from RHEL. I guess the short answer is there is no confirmed, long term plan for this in Fedora. So we’ll see…
Lee Underwood
Get some BTRFS experience dude!
Facebook uses BTRFS to store PB of data.
https://www.linux.com/news/how-facebook-uses-linux-and-btrfs-interview-chris-mason/
I have been using BTRFS on Suse for years.
I am able to store 50 times the amount of data with snapshots.
Scrub data volumes without having to dismount the volumes.
Enterprise File System for the 21st century.
Run Samba, NFS, or NCP volumes on BTRFS just fine.
Lee
GM
yum has been deprecated for years in favour of dnf
Andy
Since the post seems to be server oriented he is probably including it for CentOS users.
tabowling
The YUM user experience and important compatibility were implemented in DNF to enable a smooth transition. As of RHEL 8 and Fedora 31, you can consider DNF and YUM to be essentially one and the same (built off of the DNF code base). But continue to use the YUM commands if that is what your fingers have memorized!
https://fedoraproject.org/wiki/Changes/Retire_YUM_3
Bill Dietrich
Is Stratis XFS-only ? Can’t use it with Btrfs or ext4, for example ? Thanks.
Oscar
Yes. It’s XFS only by design.
In fact, it is a direct competence of Btrfs (and ZFS).
tabowling
https://stratis-storage.github.io/StratisSoftwareDesign.pdf
Dennis Keefe
Thank you for spending your time writing this article for Fedora Magazine. I’m sure it will help users who are interested in using Stratis!
Anon
Whoever created the thumbnail image for this… pick a position for the sun, that’s not how light and shadow works. 😀
Gregory Bartholomew
The image was my doing (the editor), not the author’s. I have zero art skills, but I’ll try to pay at least a little attention to the direction of the light coming from the moon next time. 😄
François Fontaine
Since ‘states’ is only XFS, how does it handle disk removal and space resizing ?
Dennis Keefe
Stratis allows increasing a pool’s size. File systems in a pool will share the available blocks of the pool. Once a physical or logical device has been added to a Stratis pool it will be a member until the pool is destroyed. Removing a device for maintenance or for another purpose would be done at a lower layer, such as, RAID layer.
SD
For anyone coming to this and asking about raid (because I know stratis basically is just layering lvm, mdadm, thinpools) they have a
command BUT, even on fedora 33 server with the latest stratis your only option is .
Not sure why they haven’t been able to incorporate that just yet as you can easily do an
to get you a mirrored logical volume. I assume it has something to do with the thinpools but do not know for sure.
Steven
Hi all.
Can a Stratis storage pool be reduced (eg: remove a block device) or reduce filesystem size?
AFAIK, XFS does not support filesystem reduction, so i guess Stratis does not currently support such operations. Is this correct?
Thanks & Bye
Dennis Keefe
Steven,
Correct, see my response to François Fontaine. I would like to hear your thoughts regarding which use cases shrinking a Stratis file system might be interesting.
Thank you,
-Dennis
steven
Sorry i missed your previous response.
Anyways thanks for your reply!
GnuDNA
Real world use case scenario of shrinking disk space, When users over provision disk for a VM or even laptop and need recover it, could be one example.
Jeffersonien
Could you use dnf, and validate it works normally?
Yum has been deprecated almost 2 years ago…
Jatin
If you use yum in the latest version of fedora it will use dnf as it is in the background both are sym linked to each other since a long time now, this step was taken so that people who are using yum since a long time wont have a difficulty managing the packages but both are sym linked and will use dnf as it is. DNF basically stands for Dandified YUM.
Jeffersonian
Gordon:
thanks for writing this informative article about Startis.
However, no disrespect intended, I am wondering if a complete rewriting of the article, for clarity, and explanation would not also be useful.
For example, in the now multitude of existing Linux/Unix file systems how does this improves the situation compared to the most popular and best latest (BRTFS, XFS, ZFS), how exactly ?
If any, other than testing for RedHat/IBM what would be a compelling argument to use Stratis over the one(s) we currently use?
Can Stratis do compression, now a nice and now reliable feature of BTRFS, especially with SSD’s
Etc…
Jatin
I am eagerly waiting for Stratis on root support, which is still being worked on ! Once it makes into anaconda I will love to switch to stratis, XFS has better performance for large files than btrfs or ZFS what it lacks tho is features like native snapshots and easy disk management. With stratis it will give me the perfect experience thanks again RedHat and the community !