From 1f990063f5d37f7f8124bbb2ccae6258cb8e7b05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Ferr=C3=A3o?= <2031761+viniciusferrao@users.noreply.github.com> Date: Thu, 29 Oct 2026 22:08:54 -0300 Subject: [PATCH] fix(ubuntu): apply partitionfile entries on Subiquity installs linuximage.partitionfile had no effect on Ubuntu 20.04 and later installs. The Subiquity pre-install script decodes each entry with base64decode, which uses read -n, and Subiquity runs the script under dash, which has no read -n. A layout file decoded to an empty storage config, which stops the install, and a layout script or disk script decoded to nothing. The d: and s:d: disk step also ran after the script had written the storage config, so a disk file could not change the disk that getinstdisk chose, which prefers a disk that already holds an operating system. Decode with coreutils base64, which the live system ships, and run the disk step before the storage config is written. The storage config uses the first disk the disk file names, because the layout uses one disk, and names it by its device node: Subiquity matches the path literally and finds no disk for a /dev/disk/by-id link. --- .../xcat/install/scripts/pre.ubuntu.subiquity | 67 +++---------------- 1 file changed, 11 insertions(+), 56 deletions(-) diff --git a/xCAT-server/share/xcat/install/scripts/pre.ubuntu.subiquity b/xCAT-server/share/xcat/install/scripts/pre.ubuntu.subiquity index 92707fb716..be79dbe1c7 100644 --- a/xCAT-server/share/xcat/install/scripts/pre.ubuntu.subiquity +++ b/xCAT-server/share/xcat/install/scripts/pre.ubuntu.subiquity @@ -139,63 +139,15 @@ chmod 755 /tmp/foo.sh /tmp/foo.sh >/tmp/foo.log 2>&1 & +# Subiquity runs this script under dash, which has no read -n, and its live system ships coreutils. base64decode() { - h0="0"; h1="1"; h2="2"; h3="3"; h4="4"; h5="5"; h6="6"; h7="7"; - h8="8"; h9="9"; h10="A"; h11="B"; h12="C"; h13="D"; h14="E"; h15="F"; - - while : - do - i=0 - while [ "$i" -lt 4 ] - do - read -n 1 c || return - - case "${c}" in - "A") d=0 ;; "B") d=1 ;; "C") d=2 ;; "D") d=3 ;; - "E") d=4 ;; "F") d=5 ;; "G") d=6 ;; "H") d=7 ;; - "I") d=8 ;; "J") d=9 ;; "K") d=10 ;; "L") d=11 ;; - "M") d=12 ;; "N") d=13 ;; "O") d=14 ;; "P") d=15 ;; - "Q") d=16 ;; "R") d=17 ;; "S") d=18 ;; "T") d=19 ;; - "U") d=20 ;; "V") d=21 ;; "W") d=22 ;; "X") d=23 ;; - "Y") d=24 ;; "Z") d=25 ;; "a") d=26 ;; "b") d=27 ;; - "c") d=28 ;; "d") d=29 ;; "e") d=30 ;; "f") d=31 ;; - "g") d=32 ;; "h") d=33 ;; "i") d=34 ;; "j") d=35 ;; - "k") d=36 ;; "l") d=37 ;; "m") d=38 ;; "n") d=39 ;; - "o") d=40 ;; "p") d=41 ;; "q") d=42 ;; "r") d=43 ;; - "s") d=44 ;; "t") d=45 ;; "u") d=46 ;; "v") d=47 ;; - "w") d=48 ;; "x") d=49 ;; "y") d=50 ;; "z") d=51 ;; - "0") d=52 ;; "1") d=53 ;; "2") d=54 ;; "3") d=55 ;; - "4") d=56 ;; "5") d=57 ;; "6") d=58 ;; "7") d=59 ;; - "8") d=60 ;; "9") d=61 ;; "+") d=62 ;; "/") d=63 ;; - "=") d=0 ;; - *) continue ;; - esac - - eval "a${i}=${c}" - eval "b${i}=${d}" - - i=$(( i + 1 )) - done - - o0=$(( ((b0 << 2) | (b1 >> 4)) & 0xff )) - o1=$(( ((b1 << 4) | (b2 >> 2)) & 0xff )) - o2=$(( ((b2 << 6) | b3) & 0xff )) - - [ "${a2}" == "=" ] && - eval "printf \"\\x\${h$(( o0 / 16 ))}\${h$(( o0 % 16 - ))}\"" && - return - [ "${a3}" == "=" ] && - eval "printf \"\\x\${h$(( o0 / 16 ))}\${h$(( o0 % 16 - ))}\\x\${h$(( o1 / 16 ))}\${h$(( o1 % 16 - ))}\"" && - return - eval "printf \"\\x\${h$(( o0 / 16 ))}\${h$(( o0 % 16 - ))}\\x\${h$(( o1 / 16 ))}\${h$(( o1 % 16 - ))}\\x\${h$(( o2 / 16 ))}\${h$(( o2 % 16 ))}\"" - done + base64 -d } + +# A d: or s:d: entry in linuximage.partitionfile replaces the disk getinstdisk chose. +#XCA_PARTMAN_DISK_SCRIPT# + # Note that the subiquity/curtin installation config is fairly picky about # the order in which things are specified - you have to specify all the # partitions before you can specify any filesystems, which means this is @@ -211,7 +163,10 @@ base64decode() # to this unwrapped file and must start at column 0. logger -t $log_label -p "info" "Generate partition file..." if [ -e /tmp/xcat.install_disk ]; then - INSTALL_DISK=$(cat /tmp/xcat.install_disk) + # The layout uses one disk, the first one the disk file names. + INSTALL_DISK=$(awk 'NF {print $1; exit}' /tmp/xcat.install_disk) + # Subiquity matches the disk path literally, so resolve a link such as /dev/disk/by-id/. + INSTALL_DISK=$(readlink -f "$INSTALL_DISK" || echo "$INSTALL_DISK") else logger -t $log_label -p "err" "Failed to find partition file - getinstdisk must be run first" logger -t $log_label -p "err" "Using fallback default disk /dev/sda" @@ -385,8 +340,8 @@ storage: EOF fi +# A partitionfile layout or s: script must come after the default layout, which it replaces. #XCA_PARTMAN_RECIPE_SCRIPT# -#XCA_PARTMAN_DISK_SCRIPT# #XCA_PARTMAN_ADDITIONAL_CONFIG_SCRIPT# exit 0