Hello, friends. In this post, you will learn how to rename the volume group for root and swap using Alma Linux 9
First steps
For this post, an Alma Linux 9 installation using LVM is assumed. So, this should not be a problem.
First, log in as root or some other user with root permissions.
It never hurts to update the system and install dracut
dnf update && dnf install dracut
After that, reboot the system.
Then, check the current configuration
vgs
Sample output
VG #PV #LV #SN Attr VSize VFree
almalinux 1 2 0 wz--n- <31.00g 0
Now check the configuration of the group
lvs almalinux
You will get an output screen like this
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root almalinux -wi-ao---- <28.77g
swap almalinux -wi-ao---- <2.23g
Remember that the name may change on your system.
Rename the volume group for root and swap on Alma Linux 9
Now rename the group with the following command
vgrename almalinux vg-root
Volume group "almalinux" successfully renamed to "vg-root"
Then, verify the change
vgs
As you have changed the volume, you need to update the /etc/fstab
file
vi /etc/fstab
And replace all references to the old name with the new one. Then, save the changes and close the editor.
We have to do the same with the grub file /boot/grub2/grub.cfg
.
sed -i 's/almalinux/root-vg/g' /boot/grub2/grub.cfg
Verify changes
cat /boot/grub2/grub.cfg | grep root-vg
Sample output
set kernelopts="root=/dev/mapper/root-vg-root ro crashkernel=1G-4G:192M,4G-64G:256M,64G-:512M resume=/dev/mapper/root-vg-swap rd.lvm.lv=root-vg/root rd.lvm.lv=root-vg/swap rhgb quiet "
Then activate the volume group
vgchange -ay
2 logical volume(s) in volume group "vg-root" now active
And refresh the logical volume attributes
lvchange /dev/vg-root/root --refresh
lvchange /dev/vg-root/swap --refresh
The last step is to create a new initial ramdisk. To achieve this, verify its existence.
ls -al /boot/
Then, back it up
cp /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r).img.$(date +%m-%d-%H%M%S).bak
And generate a new one.
mkinitrd -f -v /boot/initramfs-$(uname -r).img $(uname -r)
Remember that if you upgraded the kernel, you have to do it if there are other initramfs.
That’s all.