From 38eb8868e3237039451ac73ad7e5a7a7cd03ace5 Mon Sep 17 00:00:00 2001 From: A Holt Date: Fri, 18 Feb 2022 10:03:23 -0500 Subject: [PATCH 1/3] Clarify & Clean 1-prep/templates/iiab-rpi-max-rootfs.sh for PR #3121 --- roles/1-prep/templates/iiab-rpi-max-rootfs.sh | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/roles/1-prep/templates/iiab-rpi-max-rootfs.sh b/roles/1-prep/templates/iiab-rpi-max-rootfs.sh index aa221bcf0..6c91ac9f6 100644 --- a/roles/1-prep/templates/iiab-rpi-max-rootfs.sh +++ b/roles/1-prep/templates/iiab-rpi-max-rootfs.sh @@ -1,6 +1,6 @@ #!/bin/bash -x -# Resize rootfs and its partition on the rpi SD card (or external USB +# Resize rootfs and its partition on the RPi SD card (or external USB # disk if possible, e.g. with Raspberry Pi OS) to maximum size. # To be used by /etc/systemd/system/iiab-rpi-root-resize.service on boot. @@ -15,13 +15,18 @@ if [ -f /.resize-rootfs ]; then # just microSD cards). IF ONLY THIS ALSO WORKED ON Ubuntu/Mint/etc ! raspi-config --expand-rootfs else - # Assumes sd card style partition name like p + # 2022-02-17 PR #3121: This 2-line explanation appears stale... + # Assumes SD card style partition name like p # Only works on F22 + where resizepart command exists # Calculate root partition - root_part=`lsblk -aP -o NAME,MOUNTPOINT | grep 'MOUNTPOINT="/"' | awk -F\" '{ print $2 }'` + root_part=`lsblk -aP -o NAME,MOUNTPOINT | grep 'MOUNTPOINT="/"' | awk -F\" '{ print $2 }'` root_dev=${root_part:0:-2} - root_part_no=${root_part: (-1)} + # bash substring expansion: "negative offset [below, but not above] + # must be separated from the colon by at least one space to avoid + # being confused with the ‘:-’ expansion" + # https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html + root_part_no=${root_part: -1} # Resize partition growpart /dev/$root_dev $root_part_no From e7b201e84cc5852fef6123a49999c2053cc5b877 Mon Sep 17 00:00:00 2001 From: A Holt Date: Fri, 18 Feb 2022 13:46:46 -0500 Subject: [PATCH 2/3] Further clarify 1-prep/templates/iiab-rpi-max-rootfs.sh --- roles/1-prep/templates/iiab-rpi-max-rootfs.sh | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/roles/1-prep/templates/iiab-rpi-max-rootfs.sh b/roles/1-prep/templates/iiab-rpi-max-rootfs.sh index 6c91ac9f6..034b653eb 100644 --- a/roles/1-prep/templates/iiab-rpi-max-rootfs.sh +++ b/roles/1-prep/templates/iiab-rpi-max-rootfs.sh @@ -13,20 +13,24 @@ if [ -f /.resize-rootfs ]; then if [ -x /usr/bin/raspi-config ]; then # 2022-02-17: Works in many more situations, e.g. with USB disks (not # just microSD cards). IF ONLY THIS ALSO WORKED ON Ubuntu/Mint/etc ! + + # Uses do_expand_rootfs() from: + # https://github.com/RPi-Distro/raspi-config/blob/master/raspi-config raspi-config --expand-rootfs else - # 2022-02-17 PR #3121: This 2-line explanation appears stale... - # Assumes SD card style partition name like p - # Only works on F22 + where resizepart command exists + # ASSUMES SD CARD STYLE PARTITION NAME LIKE p + # e.g. /dev/mmcblk0p2 mounts at / (typical RasPiOS microSD) + # BUT /dev/sda2 mounts at /media/usb1 (typical RasPiOS USB boot + # disk WON'T WORK BELOW!) # Calculate root partition - root_part=`lsblk -aP -o NAME,MOUNTPOINT | grep 'MOUNTPOINT="/"' | awk -F\" '{ print $2 }'` - root_dev=${root_part:0:-2} + root_part=`lsblk -aP -o NAME,MOUNTPOINT | grep 'MOUNTPOINT="/"' | awk -F\" '{ print $2 }'` # e.g. mmcblk0p2 + root_dev=${root_part:0:-2} # e.g. mmcblk0 # bash substring expansion: "negative offset [below, but not above] # must be separated from the colon by at least one space to avoid # being confused with the ‘:-’ expansion" # https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html - root_part_no=${root_part: -1} + root_part_no=${root_part: -1} # e.g. 2 # Resize partition growpart /dev/$root_dev $root_part_no From bd71b9484bad2f168ea88ac15f5823d0a91860f5 Mon Sep 17 00:00:00 2001 From: A Holt Date: Fri, 18 Feb 2022 13:56:57 -0500 Subject: [PATCH 3/3] 1-prep/templates/iiab-rpi-max-rootfs.sh: Explain & link to PR #3121 --- roles/1-prep/templates/iiab-rpi-max-rootfs.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/roles/1-prep/templates/iiab-rpi-max-rootfs.sh b/roles/1-prep/templates/iiab-rpi-max-rootfs.sh index 034b653eb..8405727b4 100644 --- a/roles/1-prep/templates/iiab-rpi-max-rootfs.sh +++ b/roles/1-prep/templates/iiab-rpi-max-rootfs.sh @@ -20,8 +20,8 @@ if [ -f /.resize-rootfs ]; then else # ASSUMES SD CARD STYLE PARTITION NAME LIKE p # e.g. /dev/mmcblk0p2 mounts at / (typical RasPiOS microSD) - # BUT /dev/sda2 mounts at /media/usb1 (typical RasPiOS USB boot - # disk WON'T WORK BELOW!) + # BUT /dev/sda2 mounts at /media/usb1 (RasPiOS USB boot disk... + # ...WON'T WORK BELOW; recap @ PR #3121) # Calculate root partition root_part=`lsblk -aP -o NAME,MOUNTPOINT | grep 'MOUNTPOINT="/"' | awk -F\" '{ print $2 }'` # e.g. mmcblk0p2