Make root and var filesystems LVM based

Add two patches to update the init and lat-installer scripts to
- fully parameterize ostree boot and root devices for A and B locations
  so that devices can be specified
- add support for specifying an ostree var device that will be used for
  the dynamic R/W data. This was previously specified by a hard coded
  'LABEL=fluxdata' partition.

Rename patches 0003-0008 as former patch 0002 was removed with a
previous commit.

Test Plan:
- PASS: BIOS AIO-SX
- PASS: UEFI AIO-SX
- PASS: BIOS 2+2+2
- SKIP: secure boot, not ready for Stx8.0
- PASS: AIO-SX upgrade
- PASS: duplex upgrade
- PASS: DC subcloud install (virtual test)

Change-Id: I9fbe3fc89b05743b9c6090c05d3d011e2ba48eda
Story: 2010444
Task: 46883
Signed-off-by: Robert Church <robert.church@windriver.com>
This commit is contained in:
Robert Church 2022-11-18 01:10:42 -06:00 committed by Dan Voiculeasa
parent 1f37f8b5d4
commit 95a9d2d699
9 changed files with 274 additions and 17 deletions

View File

@ -8,10 +8,10 @@ Signed-off-by: Jim Somerville <jim.somerville@windriver.com>
1 file changed, 6 insertions(+)
diff --git a/init-ostree-install.sh b/init-ostree-install.sh
index 1a53f3c..7f7f925 100644
index 0e5b8f3..51fb6a0 100644
--- a/init-ostree-install.sh
+++ b/init-ostree-install.sh
@@ -1549,6 +1549,12 @@ if [ -d /sys/firmware/efi/efivars ] ;then
@@ -1540,6 +1540,12 @@ if [ -d /sys/firmware/efi/efivars ] ;then
fi
fi

View File

@ -16,7 +16,7 @@ Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/init-ostree-install.sh b/init-ostree-install.sh
index 7f7f925..a302abc 100644
index 51fb6a0..79496e0 100644
--- a/init-ostree-install.sh
+++ b/init-ostree-install.sh
@@ -528,9 +528,9 @@ fatal() {

View File

@ -16,7 +16,7 @@ Signed-off-by: Dan Voiculeasa <dan.voiculeasa@windriver.com>
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/init-ostree-install.sh b/init-ostree-install.sh
index a302abc..4dc3079 100644
index 79496e0..befeac7 100644
--- a/init-ostree-install.sh
+++ b/init-ostree-install.sh
@@ -920,7 +920,9 @@ if [ "$INSTSH" = 1 -o "$INSTSH" = 3 -o "$INSTSH" = 4 ] ; then

View File

@ -20,7 +20,7 @@ Signed-off-by: Zhang Xiao <xiao.zhang@windriver.com>
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/init-ostree-install.sh b/init-ostree-install.sh
index 4dc3079..41bae2a 100644
index befeac7..46a0c08 100644
--- a/init-ostree-install.sh
+++ b/init-ostree-install.sh
@@ -1480,11 +1480,11 @@ else

View File

@ -20,7 +20,7 @@ Signed-off-by: Robert Church <robert.church@windriver.com>
1 file changed, 93 insertions(+), 66 deletions(-)
diff --git a/init-ostree-install.sh b/init-ostree-install.sh
index 41bae2a..2c6fd57 100644
index 46a0c08..98cfb2b 100644
--- a/init-ostree-install.sh
+++ b/init-ostree-install.sh
@@ -93,6 +93,8 @@ OPTIONAL:

View File

@ -1,7 +1,6 @@
From e5f3bfdb1bf1438d4d1c4b2625eb8830b554cf69 Mon Sep 17 00:00:00 2001
From: Jiping Ma <jiping.ma2@windriver.com>
Date: Thu, 3 Nov 2022 20:39:50 -0700
Subject: [PATCH] Make driver switch more adaptable
Subject: Make driver switch more adaptable
This commit makes it flexible to address future requirements.
It will load drivers based on multi-drivers-switch=version, if the
@ -78,6 +77,3 @@ index b6eacbf..d0b0dda 100644
[ -z "$CONSOLE" ] && CONSOLE="/dev/console"
[ -z "$INIT" ] && INIT="/sbin/init"
--
2.35.1

View File

@ -0,0 +1,83 @@
From e90857af6b969e6507c727335c12a19c1a2ef2c4 Mon Sep 17 00:00:00 2001
From: Robert Church <robert.church@windriver.com>
Date: Wed, 16 Nov 2022 15:07:07 -0600
Subject: Allow specifying boot/root devices for installs
This adds the capability to set specific root devices for A/B
boot/root devices that will control where ostree installation occurs.
Signed-off-by: Robert Church <robert.church@windriver.com>
---
init-ostree-install.sh | 24 ++++++++++++++++++++----
1 file changed, 20 insertions(+), 4 deletions(-)
diff --git a/init-ostree-install.sh b/init-ostree-install.sh
index 98cfb2b..d54185a 100644
--- a/init-ostree-install.sh
+++ b/init-ostree-install.sh
@@ -95,6 +95,10 @@ OPTIONAL:
inststx=1 - Skip LAT partitioning scheme (StarlingX).
Only call %part ks hook to partition
+ inst_ostree_boot=DEVICE - Specify the ostree boot device
+ inst_ostree_boot_b=DEVICE - Specify the ostree boot_b device
+ inst_ostree_root=DEVICE - Specify the ostree root device
+ inst_ostree_root_b=DEVICE - Specify the ostree root_b device
EOF
}
@@ -572,6 +576,10 @@ KERNEL_PARAMS=""
IP=""
MAX_TIMEOUT_FOR_WAITING_LOWSPEED_DEVICE=60
OSTREE_KERNEL_ARGS=${OSTREE_KERNEL_ARGS=%OSTREE_KERNEL_ARGS%}
+OSTREE_BOOT_DEVICE=${OSTREE_BOOT_DEVICE="LABEL=otaboot"}
+OSTREE_ROOT_DEVICE=${OSTREE_ROOT_DEVICE="LABEL=otaroot"}
+OSTREE_BOOT_B_DEVICE=${OSTREE_BOOT_B_DEVICE="LABEL=otaboot_b"}
+OSTREE_ROOT_B_DEVICE=${OSTREE_ROOT_B_DEVICE="LABEL=otaroot_b"}
KS=""
if [ "$OSTREE_KERNEL_ARGS" = "%OSTREE_KERNEL_ARGS%" ] ; then
@@ -677,6 +685,16 @@ read_args() {
VSZ=$optarg ;;
inststx=*)
INSTSTX=$optarg ;;
+ instiso=*)
+ ISO_INSTLABEL=$optarg ;;
+ inst_ostree_boot=*)
+ OSTREE_BOOT_DEVICE=$optarg ;;
+ inst_ostree_root=*)
+ OSTREE_ROOT_DEVICE=$optarg ;;
+ inst_ostree_boot_b=*)
+ OSTREE_BOOT_B_DEVICE=$optarg ;;
+ inst_ostree_root_b=*)
+ OSTREE_ROOT_B_DEVICE=$optarg ;;
esac
done
# defaults if not set
@@ -1283,8 +1301,6 @@ fi
# OSTree deploy
PHYS_SYSROOT="/sysroot"
-OSTREE_BOOT_DEVICE="LABEL=otaboot"
-OSTREE_ROOT_DEVICE="LABEL=otaroot"
mount_flags="rw,noatime"
if [ -x /init.ima ] ; then
mount --help 2>&1 |grep -q BusyBox
@@ -1385,7 +1401,7 @@ fi
if [ "$INSTAB" = "1" ] ; then
mkdir -p ${PHYS_SYSROOT}_b
- mount -o $mount_flags "${OSTREE_ROOT_DEVICE}_b" "${PHYS_SYSROOT}_b" || fatal "Error mouting ${OSTREE_ROOT_DEVICE}_b"
+ mount -o ${mount_flags} "${OSTREE_ROOT_B_DEVICE}" "${PHYS_SYSROOT}_b" || fatal "Error mounting ${OSTREE_ROOT_B_DEVICE}"
ostree admin --sysroot=${PHYS_SYSROOT}_b init-fs ${PHYS_SYSROOT}_b
ostree admin --sysroot=${PHYS_SYSROOT}_b os-init ${INSTOS}
@@ -1395,7 +1411,7 @@ if [ "$INSTAB" = "1" ] ; then
mkdir -p ${PHYS_SYSROOT}_b/boot
fi
- mount "${OSTREE_BOOT_DEVICE}_b" "${PHYS_SYSROOT}_b/boot" || fatal "Error mouting ${OSTREE_BOOT_DEVICE}_b"
+ mount "${OSTREE_BOOT_B_DEVICE}" "${PHYS_SYSROOT}_b/boot" || fatal "Error mounting ${OSTREE_BOOT_B_DEVICE}"
mkdir -p ${PHYS_SYSROOT}_b/boot/efi

View File

@ -0,0 +1,176 @@
From 2e02c84c83014bb647763898f6ab14c68f452fa2 Mon Sep 17 00:00:00 2001
From: Robert Church <robert.church@windriver.com>
Date: Thu, 17 Nov 2022 01:57:53 -0600
Subject: Allow specifying /var device for installs
To enable a logical volume based /var filesystem, add support to the
installer scripts to allow specifying a device to mount instead of just
looking for LABEL=fluxdata.
For the init script add option 'ostree_var' to specify the device to
mount and provide from grub boot options.
Update the lat-installer to pass a device for /var as this was hardcoded
as 'LABEL=fluxdata' and update the install script accordingly.
Signed-off-by: Robert Church <robert.church@windriver.com>
---
init-ostree-install.sh | 33 +++++++++++++++++++++++----------
init-ostree.sh | 13 ++++++++++---
lat-installer.sh | 8 +++++++-
3 files changed, 40 insertions(+), 14 deletions(-)
diff --git a/init-ostree-install.sh b/init-ostree-install.sh
index d54185a..9f145ec 100644
--- a/init-ostree-install.sh
+++ b/init-ostree-install.sh
@@ -99,6 +99,7 @@ OPTIONAL:
inst_ostree_boot_b=DEVICE - Specify the ostree boot_b device
inst_ostree_root=DEVICE - Specify the ostree root device
inst_ostree_root_b=DEVICE - Specify the ostree root_b device
+ inst_ostree_var=DEVICE - Specify the ostree var device
EOF
}
@@ -580,6 +581,7 @@ OSTREE_BOOT_DEVICE=${OSTREE_BOOT_DEVICE="LABEL=otaboot"}
OSTREE_ROOT_DEVICE=${OSTREE_ROOT_DEVICE="LABEL=otaroot"}
OSTREE_BOOT_B_DEVICE=${OSTREE_BOOT_B_DEVICE="LABEL=otaboot_b"}
OSTREE_ROOT_B_DEVICE=${OSTREE_ROOT_B_DEVICE="LABEL=otaroot_b"}
+OSTREE_VAR_DEVICE=${OSTREE_VAR_DEVICE="LABEL=fluxdata"}
KS=""
if [ "$OSTREE_KERNEL_ARGS" = "%OSTREE_KERNEL_ARGS%" ] ; then
@@ -695,6 +697,8 @@ read_args() {
OSTREE_BOOT_B_DEVICE=$optarg ;;
inst_ostree_root_b=*)
OSTREE_ROOT_B_DEVICE=$optarg ;;
+ inst_ostree_var=*)
+ OSTREE_VAR_DEVICE=$optarg ;;
esac
done
# defaults if not set
@@ -1509,18 +1513,22 @@ fi
# Modify fstab if not using fluxdata
# Caution... If someone resets the /etc/fstab with OSTree this change is lost...
mkdir /var1
-if [ "$INSTFLUX" != "1" ] ; then
- if [ "$BL" = "grub" -o "$BL" = "ufsd" ] ; then
- sed -i -e "s#^LABEL=fluxdata.*#${PHYS_SYSROOT}/ostree/deploy/${INSTOS}/var /var none bind 0 0#" ${PHYS_SYSROOT}/ostree/?/etc/fstab
- if [ "$INSTAB" = 1 ] ; then
- sed -i -e "s#^LABEL=fluxdata.*#${PHYS_SYSROOT}/ostree/deploy/${INSTOS}/var /var none bind 0 0#" ${PHYS_SYSROOT}_b/ostree/?/etc/fstab
+if [ "${INSTSTX}" = 1 ]; then
+ mount -o ${mount_flags} ${OSTREE_VAR_DEVICE} /var1 || fatal "Error mounting ${OSTREE_BOOT_VAR}"
+else
+ if [ "${INSTFLUX}" != "1" ] ; then
+ if [ "${BL}" = "grub" -o "${BL}" = "ufsd" ] ; then
+ sed -i -e "s#^${OSTREE_VAR_DEVICE}.*#${PHYS_SYSROOT}/ostree/deploy/${INSTOS}/var /var none bind 0 0#" ${PHYS_SYSROOT}/ostree/?/etc/fstab
+ if [ "${INSTAB}" = 1 ] ; then
+ sed -i -e "s#^${OSTREE_VAR_DEVICE}.*#${PHYS_SYSROOT}/ostree/deploy/${INSTOS}/var /var none bind 0 0#" ${PHYS_SYSROOT}_b/ostree/?/etc/fstab
+ fi
+ else
+ fatal "Error: bl=${BL} is not supported"
fi
+ mount --bind ${PHYS_SYSROOT}/ostree/deploy/${INSTOS}/var /var1
else
- fatal "Error: bl=$BL is not supported"
+ mount -o ${mount_flags} LABEL=fluxdata /var1
fi
- mount --bind ${PHYS_SYSROOT}/ostree/deploy/${INSTOS}/var /var1
-else
- mount -o $mount_flags LABEL=fluxdata /var1
fi
if [ -d ${PHYS_SYSROOT}/ostree/1/var ] ; then
tar -C ${PHYS_SYSROOT}/ostree/1/var/ --hard-dereference --xattrs --xattrs-include='*' -cf - . | \
@@ -1543,7 +1551,12 @@ if [ -n "${KS}" ]; then
fatal "Run Kickstart Set network failed in ${root}"
fi
- ./lat-installer.sh post-install --root=${root} -v --instflux=${INSTFLUX} --instos=${INSTOS}
+ if [ "${INSTSTX}" = 1 ]; then
+ ./lat-installer.sh post-install --root=${root} -v --instflux=${INSTFLUX} --fluxdev=/dev/mapper/cgts--vg-var--lv --instos=${INSTOS}
+ else
+ ./lat-installer.sh post-install --root=${root} -v --instflux=${INSTFLUX} --instos=${INSTOS}
+ fi
+
if [ $? -ne 0 ]; then
fatal "Run Kickstart Post Install Script failed in ${root}"
fi
diff --git a/init-ostree.sh b/init-ostree.sh
index d0b0dda..f0217c0 100644
--- a/init-ostree.sh
+++ b/init-ostree.sh
@@ -31,6 +31,7 @@ UMOUNT="/bin/umount"
ROOT_DELAY="0"
OSTREE_SYSROOT=""
OSTREE_BOOT_DEVICE="LABEL=otaboot"
+OSTREE_VAR_DEVICE=""
OSTREE_LABEL_FLUXDATA="fluxdata"
VSZ=20480
SKIP_BOOT_DIFF=""
@@ -124,6 +125,8 @@ read_args() {
OSTREE_LABEL_FLUXDATA=$optarg ;;
multi-drivers-switch=*)
DRIVER_VERSION=$optarg ;;
+ ostree_var=*)
+ OSTREE_VAR_DEVICE=${optarg} ;;
esac
done
}
@@ -289,7 +292,7 @@ while [ 1 ] ; do
fi
done
-[ $VSZ = 0 ] && expand_fluxdata
+[ -z "${OSTREE_VAR_DEVICE}" ] && [ "${VSZ}" = 0 ] && expand_fluxdata
[ -x /init.luks-ostree ] && {
/init.luks-ostree $OSTREE_LABEL_ROOT $OSTREE_LABEL_FLUXDATA || fatal "Couldn't init LUKS."
@@ -334,9 +337,13 @@ sed "/LABEL=otaboot[\t ]*\/boot[\t ]/s/LABEL=otaboot/${OSTREE_BOOT_DEVICE}/g" -i
sed "/LABEL=otaboot_b[\t ]*\/boot[\t ]/s/LABEL=otaboot_b/${OSTREE_BOOT_DEVICE}/g" -i ${ROOT_MOUNT}/etc/fstab
noflux=`ostree config --repo=/sysroot/ostree/repo get upgrade.noflux 2> /dev/null`
if [ "$noflux" = 1 ] ; then
- sed "s/^LABEL=fluxdata.*//" -i ${ROOT_MOUNT}/etc/fstab
+ sed "s/^LABEL=fluxdata.*//" -i ${ROOT_MOUNT}/etc/fstab
else
- sed "/LABEL=fluxdata[\t ]*\/var[\t ]/s/LABEL=fluxdata/LABEL=${OSTREE_LABEL_FLUXDATA}/g" -i ${ROOT_MOUNT}/etc/fstab
+ if [ -z "${OSTREE_VAR_DEVICE}" ] ; then
+ sed "/LABEL=fluxdata[\t ]*\/var[\t ]/s/LABEL=fluxdata/LABEL=${OSTREE_LABEL_FLUXDATA}/g" -i ${ROOT_MOUNT}/etc/fstab
+ else
+ sed "/LABEL=fluxdata[\t ]*\/var[\t ]/s#LABEL=fluxdata#${OSTREE_VAR_DEVICE}#g" -i ${ROOT_MOUNT}/etc/fstab
+ fi
fi
# If we pass args to bash, it will assume they are text files
diff --git a/lat-installer.sh b/lat-installer.sh
index c4462ca..dc03535 100755
--- a/lat-installer.sh
+++ b/lat-installer.sh
@@ -34,6 +34,7 @@ target_rootfs=""
ks_file="${lat_tmp}/lat-installer.ks"
INSTFLUX="1"
+FLUX_DEVICE="LABEL=fluxdata"
INSTOS="lat-os"
fatal() {
@@ -512,7 +513,7 @@ post_install() {
mount --bind /sysroot/boot ${target_rootfs}/boot
mount --bind /sysroot/boot/efi ${target_rootfs}/boot/efi
if [ "${INSTFLUX}" = 1 ] ; then
- mount LABEL=fluxdata ${target_rootfs}/var
+ mount ${FLUX_DEVICE} ${target_rootfs}/var
else
mount --bind /sysroot/ostree/deploy/${INSTOS}/var ${target_rootfs}/var
fi
@@ -620,6 +621,11 @@ while [ $# -gt 0 ]; do
shift
continue
;;
+ --fluxdev=*)
+ FLUX_DEVICE=${val}
+ shift
+ continue
+ ;;
--instos=*)
INSTOS=$val
shift

View File

@ -1,7 +1,9 @@
0001-Prevent-auto-expansion-of-fluxdata-partition.patch
0003-Make-boot-efi-mount-as-rw.patch
0004-debian-set-default-size-variables-in-install-script.patch
0005-Wait-for-devices-to-be-configured-after-boot.patch
0006-init-ostree-install.sh-break-hardlinks-in-var.patch
0007-Add-support-for-StarlingX-partitioning-formatting.patch
0008-Make-driver-switch-more-adaptable.patch
0002-Make-boot-efi-mount-as-rw.patch
0003-debian-set-default-size-variables-in-install-script.patch
0004-Wait-for-devices-to-be-configured-after-boot.patch
0005-init-ostree-install.sh-break-hardlinks-in-var.patch
0006-Add-support-for-StarlingX-partitioning-formatting.patch
0007-Make-driver-switch-more-adaptable.patch
0008-Allow-specifying-boot-root-devices-for-installs.patch
0009-Allow-specifying-var-device-for-installs.patch