32 lines
647 B
Bash
Raw Normal View History

2024-03-08 10:41:41 +01:00
#! /bin/sh
2025-03-05 14:27:12 +01:00
if [ -z "$DISK" ]; then
DISK="mmcblk1"
fi
if [ "$(/usr/bin/id -u)" -ne 0 ]; then
2024-03-08 10:41:41 +01:00
echo "$0 shall be run as root"
exit 1
fi
2025-03-05 14:27:12 +01:00
start_sector=$(cat /sys/block/$DISK/${DISK}p4/start)
2024-03-08 10:41:41 +01:00
echo "Start sector is: $start_sector"
if [ -z "$start_sector" ]; then
echo "Cannot find the start sector"
exit 1
fi
echo "Expanding the partition"
2025-03-05 14:27:12 +01:00
sed -e 's/\s*\([\+0-9a-zA-Z]*\).*/\1/' << EOF | fdisk /dev/$DISK
2024-03-08 10:41:41 +01:00
d # delete partition
4 # number 4
n # new partition
p # primary partition
4 # partition number 4
$start_sector
# default - end of disk
p # print the in-memory partition table
w # write the partition table
q # and we're done
EOF