1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-03-09 15:40:17 +00:00

Merge pull request #3121 from holta/resize-rootfs-needs-work

Use 'raspi-config --expand-rootfs' in 1-prep/templates/iiab-rpi-max-rootfs.sh (for external USB disks, that also need their filesystem expanded)
This commit is contained in:
Tim Moody 2022-02-18 08:00:45 -05:00 committed by GitHub
commit 01dc89f2ca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,20 +1,32 @@
#!/bin/bash -x
# Resize rootfs and its partition on the rpi SD card to maximum size
# To be used by systemd service on boot
# Only resizes if /.resize-rootfs exists
# Assumes root is last partition
# Only works on F22 + where resizepart command exists
# Assumes sd card style partition name like <device>p<partition number>
if [ -f /.resize-rootfs ];then
echo "$0: maximizing rootfs partion"
# Calculate root partition
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)}
# 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.
# Resize partition
growpart /dev/$root_dev $root_part_no
resize2fs /dev/$root_part
rm /.resize-rootfs
# To be used by /etc/systemd/system/iiab-rpi-root-resize.service on boot.
# Only resizes if /.resize-rootfs exists.
# Assumes root is last partition.
if [ -f /.resize-rootfs ]; then
echo "$0: maximizing rootfs partion"
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 !
raspi-config --expand-rootfs
else
# Assumes sd card style partition name like <device>p<partition number>
# 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_dev=${root_part:0:-2}
root_part_no=${root_part: (-1)}
# Resize partition
growpart /dev/$root_dev $root_part_no
resize2fs /dev/$root_part
fi
rm /.resize-rootfs
fi