#3209 Issue closed: To get rid of message "A volume group called vg00 already exists."

Labels: fixed / solved / done, won't fix / can't fix / obsolete

gdha opened issue at 2024-04-23 15:04:

  • ReaR version ("/usr/sbin/rear -V"): rear-2.6

  • If your ReaR version is not the current version, explain why you can't upgrade: using the RH package rear-2.6-10.el8.x86_64 (on RHEL 8) or rear-2.6-21.el9_3.x86_64 (on RHEL 9)

  • OS version ("cat /etc/os-release" or "lsb_release -a" or "cat /etc/rear/os.conf"): RHEL 8.9 and/or RHEL 9.3

  • ReaR configuration files ("cat /etc/rear/site.conf" and/or "cat /etc/rear/local.conf"):

BACKUP=NETFS
BACKUP_OPTIONS="nfsvers=4,nolock"
NETFS_PREFIX=image
NETFS_KEEP_OLD_BACKUP_COPY=yes
AUTOEXCLUDE_DISKS=no
BACKUP_URL=nfs:...
  • Hardware vendor/product (PC or PowerNV BareMetal or ARM) or VM (KVM guest or PowerVM LPAR): VM

  • System architecture (x86 compatible or PPC64/PPC64LE or what exact ARM device): x86_64

  • Firmware (BIOS or UEFI or Open Firmware) and bootloader (GRUB or ELILO or Petitboot): BIOS

  • Storage (local disk or SSD) and/or SAN (FC or iSCSI or FCoE) and/or multipath (DM or NVMe): LVM

  • Storage layout ("lsblk -ipo NAME,KNAME,PKNAME,TRAN,TYPE,FSTYPE,LABEL,SIZE,MOUNTPOINT"):

#-> lsblk -ipo NAME,KNAME,PKNAME,TRAN,TYPE,FSTYPE,LABEL,SIZE,MOUNTPOINT
NAME                           KNAME      PKNAME    TRAN   TYPE FSTYPE      LABEL  SIZE MOUNTPOINT
/dev/sda                       /dev/sda                    disk LVM2_member        400G
`-/dev/mapper/vg02-lv00        /dev/dm-3  /dev/sda         lvm  ext3               400G /app/util
/dev/sdb                       /dev/sdb                    disk                     55G
|-/dev/sdb1                    /dev/sdb1  /dev/sdb         part ext3               512M /boot
`-/dev/sdb2                    /dev/sdb2  /dev/sdb         part LVM2_member       54.5G
  |-/dev/mapper/vg00-lv_root   /dev/dm-0  /dev/sdb2        lvm  ext3                13G /
  |-/dev/mapper/vg00-swap      /dev/dm-1  /dev/sdb2        lvm  swap                 4G
  |-/dev/mapper/vg00-lv_home   /dev/dm-4  /dev/sdb2        lvm  ext3                 8G /home
  |-/dev/mapper/vg00-lv_audit  /dev/dm-5  /dev/sdb2        lvm  ext3                 4G /var/log/audit
  |-/dev/mapper/vg00-lv_log    /dev/dm-6  /dev/sdb2        lvm  ext3                 4G /var/log
  |-/dev/mapper/vg00-lv_var    /dev/dm-7  /dev/sdb2        lvm  ext3              14.7G /var
  |-/dev/mapper/vg00-lv_tmp    /dev/dm-8  /dev/sdb2        lvm  ext3                 6G /var/tmp
  |-/dev/mapper/vg00-lv_openv  /dev/dm-9  /dev/sdb2        lvm  ext3                 7G /usr/openv
  `-/dev/mapper/vg00-lv_tanium /dev/dm-11 /dev/sdb2        lvm  ext3                 3G /opt/Tanium
/dev/sdc                       /dev/sdc                    disk LVM2_member         20G
|-/dev/mapper/vg00-lv_home     /dev/dm-4  /dev/sdc         lvm  ext3                 8G /home
|-/dev/mapper/vg00-lv_var      /dev/dm-7  /dev/sdc         lvm  ext3              14.7G /var
|-/dev/mapper/vg00-lv_tmp      /dev/dm-8  /dev/sdc         lvm  ext3                 6G /var/tmp
|-/dev/mapper/vg00-lv_openv    /dev/dm-9  /dev/sdc         lvm  ext3                 7G /usr/openv
`-/dev/mapper/vg00-lv_opt      /dev/dm-10 /dev/sdc         lvm  ext3                 7G /opt
/dev/sdd                       /dev/sdd                    disk LVM2_member        100G
`-/dev/mapper/vg01-lv00        /dev/dm-2  /dev/sdd         lvm  xfs                100G /var/lib/rancher
/dev/sr0                       /dev/sr0             sata   rom                    1024M
  • Description of the issue (ideally so that others can reproduce it): During recovery we saw the message:
+++ lvm vgcreate --physicalextentsize 4096k vg00 /dev/sda2 /dev/sde
 WARNING: Failed to connect to lvmetad. Falling back to device scanning.
 A volume group called vg00 already exists.
  • Workaround, if any:
    Add an extra line into script /usr/share/rear/layout/prepare/GNU/Linux/110_include_lvm_code.sh :
# diff 110_include_lvm_code.sh 110_include_lvm_code.sh.orig
137d136
< lvm vgremove $vg --force --yes >&2 || true

or more visual in script 110_include_lvm_code.sh:
if [ \$create_volume_group -eq 1 ] ; then
 LogPrint "Creating LVM VG '$vg'; Warning: some properties may not be preserved..."
 if [ -e "$vgrp" ] ; then
 rm -rf "$vgrp"
 fi
 lvm vgremove $vg --force --yes >&2 || true
 lvm vgcreate --physicalextentsize ${extentsize}k $vg ${devices[@]} >&2
 lvm vgchange --available y $vg >&2
fi

The fix has been tested out in real test recoveries of the past year of 2 as it is injected with a Chef recipe on +10K systems

  • Attachments, as applicable ("rear -D mkrescue/mkbackup/recover" debug log files):

gdha commented at 2024-04-29 12:52:

Current master branch already contains:

if IsInArray $vg "\${create_volume_group[@]}" ; then
    LogPrint "Creating LVM VG '$vg' (some properties may not be preserved)"
    lvm vgremove --force --force --yes $vg >&2 || true
    if [ -e "$vgrp" ] ; then
        rm -rf "$vgrp"
    fi
    lvm vgcreate --physicalextentsize ${extentsize}k $vg ${devices[@]} >&2
    lvm vgchange --available y $vg >&2
fi

Hereby - the fix is already implemented.

jsmeix commented at 2024-04-29 14:09:

For the log:
The line

    lvm vgremove --force --force --yes $vg >&2 || true

was added by @rmetrich via
https://github.com/rear/rear/commit/70acf6fa39b3d133c0a632e3496e5a273dc9ef27
that points to
https://github.com/rear/rear/pull/2564

gdha commented at 2024-04-29 14:26:

@jsmeix Thank you for the refreshment of ReaR history - should use it more often before submitting something. Luckily, it was only a waste on my time ;-)

gdha commented at 2024-04-29 14:28:

@pcahyna @rmetrich Just a note from side - why is this update not yet added to an official ReaR version of RedHat?

jsmeix commented at 2024-04-29 15:19:

@gdha
my pleasure!

FYI:
My favourite command for ReaR "archaeology"
e.g. as in this case here is

# git log -p --follow usr/share/rear/layout/prepare/GNU/Linux/110_include_lvm_code.sh | less

and then I am searching in 'less'
e.g. for \+.*vgremove in this case here.
I like this way because it shows me the real history
as 'diff -u' snippets plus git commit messages
which I find easy to understand because I get context.
In contrast 'git blame' does not tell about lines
which have been deleted or replaced,
cf. git help blame


[Export of Github issue for rear/rear.]