Change name for a vg with rootfs on Ubuntu 1804 onward

In our dev enviroment, we use several KVM desktop machine to create lot VMs to test all kinds of new stuff.
Compared with CentOS 7, Ubuntu 1804 or 1904 are more easy to install any new software just with apt install, don’t even need to update package list.

Though we found Ubuntu had big issue in change the vg name or doing what ever LVM init (aka virt-sysprep) . We already found the solution to it. But for regular Ubuntu VG name change, we still should have a separate way to do. Here it is.

  1. # vgrename oldvg newvg
  2. # perl -p -i -e ‘s/oldvg/newvg/g’ /etc/fstab /boot/grub/grub.cfg /etc/initramfs-tools/conf.d/resume
    if vg name contain dash (“-“), we need to run one more time with this:
    # perl -p -i -e ‘s/oldvg–/newvg–/g’ /etc/fstab /boot/grub/grub.cfg /etc/initramfs-tools/conf.d/resume
  3. # /sbin/update-initramfs -c -k all

作者: 甬洁网络