improvements for the rootfs-expand script #8
@ -1,18 +1,25 @@
|
|||||||
# Package setup
|
# Package setup
|
||||||
%packages
|
%packages
|
||||||
@core
|
@core
|
||||||
|
|
||||||
|
# other necessary packages
|
||||||
|
bash-completion
|
||||||
chrony
|
chrony
|
||||||
glibc-langpack-en
|
|
||||||
cloud-utils-growpart
|
cloud-utils-growpart
|
||||||
|
e2fsprogs
|
||||||
|
glibc-langpack-en
|
||||||
|
nano
|
||||||
net-tools
|
net-tools
|
||||||
NetworkManager-wifi
|
NetworkManager-wifi
|
||||||
nano
|
|
||||||
bash-completion
|
# uboot stuff
|
||||||
uboot-images-armv8
|
|
||||||
bcm2711-firmware
|
bcm2711-firmware
|
||||||
bcm2835-firmware
|
bcm2835-firmware
|
||||||
bcm283x-firmware
|
bcm283x-firmware
|
||||||
bcm283x-overlays
|
bcm283x-overlays
|
||||||
|
uboot-images-armv8
|
||||||
|
|
||||||
|
# remove this
|
||||||
-java-11-*
|
-java-11-*
|
||||||
|
|
||||||
%end
|
%end
|
||||||
|
@ -1,35 +1,31 @@
|
|||||||
%post
|
%post
|
||||||
cat >/usr/local/bin/rootfs-expand << EOF
|
cat << EOF > /usr/local/bin/rootfs-expand
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euf -o pipefail
|
||||||
|
|
||||||
#!/bin/bash
|
ROOT_PART=\$(mount | grep ' on / ' | awk '{print \$1}')
|
||||||
clear
|
if [[ \${ROOT_PART} =~ "mmcblk" || \${ROOT_PART} =~ "nvme" ]]; then
|
||||||
part=\$(mount |grep '^/dev.* / ' |awk '{print \$1}')
|
DEV=\$(echo "\${ROOT_PART}" | rev | sed -r 's/^.{2}//' | rev)
|
||||||
if [ -z "\$part" ];then
|
INTERMEDIATE_DEV="\${DEV}p"
|
||||||
echo "Error detecting rootfs"
|
elif [[ \${ROOT_PART} =~ "vd" || \${ROOT_PART} =~ "sd" ]]; then
|
||||||
exit -1
|
DEV=\$(echo "\${ROOT_PART}" | rev | sed -r 's/^.{1}//' | rev)
|
||||||
|
INTERMEDIATE_DEV="\${DEV}"
|
||||||
|
else
|
||||||
|
>&2 echo "\$0: device type unsupported"
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
dev=\$(echo \$part|sed 's/[0-9]*\$//g')
|
PART_NUM="\${ROOT_PART#"\$INTERMEDIATE_DEV"}"
|
||||||
devlen=\${#dev}
|
|
||||||
num=\${part:\$devlen}
|
echo "\${DEV} \${PART_NUM} \${ROOT_PART}"
|
||||||
if [[ "\$dev" =~ ^/dev/mmcblk[0-9]*p\$ ]];then
|
|
||||||
dev=\${dev:0:-1}
|
echo "Extending partition \${PART_NUM} of \${DEV} to max size..."
|
||||||
fi
|
growpart "\${DEV}" "\${PART_NUM}"
|
||||||
if [ ! -x /usr/bin/growpart ];then
|
|
||||||
echo "Please install cloud-utils-growpart (sudo yum install cloud-utils-growpart)"
|
echo "Resising ext4 filesystem on \${ROOT_PART}..."
|
||||||
exit -2
|
resize2fs "\${ROOT_PART}"
|
||||||
fi
|
|
||||||
if [ ! -x /usr/sbin/resize2fs ];then
|
|
||||||
echo "Please install e2fsprogs (sudo yum install e2fsprogs)"
|
|
||||||
exit -3
|
|
||||||
fi
|
|
||||||
echo \$part \$dev \$num
|
|
||||||
|
|
||||||
echo "Extending partition \$num to max size ...."
|
|
||||||
growpart \$dev \$num
|
|
||||||
echo "Resizing ext4 filesystem ..."
|
|
||||||
resize2fs \$part
|
|
||||||
echo "Done."
|
echo "Done."
|
||||||
df -h |grep \$part
|
df -kh | head -n 1 && df -kh | grep "\${DEV}" | sort
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
chmod +x /usr/local/bin/rootfs-expand
|
chmod +x /usr/local/bin/rootfs-expand
|
||||||
|
Loading…
Reference in New Issue
Block a user