Force installation of prestage iso when force_install option is

provided through the kernel commandline

When there is an existing installation on the subcloud, the
kickstart will ensure that it is not overwritten by the prestaged
iso.

However, when the force_install option is provided via the kernel
commandline, the existing installation can be overwritten.

Test Plan:
PASS: Verify that the prestage iso overwrites the existing
      installation when the force_install option is provided at
      the kernel commandline.

PASS: Verify that the installation halts with a message, if there
      is an existing installation and force_install option is
      not provided at the kernel commandline.

PASS: Verify that the prestage iso installs when there is no
      pre-existing installation and force_install is provided

PASS: Verify that above tests pass on NVMe-based systems

Regression:
PASS: Verify that the prestage iso installs without force_install
      and no installation exists

Story: 2009948
Task: 44914

Signed-off-by: Shrikumar Sharma <shrikumar.sharma@windriver.com>
Change-Id: I2491d80cb4e07aa2fb38381c9e92afd7549526ef
This commit is contained in:
Shrikumar Sharma 2022-04-01 14:25:02 -04:00
parent 3ac0bcfd99
commit dc3bfbf164
1 changed files with 57 additions and 48 deletions

View File

@ -11,39 +11,43 @@ wlog "pre prestaging install check"
# First, parse /proc/cmdline to find the boot args
set -- `cat /proc/cmdline`
for I in $*; do case "$I" in *=*) eval $I 2>/dev/null;; esac; done
for J in $*; do case "$J" in force_install) force_install=${J};; esac; done
if [ -z "$rootfs_device" ]; then
# if force_install is set, install anyway. Ignore the remainder of this section.
if [ -z ${force_install} ]; then
if [ -z "$rootfs_device" ]; then
rootfs_device=$(get_disk_dev)
fi
fi
orig_rootfs_device=$rootfs_device
by_path_rootfs_device=$(get_by_path $rootfs_device)
rootfs_device=$(get_disk $by_path_rootfs_device)
wlog "Found rootfs $orig_rootfs_device on: $by_path_rootfs_device->$rootfs_device."
orig_rootfs_device=$rootfs_device
by_path_rootfs_device=$(get_by_path $rootfs_device)
rootfs_device=$(get_disk $by_path_rootfs_device)
wlog "Found rootfs $orig_rootfs_device on: $by_path_rootfs_device->$rootfs_device."
part_numbers=( $(parted -s ${rootfs_device} print | awk '$1 == "Number" {i=1; next}; i {print $1}') )
# print the partnumber info for informational purposes
for i in ${part_numbers[@]}; do
part_numbers=( $(parted -s ${rootfs_device} print | awk '$1 == "Number" {i=1; next}; i {print $1}') )
# print the partnumber info for informational purposes
for i in ${part_numbers[@]}; do
wlog "partnumber: ${i}"
done
done
# Get the correct rootfs prefix
ROOTFS_PART_PREFIX=${rootfs_device}
# check if rootfs part is nvme (eg. /dev/nvme0n1). The partitions have a "p" in the part prefix.
# for example, /dev/nvme0n1p1
# so we need to add the letter "p" to get the prefix.
# The part numbers will be used later in the code.
case $rootfs_device in
# Get the correct rootfs prefix
ROOTFS_PART_PREFIX=${rootfs_device}
# check if rootfs part is nvme (eg. /dev/nvme0n1). The partitions have a "p" in the part prefix.
# for example, /dev/nvme0n1p1
# so we need to add the letter "p" to get the prefix.
# The part numbers will be used later in the code.
case $rootfs_device in
*"nvme"*)
ROOTFS_PART_PREFIX=${ROOTFS_PART_PREFIX}p
;;
esac
esac
# temporary mount directory
temp_mount=/mnt
# temporary mount directory
temp_mount=/mnt
wlog "Searching for existing installation..."
for part in "${part_numbers[@]}"; do
wlog "Searching for existing installation..."
for part in "${part_numbers[@]}"; do
device=${ROOTFS_PART_PREFIX}${part}
wlog "Searching on ${device}"
# mount this part at a temporary mount point
@ -60,7 +64,12 @@ for part in "${part_numbers[@]}"; do
# do not modify the system in any way
report_pre_failure_with_msg "Prestage rejected. Existing installation detected. Please eject the media before rebooting."
fi
wlog "Unmounting ${device}"
umount ${temp_mount}
done
done
wlog "Installing Prestaged content. No existing installation found."
else
# force install inspite of existing installation
wlog "Force install the prestage content"
wlog "Installing Prestaged content. All existing installations will be lost."
fi
%end