Enable expand on eMMc module
This commit is contained in:
parent
17346f5d02
commit
ec496d6155
15
pishrink.sh
15
pishrink.sh
|
@ -181,18 +181,23 @@ cat <<\EOF1 > "$mountdir/etc/rc.local"
|
||||||
do_expand_rootfs() {
|
do_expand_rootfs() {
|
||||||
ROOT_PART=$(mount | sed -n 's|^/dev/\(.*\) on / .*|\1|p')
|
ROOT_PART=$(mount | sed -n 's|^/dev/\(.*\) on / .*|\1|p')
|
||||||
|
|
||||||
|
BLK_NUM=mmcblk0
|
||||||
PART_NUM=${ROOT_PART#mmcblk0p}
|
PART_NUM=${ROOT_PART#mmcblk0p}
|
||||||
if [ "$PART_NUM" = "$ROOT_PART" ]; then
|
if [ "$PART_NUM" = "$ROOT_PART" ]; then
|
||||||
echo "$ROOT_PART is not an SD card. Don't know how to expand"
|
PART_NUM=${ROOT_PART#mmcblk1p}
|
||||||
return 0
|
BLK_NUM=mmcblk1
|
||||||
|
if [ "$PART_NUM" = "$ROOT_PART" ]; then
|
||||||
|
echo "$ROOT_PART is not an SD card nor eMMc module. Don't know how to expand"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Get the starting offset of the root partition
|
# Get the starting offset of the root partition
|
||||||
PART_START=$(parted /dev/mmcblk0 -ms unit s p | grep "^${PART_NUM}" | cut -f 2 -d: | sed 's/[^0-9]//g')
|
PART_START=$(parted "/dev/$BLK_NUM" -ms unit s p | grep "^${PART_NUM}" | cut -f 2 -d: | sed 's/[^0-9]//g')
|
||||||
[ "$PART_START" ] || return 1
|
[ "$PART_START" ] || return 1
|
||||||
# Return value will likely be error for fdisk as it fails to reload the
|
# Return value will likely be error for fdisk as it fails to reload the
|
||||||
# partition table because the root fs is mounted
|
# partition table because the root fs is mounted
|
||||||
fdisk /dev/mmcblk0 <<EOF
|
fdisk "/dev/$BLK_NUM" <<EOF
|
||||||
p
|
p
|
||||||
d
|
d
|
||||||
$PART_NUM
|
$PART_NUM
|
||||||
|
@ -323,4 +328,4 @@ fi
|
||||||
aftersize=$(ls -lh "$img" | cut -d ' ' -f 5)
|
aftersize=$(ls -lh "$img" | cut -d ' ' -f 5)
|
||||||
logVariables $LINENO aftersize
|
logVariables $LINENO aftersize
|
||||||
|
|
||||||
info "Shrunk $img from $beforesize to $aftersize"
|
info "Shrunk $img from $beforesize to $aftersize"
|
Loading…
Reference in New Issue