BOOM is a boot manager for Linux systems that support the 'BootLoader Specification' for boot entry configuration (ie: RHEL8 with GRUB2). It simplifies the creation of new or modified boot entries: for example, to boot snapshot images of the system created using LVM.
BOOM does not modify the existing boot loader configuration, and only inserts additional entries. The existing configuration is maintained, and any distribution integration, such as kernel installation and update scripts, continue to function as before.
BOOM also has a simple command-line interface (CLI) and API.
Starting on the host workstation.example.com, let’s ssh over to node3.example.com. No password should be required.
ssh node3.example.com
Verify that you are on the right host for these exercises.
cheat-boom-checkhost.sh
Now you are ready to begin
The following set of instructions will install Boom.
yum install -y boom-boot
That was easy!
In order to support LVM snapshots on the root volume, we need to: * add some additional storage capacity * partition the disk * add the partition to the root volume group * and finally create logical volume to support the snapshot
The following command will take care of all of these steps for you. The individual steps are also outlined below.
cheat-boom-addstorage.sh
ℹ️
|
Native command(s) to add storage printf "o\nn\np\n\n\n\nw\n" | fdisk /dev/vdb pvcreate /dev/vdb1 vgextend rhel /dev/vdb1 |
Clearing /dev/vdb
Creating new partition table on /dev/vdb
Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0xb8fd7055.
Command (m for help): Created a new DOS disklabel with disk identifier 0x4e3b8150.
Command (m for help): Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): Partition number (1-4, default 1): First sector (2048-20971519, default 2048): Last sector, +sectors or +size{K,M,G,T,P} (2048-20971519, default 20971519):
Created a new partition 1 of type 'Linux' and of size 10 GiB.
Command (m for help): The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
Creating physical volume lable on /dev/vdb1
Physical volume "/dev/vdb1" successfully created.
Extending volume group 'rhel' with /dev/vdb1
Volume group "rhel" successfully extended
Reducing COW size 10.00 GiB down to maximum usable size <8.03 GiB.
Logical volume "root_snapshot" created.
The next set of instructions will create a file and a userID that we will remove and recover as part of this exercise:
cheat-boom-importantstuff.sh
ℹ️
|
Native command(s) to create important file echo "This is an important file!!" > /root/importantfile useradd importantuser cat /root/importantfile grep importantuser /etc/passwd |
Contents of 'importantfile':
This is an important file!!
Grepping 'importantuser' from /etc/passwd:
importantuser:x:1001:1001::/home/importantuser:/bin/bash
Now that we have created some important data, it’s time to create a snapshot of our system.
cheat-boom-snapshot.sh
ℹ️
|
Native command(s) to create lvm snapshot lvcreate -s rhel/root -n root_snapshot -L 10G |
Let us take a quick look at what we just did.
cheat-boom-lvreport.sh
ℹ️
|
Native command(s) to report lv status lvs -a -o lv_name,lv_size,lv_attr,segtype,devices lvs -a -o lv_name,lv_size,lv_attr,origin,snap_percent |
This script uses different options to create 2 different reports.
Local volume reports:
LV LSize Attr Type Devices
root <8.00g owi-aos--- linear /dev/vda2(256)
root_snapshot <8.03g swi-a-s--- linear /dev/vdb1(0)
swap 1.00g -wi-ao---- linear /dev/vda2(0)
LV LSize Attr Origin Snap%
root <8.00g owi-aos---
root_snapshot <8.03g swi-a-s--- root 0.01
swap 1.00g -wi-ao----
In your output, note the percentage used in the new snapshot as shown by the 2nd report.
Since we have made no real changes to our system, the percentage of the "exception store" used is still very small. Let’s change that.
Now we are going to remove the “importantfile” file and “importantuser” userID.
rm -f /root/importantfile userdel importantuser
What the heck, let’s anti up and delete some more stuff. Who needs documentation anyway!
rm -rf /usr/share/man rm -rf /usr/share/doc rm -rf /usr/share/GeoIP
Confirm that our changes were effective
cat /root/importantfile grep -c importantuser /etc/passwd
ℹ️
|
"grep -c" counts how many time the token is matched. In our case it should be zero |
cat: /root/importantfile: No such file or directory
0
Analyze the snapshot data and we see that there is now a measurable difference.
cheat-boom-lvreport.sh
Local volume reports:
LV LSize Attr Type Devices
root <8.00g owi-aos--- linear /dev/vda2(256)
root_snapshot <8.03g swi-a-s--- linear /dev/vdb1(0)
swap 1.00g -wi-ao---- linear /dev/vda2(0)
LV LSize Attr Origin Snap%
root <8.00g owi-aos---
root_snapshot <8.03g swi-a-s--- root 0.38
swap 1.00g -wi-ao----
Let’s summarize what’s been done so far:
-
you added some storage capacity to the root volume
-
you created an "importantfile" and an "importantuser" on your host
-
you created a snapshot of the root volume
-
you then made some changes to the host (deleted a bunch of stuff)
Time to boot our host using the snapshot value, inspect the host to verify our data is there and then finally recover the host.
Create a boom profile.
cheat-boom-mkprofile.sh
ℹ️
|
Native command(s) to create boom profile boom profile create --from-host --uname-pattern el8 |
Created profile with os_id e6f881a:
OS ID: "e6f881ae3f8a2e010375fb840bb4f386b330db6e",
Name: "Red Hat Enterprise Linux", Short name: "rhel",
Version: "8.0 (Ootpa)", Version ID: "8.0",
UTS release pattern: "el8",
Kernel pattern: "/vmlinuz-%{version}", Initramfs pattern: "/initramfs-%{version}.img",
Root options (LVM2): "rd.lvm.lv=%{lvm_root_lv}",
Root options (BTRFS): "rootflags=%{btrfs_subvolume}",
Options: "root=%{root_device} ro %{root_opts}"
Verify that the boom profile was created by the previous command.
boom profile list
OsID Name OsVersion
e6f881a Red Hat Enterprise Linux 8.0 (Ootpa)
Now to create a boot entry for grub which utilizes the snapshot as the boot volume.
cheat-boom-mkgrub.sh
ℹ️
|
Native command(s) to create grub entry boom create --title "root LV snapshot" --rootlv rhel/root_snapshot |
WARNING - Boom grub2 script missing from '/etc/grub.d'
WARNING - Boom configuration not found in grub.cfg
WARNING - Run 'grub2-mkconfig > /boot/grub2/grub.cfg' to enable
Created entry with boot_id 85e739d:
title root LV snapshot
machine-id e988045b45b04b11b84741d6a568861b
version 4.18.0-67.el8.x86_64
linux /vmlinuz-4.18.0-67.el8.x86_64
initrd /initramfs-4.18.0-67.el8.x86_64.img
options root=/dev/rhel/root_snapshot ro rd.lvm.lv=rhel/root_snapshot
Take a look at currently configured boom-boot entries.
boom entry list
Your output should look like this.
BootID Version Name RootDevice
85e739d 4.18.0-67.el8.x86_64 Red Hat Enterprise Linux /dev/rhel/root_snapshot
Show details about our boom-boot entry.
boom entry show 85e739d
Boot Entry (boot_id=85e739d)
title root LV snapshot
machine-id e988045b45b04b11b84741d6a568861b
version 4.18.0-67.el8.x86_64
linux /vmlinuz-4.18.0-67.el8.x86_64
initrd /initramfs-4.18.0-67.el8.x86_64.img
options root=/dev/rhel/root_snapshot ro rd.lvm.lv=rhel/root_snapshot
|
Bring up the virtual machine console for node3 before proceeding. |
Before reboot, there are 2 options to invoke the right loader at restart: . enter the GRUB menu and select at boot time . use grub-set-default to preselect which one to load
We are going to opt for preselect since it’s just easier. Use the following cheat to inspect the currently configured GRUB menu options.
cheat-boom-grublist.sh
0 title="root LV snapshot"
1 title="Red Hat Enterprise Linux (4.18.0-67.el8.x86_64) 8.0 (Ootpa)"
2 title="Red Hat Enterprise Linux (0-rescue-e988045b45b04b11b84741d6a568861b) 8.0 (Ootpa)"
We want to reboot to our snapshot, so in this case we use '0'.
grub2-set-default 0
Verify that the parameters stuck
grub2-editenv list
Notice that "saved_entry=0", that’s what we want.
saved_entry=0
kernelopts=root=/dev/mapper/rhel-root_snapshot ro crashkernel=auto resume=/dev/mapper/rhel-swap rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap rhgb quiet
boot_success=0
We will now reset our host and boot the snapshot Logical Volume.
reboot
Once the host is back online, ssh to back to node3.example.com and verify that the “importantfile” and “importantuser” exist in the backup snapshot:
ssh root@node3.example.com
df /
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/rhel-root_snapshot 8374272 1321268 7053004 16% /
Let’s find our data.
cat /root/importantfile grep importantuser /etc/passwd du -sh /usr/share/doc du -sh /usr/share/GeoIP man bash
Wahoo! Man pages are back! It should be clear that the data removed earlier is still present within the snapshot volume. Now it’s time to recover the data.
ℹ️
|
You can technically initiate the logical volume merge now, set the grub default back to the normal boot entry, and reboot as merging requires a unmount before anything happens and once it’s initiated it can work in the background. But, we are going to utilize the rescue image for extra fun! |
|
Bring up the virtual machine console for node3 before proceeding. |
We will now reboot node3 virtual machine again into rescue mode and return the host to it’s previous state.
cheat-boom-grublist.sh
0 title="root LV snapshot"
1 title="Red Hat Enterprise Linux (4.18.0-67.el8.x86_64) 8.0 (Ootpa)"
2 title="Red Hat Enterprise Linux (0-rescue-e988045b45b04b11b84741d6a568861b) 8.0 (Ootpa)"
We want to reboot to recuse mode, so in this case we use '2'.
grub2-set-default 2
Let’s go…
reboot
Once the host is back online, ssh to back to node3.example.com.
ssh root@node3.example.com
df / cat /proc/cmdline
The output shows that we are no longer mounted to the snapshot volume, and we ARE using the rescue kernel image.
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/rhel-root 8374272 1230660 7143612 15% /
.[root@node3 ~]# cat /proc/cmdline
BOOT_IMAGE=(hd0,msdos1)/vmlinuz-0-rescue-e988045b45b04b11b84741d6a568861b root=/dev/mapper/rhel-root ro crashkernel=auto resume=/dev/mapper/rhel-swap rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap rhgb quiet
Time return the host back to it’s previous state.
lvconvert --merge /dev/rhel/root_snapshot
As pointed out earlier, the "merge" will being the next time the root volume is mounted. This output merely confirms this.
Delaying merge since origin is open.
Merging of snapshot rhel/root_snapshot will occur on next activation of rhel/root.
Last few steps and we will be done.
Set grub to boot default OS again.
cheat-boom-grublist.sh
0 title="root LV snapshot"
1 title="Red Hat Enterprise Linux (4.18.0-67.el8.x86_64) 8.0 (Ootpa)"
2 title="Red Hat Enterprise Linux (0-rescue-e988045b45b04b11b84741d6a568861b) 8.0 (Ootpa)"
This time we want entry '1'.
grub2-set-default 1
reboot
We have now returned the host to it’s previous state (ie: the moment we created the snapshot with boom). Let’s make sure everything is where we expect.
ssh root@node3.example.com
cat /root/importantfile grep importantuser /etc/passwd
This is an important file!!
Last piece of information. Since the "snapshot" was merged back into it’s "origin", the snapshot itself is now gone. You can confirm this by running "lvs" and noting that the root_snapshot is missing.
lvs
Thus our boom-boot entry points to a non-existent volume. Here are the final commands to clean everything up.
boom entry list
BootID Version Name RootDevice
85e739d 4.18.0-67.el8.x86_64 Red Hat Enterprise Linux /dev/rhel/root_snapshot
Make note of the BootID and use it in the next command.
boom entry delete 85e739d
Double check the grub configuration.
cheat-boom-grublist.sh
Note that the snapshot entry has been removed.
0 title="Red Hat Enterprise Linux (4.18.0-67.el8.x86_64) 8.0 (Ootpa)"
1 title="Red Hat Enterprise Linux (0-rescue-e988045b45b04b11b84741d6a568861b) 8.0 (Ootpa)"
Make sure grub is configured to boot the entry.
grub2-editenv list
saved_entry=1
kernelopts=root=/dev/mapper/rhel-root ro crashkernel=auto resume=/dev/mapper/rhel-swap rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap rhgb quiet
boot_success=0
Whoops! That’s not right
grub2-set-default 0
Wahoo! You are done. If you have any questions, please ask.