1
0
mirror of https://github.com/lxsang/meta-rpi-diya.git synced 2024-11-08 22:48:22 +01:00
meta-rpi-diya/recipes-diya/diya-overlay/files/expandfs.sh

37 lines
774 B
Bash
Raw Permalink Normal View History

2021-12-17 20:30:04 +01:00
#! /bin/sh
2023-08-02 10:13:00 +02:00
if [[ $(/usr/bin/id -u) -ne 0 ]]; then
echo "$0 shall be run as root"
exit 1
fi
2021-12-17 20:30:04 +01:00
line=$(
2023-07-10 09:32:40 +02:00
sed -e 's/\s*\([\+0-9a-zA-Z]*\).*/\1/' << EOF | fdisk /dev/mmcblk0 | grep /dev/mmcblk0p4
2021-12-17 20:30:04 +01:00
p
q
EOF
)
echo "Partition: $line"
#start_sector=$(echo "$line" | cut -d' ' -f14)
start_sector=$(echo "$line" | cut -d' ' -f15)
echo "Start sector is: $start_sector"
if [ -z "$start_sector" ]; then
echo "Cannot find the start sector"
exit 1
fi
echo "Expanding the partition"
sed -e 's/\s*\([\+0-9a-zA-Z]*\).*/\1/' << EOF | fdisk /dev/mmcblk0
2023-07-10 09:32:40 +02:00
d # delete partition
4 # number 4
2021-12-17 20:30:04 +01:00
n # new partition
p # primary partition
2023-07-10 09:32:40 +02:00
4 # partition number 4
2021-12-17 20:30:04 +01:00
$start_sector
# default - end of disk
p # print the in-memory partition table
w # write the partition table
q # and we're done
EOF