From f64f6d21e9286be4eb8bf6128f618513eca85a79 Mon Sep 17 00:00:00 2001 From: /rootzoll Date: Thu, 4 May 2023 13:41:48 +0200 Subject: [PATCH] fatpack sd card expansion (#3785) * extend sd card before fatpack (#3783) * Fatpack sd card expand (#3784) * extend sd card before fatpack * fix expansion detection --- FAQ.dev.md | 11 ++----- home.admin/config.scripts/blitz.bootdrive.sh | 2 +- home.admin/config.scripts/blitz.fatpack.sh | 31 ++++++++++++++++++++ 3 files changed, 35 insertions(+), 9 deletions(-) diff --git a/FAQ.dev.md b/FAQ.dev.md index c0b1d8362..d63ae01f4 100644 --- a/FAQ.dev.md +++ b/FAQ.dev.md @@ -28,9 +28,8 @@ Work notes for the process of producing a new SD card image release: * In terminal `ssh pi@[IP-OF-RASPIBLITZ]` * Password is `raspberry` * Run the following command BUT REPLACE `[BRANCH]` with the branch-string of your latest version -* For FATPACK: `wget --no-cache https://raw.githubusercontent.com/rootzoll/raspiblitz/[BRANCH]/build_sdcard.sh && sudo bash build_sdcard.sh -u rootzoll -b [BRANCH]` -* For MINIMAL: `wget --no-cache https://raw.githubusercontent.com/rootzoll/raspiblitz/[BRANCH]/build_sdcard.sh && sudo bash build_sdcard.sh -u rootzoll -b [BRANCH] -f 0 -d headless` -* Monitor/Check outputs for warnings/errors - install LCD +* To run the minimal pack: `wget --no-cache https://raw.githubusercontent.com/rootzoll/raspiblitz/[BRANCH]/build_sdcard.sh && sudo bash build_sdcard.sh -u rootzoll -b [BRANCH] -f 0 -d headless` +* Monitor/Check outputs for warnings/errors * Login new with `ssh admin@[IP-OF-RASPIBLITZ]` (pw: raspiblitz) and run `release` * Disconnect WiFi/LAN on build laptop (hardware switch off) and shutdown * Remove `Ubuntu LIVE` USB stick and cut power from the RaspberryPi @@ -45,11 +44,7 @@ Work notes for the process of producing a new SD card image release: * Click on `boot` volume once in the file manger * Connect the NTFS USB stick, open in file manager and delete old files -* if not: review changes in latest pishrink script -* To make a raw image from sd card - first way (terminal): - * Open Terminal and cd into directory of NTFS USB stick under `/media/amnesia` - * Run `df` to check on the SD card device name (`boot` - ignore last partition number) - * `dd if=/dev/[sdcarddevice] of=./raspiblitz.img` + * To make a raw image from sd card - second way (UI with progress): * Search "Laufwerke" or "Drives" on Tails Apps * Create image named `raspiblitz.img` to USB storage diff --git a/home.admin/config.scripts/blitz.bootdrive.sh b/home.admin/config.scripts/blitz.bootdrive.sh index ea7461f5c..95bcb71fe 100644 --- a/home.admin/config.scripts/blitz.bootdrive.sh +++ b/home.admin/config.scripts/blitz.bootdrive.sh @@ -32,7 +32,7 @@ minimumSizeByte=16384000000 rootPartition=$(sudo mount | grep " / " | cut -d " " -f 1 | cut -d "/" -f 3) rootPartitionBytes=$(lsblk -b -o NAME,SIZE | grep "${rootPartition}" | tr -s ' ' | cut -d " " -f 2) -# make conculsions +# make conclusions needsExpansion=0 tooSmall=0 if [ $rootPartitionBytes -lt $minimumSizeByte ]; then diff --git a/home.admin/config.scripts/blitz.fatpack.sh b/home.admin/config.scripts/blitz.fatpack.sh index e4f106fad..8beaafaaa 100755 --- a/home.admin/config.scripts/blitz.fatpack.sh +++ b/home.admin/config.scripts/blitz.fatpack.sh @@ -9,6 +9,37 @@ if [ "$EUID" -ne 0 ] exit 1 fi +# check if sd card needs expansion before fatpack +source <(sudo /home/admin/config.scripts/blitz.bootdrive.sh status) +if [ "${needsExpansion}" == "1" ]; then + + echo "################################################" + echo "# SD CARD NEEDS EXPANSION BEFORE FATPACK" + echo "# this will be done now ... and trigger a reboot" + echo "# after reboot run this script again" + echo "################################################" + + # write a stop file to prevent full bootstrap + # after fsexpand reboot + touch /boot/stop + + # trigger fsexpand + /home/admin/config.scripts/blitz.bootdrive.sh fsexpand + + # make sure this expand is not marked (because its not done after release) + sed -i "s/^fsexpanded=.*/fsexpanded=0/g" /home/admin/raspiblitz.info + + echo "################################################" + echo "# SD CARD GOT EXPANSION BEFORE FATPACK" + echo "# triggering a reboot" + echo "# after reboot run this script again" + echo "################################################" + + # trigger reboot + shutdown -h -r now + exit 0 +fi + apt_install() { apt install -y ${@} if [ $? -eq 100 ]; then