tests: correctly mount the root and also the boot partitions for Fedora 35, 36 and rawhide Cloud Base Image
Fedora 33 and 34 Cloud Base Images have only one partition with the following directory structure, . ├── bin -> usr/bin ├── boot ├── dev ├── etc ├── home ├── root By comparison, Fedora 35, 36 and 37 Cloud Base Images have multiple partitions. The root partition which is the last partition has the following directory, . ├── home └── root ├── bin -> usr/bin ├── boot ├── dev ├── etc ├── home ├── root and the 2nd partition is the boot partition. This patch address the above changes by mounting {LAST_PARTITION}/root as to TEMP_ROOT and mount SECOND_PARTITION to TEMP_ROOT/boot. So the test image can be built successfully. Signed-off-by: Coiby Xu <coxu@redhat.com> Reviewed-by: Philipp Rudo <prudo@redhat.com>
This commit is contained in:
parent
4d1e02d340
commit
d347ad591f
@ -23,7 +23,7 @@ is_mounted()
|
||||
clean_up()
|
||||
{
|
||||
for _mnt in ${MNTS[@]}; do
|
||||
is_mounted $_mnt && $SUDO umount -f $_mnt
|
||||
is_mounted $_mnt && $SUDO umount -f -R $_mnt
|
||||
done
|
||||
|
||||
for _dev in ${DEVS[@]}; do
|
||||
@ -81,6 +81,17 @@ get_mountable_dev() {
|
||||
fi
|
||||
}
|
||||
|
||||
# get the separate boot partition
|
||||
# return the 2nd partition as boot partition
|
||||
get_mount_boot() {
|
||||
local dev=$1 _second_part=${dev}p2
|
||||
|
||||
if [[ $(lsblk -f $_second_part -n -o LABEL 2> /dev/null) == boot ]]; then
|
||||
echo $_second_part
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
prepare_loop() {
|
||||
[ -n "$(lsmod | grep "^loop")" ] && return
|
||||
|
||||
@ -133,7 +144,7 @@ image_lock()
|
||||
# Mount a device, will umount it automatially when shell exits
|
||||
mount_image() {
|
||||
local image=$1 fmt
|
||||
local dev mnt mnt_dev
|
||||
local dev mnt mnt_dev boot root
|
||||
|
||||
# Lock the image just in case user run this script in parrel
|
||||
image_lock $image
|
||||
@ -166,12 +177,20 @@ mount_image() {
|
||||
|
||||
$SUDO mount $mnt_dev $mnt
|
||||
[ $? -ne 0 ] && perror_exit "failed to mount device '$mnt_dev'"
|
||||
boot=$(get_mount_boot "$dev")
|
||||
if [[ -n "$boot" ]]; then
|
||||
root=$(get_image_mount_root $image)
|
||||
$SUDO mount $boot $root/boot
|
||||
[ $? -ne 0 ] && perror_exit "failed to mount the bootable partition for device '$mnt_dev'"
|
||||
fi
|
||||
}
|
||||
|
||||
get_image_mount_root() {
|
||||
local image=$1
|
||||
local root=${MNTS[$image]}
|
||||
|
||||
# Starting from Fedora 36, the root node is /root/root of the last partition
|
||||
[ -d "$root/root/root" ] && root=$root/root
|
||||
echo $root
|
||||
|
||||
if [ -z "$root" ]; then
|
||||
@ -213,7 +232,7 @@ run_in_image() {
|
||||
|
||||
inst_in_image() {
|
||||
local image=$1 src=$2 dst=$3
|
||||
local root=${MNTS[$image]}
|
||||
local root=$(get_image_mount_root $1)
|
||||
|
||||
$SUDO cp $src $root/$dst
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user