From f72af739e7a5f69097e6f8e70a20d997e0842178 Mon Sep 17 00:00:00 2001 From: Haiqing Bai Date: Mon, 3 Apr 2023 11:17:31 +0800 Subject: [PATCH] initramfs-ostree: Rsync the repo before pulling It is found that the 'ostree pull' is extremely slow if the ISO image which provides the remote ostree repository is served by virtual media. In this case, the remote location is in the form of a local directory instead of a URL starting with "http://" "https://" or "ssh://". To speed this up, we change to rsync the ostree repository to the true local file system first, then 'ostree pull' will be used to create the target repository with the rsynced repository in the local file system. The tests shows that the work can be done in about 15 minutes(the size of the ostree repository is about 2.7GB). Without this patch, it takes about 3 hours to finish the work. Test Plan: Pass: 1. On the webUI of the remote management controller, select 'Virtual Media', set 'Image URL' to the ISO image URL over http, then click 'Insert Media' 2. Set 'Boot Order' to boot from 'CD/DVD Drive' first 3. Create ipmi session and reboot the device to start a new installation 4. 'The following rsync command can take a while, please be patient' will be printed on the console 5. The installation will stopped at 'running:rsync ...' about 15 minutes 6. Install successfully Pass: 1. 'dd' the ISO image on USB device 2. Deploy with the USB device successfully Closes-Bug: 2013345 Signed-off-by: Haiqing Bai Change-Id: I4f42f9c3eabf1473e2ec1796578abe76c2c98e50 --- ...Rsync-the-ostree-repo-before-pulling.patch | 52 +++++++++++++++++++ ostree/initramfs-ostree/debian/patches/series | 1 + 2 files changed, 53 insertions(+) create mode 100644 ostree/initramfs-ostree/debian/patches/0013-Rsync-the-ostree-repo-before-pulling.patch diff --git a/ostree/initramfs-ostree/debian/patches/0013-Rsync-the-ostree-repo-before-pulling.patch b/ostree/initramfs-ostree/debian/patches/0013-Rsync-the-ostree-repo-before-pulling.patch new file mode 100644 index 000000000..aa1644157 --- /dev/null +++ b/ostree/initramfs-ostree/debian/patches/0013-Rsync-the-ostree-repo-before-pulling.patch @@ -0,0 +1,52 @@ +From 47ff63a93c9911524a2d66a951e85cb2f1afb663 Mon Sep 17 00:00:00 2001 +From: Haiqing Bai +Date: Mon, 3 Apr 2023 11:07:40 +0800 +Subject: [PATCH] Rsync the ostree repo before pulling + +It's extremely slow when ostree pulls +from servers virtual media, +e.g. +- Intel servers: remote ISO via samba +- HP servers: virtual CD/DVD via http + +It takes more than 3 hours while a direct copy takes +13 minutes, so here we add a step to rsync the ostree +repository to local disk first, then pull the repo from +local disk, which takes about 15 minutes. + +Signed-off-by: Jackie Huang +[ Replaced the 'cp' command with 'rsync -azr' ] +Signed-off-by: Haiqing Bai +--- + init-ostree-install.sh | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +diff --git a/init-ostree-install.sh b/init-ostree-install.sh +index 0e5b8f3..ffc68a5 100644 +--- a/init-ostree-install.sh ++++ b/init-ostree-install.sh +@@ -1329,7 +1329,12 @@ mkdir -p /var/volatile/tmp /var/volatile/run + lpull="" + if [ "$INSTL" != "" ] ; then + if [ -e /instboot${INSTL#/sysroot/boot/efi} ] ; then +- lpull="--url file:///instboot${INSTL#/sysroot/boot/efi}" ++ instl_name=$(basename ${INSTL#/sysroot/boot/efi}) ++ cmd="rsync -azr /instboot/${instl_name} /" ++ lpull="--url file:///${instl_name}" ++ echo "The following rsync command can take a while, please be patient" ++ echo running: $cmd ++ $cmd || fatal "Error: failed to rsync ${instl_name}" + elif [ -e $INSTL ] ; then + lpull="--url file://$INSTL" + else +@@ -1343,6 +1348,7 @@ fi + cmd="ostree pull $lpull --repo=${PHYS_SYSROOT}/ostree/repo ${INSTNAME} ${INSTBR}" + echo running: $cmd + $cmd || fatal "Error: ostree pull failed" ++[ -d /${instl_name} ] && rm -rf /${instl_name} + export OSTREE_BOOT_PARTITION="/boot" + ostree admin deploy ${kargs_list} --sysroot=${PHYS_SYSROOT} --os=${INSTOS} ${INSTNAME}:${INSTBR} || fatal "Error: ostree deploy failed" + +-- +2.25.1 + diff --git a/ostree/initramfs-ostree/debian/patches/series b/ostree/initramfs-ostree/debian/patches/series index afb723d7c..057909d66 100644 --- a/ostree/initramfs-ostree/debian/patches/series +++ b/ostree/initramfs-ostree/debian/patches/series @@ -10,3 +10,4 @@ 0010-Add-Installer-and-Init-Multipath-support.patch 0011-Add-H-W-Settle-time-to-installer-init.patch 0012-installer-inc-number-of-digits-in-scripts-names.patch +0013-Rsync-the-ostree-repo-before-pulling.patch