From 5a8c5086bf3fc28236436ff3ef27196509f0375d Mon Sep 17 00:00:00 2001 From: Pavel Cahyna Date: Thu, 24 Aug 2023 11:41:25 +0200 Subject: [PATCH] Remove the lvmdevices file at the end of recovery The file /etc/lvm/devices/system.devices restricts LVM to disks with given (hardware) IDs (serial numbers, WWNs). See lvmdevices(8). Unfortunately, when restoring to different disks than in the original system, it will mean that LVM is broken in the recovered system (it won't find any disks). Therefore it is safer to remove the file to force the old behavior where LVM scans all disks. This used to be the LVM default (use_devicesfile=0). --- .../GNU/Linux/230_remove_lvmdevices.sh | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 usr/share/rear/finalize/GNU/Linux/230_remove_lvmdevices.sh diff --git a/usr/share/rear/finalize/GNU/Linux/230_remove_lvmdevices.sh b/usr/share/rear/finalize/GNU/Linux/230_remove_lvmdevices.sh new file mode 100644 index 0000000000..9392c9f52f --- /dev/null +++ b/usr/share/rear/finalize/GNU/Linux/230_remove_lvmdevices.sh @@ -0,0 +1,25 @@ +# Adapted from 260_rename_diskbyid.sh + +# Remove /etc/lvm/devices/system.devices +# The file restricts LVM to disks with given (hardware) IDs (serial +# numbers, WWNs). See lvmdevices(8). +# Unfortunately, when restoring to different disks than in the original +# system, it will mean that LVM is broken in the recovered system (it +# won't find any disks). Therefore it is safer to remove the file to +# force the old behavior where LVM scans all disks. This used to be the +# LVM default (use_devicesfile=0). + +# There may be other files under /etc/lvm/devices, but they are not used +# by default + +local file=/etc/lvm/devices/system.devices +local realfile + +realfile="$TARGET_FS_ROOT/$file" +# OK if file not found +test -f "$realfile" || return 0 +mv $v "$realfile" "$realfile.rearbak" +LogPrint "Renamed LVM devices file $realfile to $realfile.rearbak +to prevent LVM problems in the recovered system, verify that the file +is correct after booting the recovered system and move it back, or +regenerate it using vgimportdevices."