MycroftOS: Buildroot: At first boot expand data partition over the whole SD card.

This commit is contained in:
Peter Steenbergen 2018-11-04 22:37:29 +01:00
parent 1c626523ac
commit 9f30517a4b
3 changed files with 16 additions and 54 deletions

View File

@ -0,0 +1,16 @@
#!/bin/bash
set -e
echo "Resize data partition ..."
parted /dev/mmcblk0 unit % resizepart 2 yes 100%
echo "Resize partition done"
partprobe /dev/mmcblk0
sync
echo "Resize data filesystem ..."
resize2fs /dev/mmcblk0p2
echo "Resize filesystem done"
chmod -x /etc/init.d/S00resize_sdcard

View File

@ -1,23 +0,0 @@
#!/bin/sh
#
# Auto resize root partition at first boot after init_resize
#
start() {
printf "Starting resize2fs_once: "
ROOT_DEV=$(findmnt / -o source -n) &&
resize2fs $ROOT_DEV &&
rm /etc/init.d/S00resizefs_once &&
echo "OK"
}
case "$1" in
start)
start
;;
*)
echo "Usage: $0 {start}"
exit 1
esac
exit $?

View File

@ -1,31 +0,0 @@
#!/bin/bash
set -e
mount -t proc proc /proc
mount -t sysfs sys /sys
mount -t tmpfs tmp /run
mount /boot
mount / -o remount,rw
sed -i 's| init=/etc/init.d/init_resize.sh||' /boot/cmdline.txt
sync
DEVICE="/dev/mmcblk0"
PARTNR="p2"
CURRENTSIZEB=`fdisk -l $DEVICE$PARTNR | grep "Disk $DEVICE$PARTNR" | cut -d' ' -f5`
CURRENTSIZE=`expr $CURRENTSIZEB / 1024 / 1024`
MAXSIZEMB=`printf %s\\n 'unit MB print list' | parted | grep "Disk ${DEVICE}" | cut -d' ' -f3 | tr -d MB`
echo "[ok] applying resize operation.."
parted ${DEVICE} resizepart ${PARTNR} ${MAXSIZEMB}
echo "[done]"
partprobe $DEVICE
umount /boot
mount / -o remount,ro
sync
reboot