mirror of
https://github.com/iiab/iiab.git
synced 2025-03-09 15:40:17 +00:00
Use 'raspi-config --expand-rootfs' in 1-prep/templates/iiab-rpi-max-rootfs.sh
This commit is contained in:
parent
41817764ab
commit
2c6902e8ae
1 changed files with 28 additions and 16 deletions
|
@ -1,13 +1,23 @@
|
||||||
#!/bin/bash -x
|
#!/bin/bash -x
|
||||||
# Resize rootfs and its partition on the rpi SD card to maximum size
|
|
||||||
# To be used by systemd service on boot
|
# Resize rootfs and its partition on the rpi SD card (or external USB
|
||||||
# Only resizes if /.resize-rootfs exists
|
# disk if possible, e.g. with Raspberry Pi OS) to maximum size.
|
||||||
# Assumes root is last partition
|
|
||||||
# Only works on F22 + where resizepart command exists
|
# To be used by /etc/systemd/system/iiab-rpi-root-resize.service on boot.
|
||||||
# Assumes sd card style partition name like <device>p<partition number>
|
# Only resizes if /.resize-rootfs exists.
|
||||||
|
# Assumes root is last partition.
|
||||||
|
|
||||||
if [ -f /.resize-rootfs ]; then
|
if [ -f /.resize-rootfs ]; then
|
||||||
echo "$0: maximizing rootfs partion"
|
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
|
# 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_dev=${root_part:0:-2}
|
||||||
|
@ -16,5 +26,7 @@ if [ -f /.resize-rootfs ];then
|
||||||
# Resize partition
|
# Resize partition
|
||||||
growpart /dev/$root_dev $root_part_no
|
growpart /dev/$root_dev $root_part_no
|
||||||
resize2fs /dev/$root_part
|
resize2fs /dev/$root_part
|
||||||
|
fi
|
||||||
|
|
||||||
rm /.resize-rootfs
|
rm /.resize-rootfs
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue