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 <shrikumar.sharma@windriver.com>
This commit is contained in:
Shrikumar Sharma 2023-01-16 14:34:12 +00:00
parent 68452f367b
commit ea1b8629e6
1 changed files with 18 additions and 1 deletions

View File

@ -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