According to the VMware KB89798 you might have to prepare your vCenter(s) for LVM Snapshots. It’s a feature in vCenter 8 to use LVM snapshots when you upgrade vCenter. According to the KB89798 this is related to vCenter 6.0.x and 7.0.x. For one of my customers test environment, this was necessary to do/fix on their vCenter 8U2.
You would see the problem if you upgrade from VAMI interface. If vCenter isn’t ready for LCM snapshots you would see a warning, which you can ignore if you want, or fix with the script in the KB, but need a small hack itself to work on 8U2, which I will show below.
Warning messages says:
| Warning | LVM Snapshot based auto-backup of vCenter Server will not be taken during vcenter patching. |
| Resolution | Please ensure a valid LVM snapshot disk and altroot disk is present on vCenter Server and LVM snapshot disk has sufficient space available on it to take the backup. |
On the KB page you will find a script attached, prepare_vc_for_lvm_snapshot (direct link, but to be safe and sure, use the link from the KB). Download this. For me to get this to work on vCenter 8U2b, I had to edit the script. On line 188, change it from this:
local dmi_uuid=$(/usr/sbin/dmidecode | grep UUID |awk '{print $2}')
to this:
local dmi_uuid=$(/usr/sbin/dmidecode | grep UUID |awk '{print $2}') | tr '[:lower:]' '[:upper:]')
Before the change, the script could not find the vm_id and thus fails to add disk:
root@testvc01 [ ~ ]# ./prepare_vc_for_lvm_snapshot.sh
Enter SSO user name : administrator@vsphere.local
Enter SSO password : ********************
Enter SDK port ( default : 443 ) : 443
INFO Root is on LVM
INFO Snapshot volume is not configured
INFO Root is on LVM
INFO Calculate disksize and add disk
ERROR Failed to get vm_id
ERROR Failed to add disk
After changing the script, the script works fine and adds the snapshot volume and configure the vCenter for LVM Snapshots:
root@testvc01 [ ~ ]# ./prepare_vc_for_lvm_snapshot.sh
Enter SSO user name : administrator@vsphere.local
Enter SSO password : ********************
Enter SDK port ( default : 443 ) :443
INFO Root is on LVM
INFO Snapshot volume is not configured
INFO Root is on LVM
INFO Calculate disksize and add disk
INFO Scanning for disk changes
INFO Configuring snapshot volume
INFO Preparing /dev/sds to configure snapshot volume
INFO Creating physical volume on /dev/sds
Physical volume "/dev/sds" successfully created.
INFO Creating volume group vg_lvm_snapshot
Volume group "vg_lvm_snapshot" successfully created
INFO Creating logical volume lv_lvm_snapshot
Logical volume "lv_lvm_snapshot" created.
INFO Creating file system for snapshot volume
mke2fs 1.46.5 (30-Dec-2021)
Creating filesystem with 59102208 4k blocks and 14778368 inodes
Filesystem UUID: ce95e006-5465-49e0-b77c-5ef9b7bc4041
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872
Allocating group tables: done
Writing inode tables: done
Creating journal (262144 blocks): done
Writing superblocks and filesystem accounting information: done
Successfully configured snapshot volume
### Checking the result:
root@testvc01 [ ~ ]# ./prepare_vc_for_lvm_snapshot.sh --precheck
INFO Check if LVM is enabled on root and snapshot disk is configured.
INFO Root is on LVM
INFO Snapshot volume is already configured
VC is prepared for LVM snapshot.