Using Linux LVM snapshots (RHEL)
Posted on Thu, Nov 12, 2026 at 16:06 by Hubertus A. Haniel
This was mainly tested on RHEL8 with some tests on RHEL9 and 10:
LVM snapshots are not like what most people may have seen with snapshots in things like VMware etc where the original file system gets frozen and all the changes are written to another file and when the snapshot is deleted the changes are committed to the original file system.
With LVM changes are still being written to the original volume/file system but the original blocks that are being changed are being pushed out to a snapshot volume. - This means that we can create snapshots and delete them at will without having to play back the changes but it means that we will have increased I/O when we roll back a snapshot for a certain amount of time until everything gets synced again.
When taking a snapshot there are however a few considerations to take:
- While there is a snapshot in place for a logical volume / file system the logical volume can not be resized so if we run out of space on the file system we need to delete the snapshots first before we can resize it.
- The snapshot volume will have a size associated with it as well - Now the snapshot volume does not have to be the same size as the actual original volume but it has to be big enough to hold all the changes which may be written to it. It is possible to resize the snapshot volume and there are ways to have it increase it's size automatically but if the volume group runs out of space the snapshot will still become stale if it fills up.
- If a snapshot volume fills up it will become invalid and should not be rolled back to. - Rolling back to an invalid snapshot will corrupt the original volume but if that snapshot is deleted no harm will come to the original volume.
- For rollback the file system/original volume must be unmounted. In the case of the root file system the rollback can be initiated while running but to actually roll back a reboot is required.
- In the case of patching - /boot is not part of LVM generally and in case of EFI boot the EFI partition will not be either so that will have to be taken care off in another way.
In this example I am assuming all file systems for the root file system are on one logical volume - If this is not the case things get a little bit more tricky to make sure that all the correct file systems are in sync - For example if /var is on a separate volume which is the case in some environment as historically people thing /var contains nothing important. Well on RPM based systems like Redhat the rpm database is kept in /var and if it becomes out of sync with the rest of the system it can create some drastic problems going forward so if / is rolled back then /var needs to be rolled back as well.
The creation of a snapshot is quite simple - on my test system I have rootvg/rootlv as the root file system:
lvcreate -L 10G -s -n rootlv_snapshot /dev/rootvg/rootlv
This will create a 10Gb snapshot of my 20Gb rootlv of which I am
currently using 10%.
I can inspect this with lvs:
[root@kvm-testvm:~]# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert rootlv rootvg owi-aos--- 25.00g rootlv_snapshot rootvg swi-a-s--- 10.00g rootlv 0.03 swaplv rootvg -wi-ao---- 4.00g [root@kvm-testvm:~]#
This is where we can see the usage of the space in the snapshot as well as the "Attr" column which will become important if the usage (Data%) gets to 100% as a "I" will indicate that the snapshot has become invalid. I am now going to write some data to this disk with something like:
dd if=/dev/zero of=/bigfile1 bs=1024 count=5000000
This will create a file which is about 5Gb in size and while that was going on some other things where running but lvs now show that I am using 58.6% of that snapshot:
[root@kvm-testvm:~]# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert rootlv rootvg owi-aos--- 25.00g rootlv_snapshot rootvg swi-a-s--- 10.00g rootlv 58.06 swaplv rootvg -wi-ao---- 4.00g
This space will not be claimed back even though if I remove the file while it may free up file system space on the original volume:
[root@kvm-testvm:~]# rm /bigfile1 rm: remove regular file '/bigfile1'? y [root@kvm-testvm:~]# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert rootlv rootvg owi-aos--- 25.00g rootlv_snapshot rootvg swi-a-s--- 10.00g rootlv 58.09 swaplv rootvg -wi-ao---- 4.00g
This shows that the blocks that have changed in the logical volume have been pushed out to the snapshot so I can write data again to the same blocks and it will not necessarily increase the usage on the snapshot.
We could now just delete the snapshot with "lvremove /dev/rootvg/rootlv" if we want to discard it but for the sake of it I will recreate the file and revert the snapshot the snapshot which is done with "lvconvert" which will require a reboot (after which the file will be gone again as well):
[root@kvm-testvm:~]# lvconvert --merge /dev/rootvg/rootlv_snapshot Delaying merge since origin is open. Merging of snapshot rootvg/rootlv_snapshot will occur on next activation of rootvg/rootlv.
If this is done in a patching situation it is important to remember which kernel we are currently running or where running when the snapshot is taken as /boot may still contain a different kernel but none of the kernel modules for any newer kernel will be on the snapshot so the system will not be able to boot into a kernel that was not present when the snapshot was taken.
The once the system is booted "lvs" will show that the snapshot volume is gone and we are back on the normal system while e in the back ground the syncing is still taking place which can be seen with "dmsetup":
[root@kvm-testvm:~]# dmsetup status rootvg-rootlv: 0 52428800 snapshot-merge 10140208/20971520 39464 rootvg-rootlv-real: 0 52428800 linear rootvg-rootlv_snapshot: 0 52428800 error rootvg-rootlv_snapshot-cow: 0 20971520 linear rootvg-swaplv: 0 8388608 linear [root@kvm-testvm:~]# dmsetup status rootvg-rootlv: 0 52428800 snapshot-merge 6373616/20971520 24808 rootvg-rootlv-real: 0 52428800 linear rootvg-rootlv_snapshot: 0 52428800 error rootvg-rootlv_snapshot-cow: 0 20971520 linear rootvg-swaplv: 0 8388608 linear
The command has been run twice here with a small break in between and it shows the snapshot-merge going on in the background which may impact performance at the moment and it is not recommended to create any new snapshots while this is in progress but we can see the blocks that are remaining decreasing at a steady rate and the OS will take care of the rest once this is complete and the output will get back to something like:
[root@kvm-testvm:~]# dmsetup status rootvg-rootlv: 0 52428800 linear rootvg-swaplv: 0 8388608 linear
On Redhat there is a tools called boom-boot which will let you boot directly into a snapshot as you can not mount a snapshot at the same time while you have the file system actual file system open.
Booting into a snapshot using boom:
This may not work correctly if the root file system is split into multiple file systems (like separate var) and it may need additional tweaking.
To do this we need to install the boom-boot package first with "yum install boot-boom" - For this to be integrated into grub after the installation of that package we need to regenerate the grub config file with "grub2-mkconfig -o /boot/grub2/grub.cfg" on an EFI system depending on the Redhat version the grub config may be in another location such as /boot/efi/EFI/redhat/grub.cfg but on modern versions of RHEL this file is just a hook back to the original so do not overwrite the wrong file.
Now we need to create the boom OS profile with "boom profile create --from-host --uname-pattern el8" which can then be queried with "boom profile list"
"boom list" should now list the usual grub entries. So we are now in the position to create a boot entry on the fly:
boom create --title "Snapshot before changes" --rootlv rootvg/rootlv_snap
--backup can be specified on the above line so the kernel and initramfs will get backed up as well but I am going beyond on what this post was originally for.
Edited on: Mon, Nov 16, 2026 16:06
Posted in HowTo (RSS), System - Linux (RSS)
What version of SSL/TLS does my openssl support?
Posted on Mon, Mar 23, 2026 at 10:39 by Hubertus A. Haniel
This one I always have to look up as I don't use openssl very often and some people say that this is the solution:
openssl ciphers -v | awk '{print $2}' | sort -u
This is not actually correct as the second column list the minimum version for a cipher. - The way you can get it from the command line is using the help section from s_client with something like:
openssl s_client -help 2>&1 > /dev/null | egrep "\-(ssl|tls)[^a-z]"
Now the client can also be used to explore a remote web server to see what versions it supports with:
openssl s_client -connect {domain}:443 -servername {domain} -tls{version}
Edited on: Mon, Mar 23, 2026 11:44Posted in HowTo (RSS), System - Linux (RSS)
Extracting a user keytab for krb5 authentication without passwords.
Posted on Thu, Mar 05, 2026 at 16:15 by Hubertus A. Haniel
WARNING - The keytab must be kept safe as it can be used as a key on other systems!
So the problem at hand is for users that do not authenticate against AD and use an SSH key for like an SFTP job or for applications that run in the background and the kerberos ticket expires they will no longer be able to access the NFS filesystem but I have the need to encrypt the filesystem. How can we keep them authenticated.
For this we use ktutil to create our own keytab (ktutil is like a shell):
Run ktutil to enter the shell
In the shell we run "addent -password -p <user>@<REALM> -k 2 -e aes256-cts-hmac-sha1-96 -f" which will prompt you for the user password.
The "-f" flag may not be required but it will make sure that the "salt" is the same as kinit will use.
We can use "list -e" to view the result and then write it to a file with "wkt <filename.keytab>"
With "q" we can gracefully exit ktutil.
You should now be able to do a "kinit -kt <path to above created keytab> <user>@<REALM>"
If that works the keytab can be placed as <user>.keytab in /var/lib/gssproxy/clients/ and gssproxy will attempt to use it when that UID accesses the filesystem. - ONLY root should be able to read that keytab!
On RHEL8 /etc/gssproxy/99-nfs-client.conf actually looks for the keytab as <numerical UID>.keytab in /var/lib/gssproxy/clients/.
Edited on: Fri, Mar 06, 2026 14:06Posted in HowTo (RSS), System - Linux (RSS)
Disk/Filesystem benchmarking
Posted on Tue, Dec 30, 2025 at 16:23 by Hubertus A. Haniel
Note to self at the moment until I have more details on what I am actually trying to prove:
To test performance on file systems I have used the following command:
fio --name=rand --rw=randrw --bs=4k --iodepth=32 --numjobs=16 --runtime=600 --time_based --size=1G --directory=/filesystem
iozone -Rac -b test.xls is also something I am experimenting it but don't really understand the output of that yet.
Another tool that has been around for a long time is bonnie++ but I am not sure if it is still maintained
Edited on: Tue, Dec 30, 2025 16:45
Posted in HowTo (RSS), System - Linux (RSS)
Encrypted NFS
Posted on Thu, Sep 04, 2025 at 17:04 by Hubertus A. Haniel
After joining AD we can use kerberos to encrypt nfs traffic as well - Obviously the NFS server must be joined to the same AD domain.
To this we need to add a SPN on the server side (already explained in the previously mentioned blog) to the NFS server nfs/<server name>
It needs to be visible in the keytab with klist -ke.
Then we add the export to the exports file womething like:
/TEST *.localnet.lan(rw,sec=krb5:krb5i:krb5p,no_root_squash)
We only really want krb5p as that is fully encrypted.
Then we need to set the domain in /etc/idmapd.conf - It should be returned when you run "nfsidmap -d" - In my case this is localnet.lan.
Most problems are about this SPN - so my SPN is nfs/server.localnet.lan but and the server name is the same but my kerberos realm is upnor.localnet.lan so I had to add this to my /etc/krb5.conf file that is mentioned in the other blog.
[domain_realm] .localnet.lan = UPNOR.LOCALNET.LAN localnet.lan = UPNOR.LOCALNET.LAN .upnor.localnet.lan = UPNOR.LOCALNET.LAN upnor.localnet.lan = UPNOR.LOCALNET.LAN
I also added allow_weak_crypto - I am not sure it is required but in the
redhat manuals it does tell you to do that so for completeness my config
is now:
includedir /etc/krb5.conf.d/
[logging]
default = FILE:/var/log/krb5libs.log
kdc = FILE:/var/log/krb5kdc.log
admin_server = FILE:/var/log/kadmind.log
[libdefaults]
dns_lookup_realm = false
dns_lookup_kdc = false
ticket_lifetime = 24h
renew_lifetime = 7d
forwardable = true
rdns = false
pkinit_anchors = FILE:/etc/pki/tls/certs/ca-bundle.crt
spake_preauth_groups = edwards25519
default_realm = UPNOR.LOCALNET.LAN
default_ccache_name = KEYRING:persistent:%{uid}
allow_weak_crypto = true
[realms]
UPNOR.LOCALNET.LAN = {
kdc = 192.168.0.10
}
[domain_realm]
.localnet.lan = UPNOR.LOCALNET.LAN
localnet.lan = UPNOR.LOCALNET.LAN
.upnor.localnet.lan = UPNOR.LOCALNET.LAN
upnor.localnet.lan = UPNOR.LOCALNET.LAN
If we have done this all correctly we should be able to mount this export with something like "mount -t nfs -o nfsvers=4,sec=krb5p,proto=tcp" - We want krb5p as that fully encrypts all traffic while krb5 and krb5i only encrypt certain parts of the protocol which may be to insecure in some environments.
It should be noted that users have to have a kerberos ticket before they can read/write files on this mount and then the normal file permissions apply - However in an export the no_root_squash is actually irrelevant as root may be able to read stuff using the host credentials but root can not write to the file system as root can not get a kerberos ticket. There are workarounds to make that work but in general they are not recommended as they make your environment less secure again.
You may want to read my article about about ssh kerberos authentication and ticket delegation.
Some of the errors that can be encountered are very misleading. - For example I have come accross "an incorrect mount option was specified" - This had nothing to do with the mount options but can mean it is an error in the client configuration. - In my case the culprit was that rpc-gssd.service actually had died and I needed to manually start it.
You may notice that the no_root_squash option does not actually work with krb5. - There are various way to enable that but none are really recommended or even work as they will lower the security of your setup. RedHat have this article on that which would not work for me. - The ony way I was able to actually make that work with my setup is add the following to my realms section on the nfs server which will enable the client host linuxdev2 which will hold the host credential to be able to access shares as root (HOSTNAME$ is the actual computer account in AD and only root can use that to perform the initial mount):
[realms]
UPNOR.LOCALNET.LAN = {
kdc = 192.168.0.10
auth_to_local_names ={
LINUXDEV2$ = root
}
}
There are articles that explain how you can create a a root account
kerberos realm but that then means that root will also have to
authenticate with a password to perform the mount and mounts can not be
performed during boot out of fstab
Posted in HowTo (RSS), System - Linux (RSS)