From ea1b8629e67dcf9a047ad2175e9f720d7190205b Mon Sep 17 00:00:00 2001 From: Shrikumar Sharma Date: Mon, 16 Jan 2023 14:34:12 +0000 Subject: [PATCH] Fix for detection of existing file system in the prestage process During prestage with a prestage iso, the existing filesystem must not be overwritten if an installation with an install_guid exists, when the force_install parameter is not specified. However, when logical volumes are used, the check for a valid installation does not succeed, resulting in the installer overwriting the existing installation. This commit fixes this issue by inspecting the volume for an installation. This commit also ensures that if an invalid storage device is specified for root device, then a failure is reported and the system breaks into a bash shell. Test Plan: PASS: Verify that the installer does not overwrite an existing installation with an install_guid. PASS: Verify that the installer reports an error and breaks into a bash shell if an invalid storage device is specified for root device. Closes-Bug: 2002999 Change-Id: I1d4ef10ce741b98455c65467367448e05f37fd64 Signed-off-by: Shrikumar Sharma --- kickstart/files/kickstart.cfg | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/kickstart/files/kickstart.cfg b/kickstart/files/kickstart.cfg index 042a14df..b7717570 100644 --- a/kickstart/files/kickstart.cfg +++ b/kickstart/files/kickstart.cfg @@ -1028,6 +1028,10 @@ if check_prestage -eq 0 ; then orig_rootfs_device=$rootfs_device by_path_rootfs_device=$(get_by_path ${rootfs_device}) + if [ -z "${by_path_rootfs_device}" ]; then + report_failure_with_msg "Device not found: ${orig_rootfs_device}" + fi + rootfs_device=$(get_disk ${by_path_rootfs_device}) ilog "Found rootfs $orig_rootfs_device on: $by_path_rootfs_device->$rootfs_device." @@ -1049,9 +1053,22 @@ if check_prestage -eq 0 ; then mkdir -p ${temp_mount} ilog "Searching for existing installation..." + + device_list=() for part in "${part_numbers[@]}"; do device=${ROOTFS_PART_PREFIX}${part} - ilog "Searching on ${device}" + device_list+=(${device}) + ilog "Adding ${device}" + done + + # adding the following device to the device list to search + # for the filesystem. If Volume Groups have been enabled, + # it is possible to perform the checks for install_guid below + # by mounting /dev/cgts-vg/var-lv. + device_list+=("/dev/cgts-vg/var-lv") + ilog "Adding /dev/cgts-vg/var-lv" + + for part in "${device_list[@]}"; do # mount this part at a temporary mount point mount ${device} ${temp_mount} if [ $? -ne 0 ]; then