Skip to content

Commit

Permalink
v9.0
Browse files Browse the repository at this point in the history
- DietPi-FS_partition_resize | Add more (debug) output to the script to better identify issues with the tailing setup partition detection: #6838
  • Loading branch information
MichaIng committed Jan 6, 2024
1 parent 4122593 commit 122c030
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions rootfs/var/lib/dietpi/services/fs_partition_resize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,28 +38,34 @@
echo "[FAILED] Unsupported root device naming scheme ($ROOT_DEV). Aborting..."
exit 1
fi
echo "[ INFO ] Detected root drive $ROOT_DRIVE with root partition $ROOT_PART"

# Check if the last partition contains a FAT filesystem with DIETPISETUP label
if [[ $(lsblk -nrbo FSTYPE,LABEL "$ROOT_DRIVE" | tail -1) == 'vfat DIETPISETUP' ]]
LAST_PART=$(lsblk -nrbo FSTYPE,LABEL "$ROOT_DRIVE" | tail -1)
if [[ $LAST_PART == 'vfat DIETPISETUP' ]]
then
# Mount it and copy files if present and newer
SETUP_PART=$(sfdisk -lqo DEVICE "$ROOT_DRIVE" | tail -1)
echo "[ INFO ] Detected trailing DietPi setup partition $SETUP_PART"
# Mount it and copy files if present and newer
TMP_MOUNT=$(mktemp -d)
mount "$SETUP_PART" "$TMP_MOUNT"
mount -v "$SETUP_PART" "$TMP_MOUNT"
for f in 'dietpi.txt' 'dietpi-wifi.txt' 'dietpiEnv.txt' 'unattended_pivpn.conf' 'Automation_Custom_PreScript.sh' 'Automation_Custom_Script.sh'
do
[[ -f $TMP_MOUNT/$f ]] && cp -u "$TMP_MOUNT/$f" /boot/
[[ -f $TMP_MOUNT/$f ]] && cp -uv "$TMP_MOUNT/$f" /boot/
done
umount "$SETUP_PART"
rmdir "$TMP_MOUNT"
umount -v "$SETUP_PART"
rmdir -v "$TMP_MOUNT"
# Finally delete the partition so the resizing works
sfdisk --no-reread --no-tell-kernel --delete "$ROOT_DRIVE" "${SETUP_PART: -1}"
else
echo "[ INFO ] No DietPi setup partition found, last partition is: \"$LAST_PART\""
lsblk -po NAME,LABEL,SIZE,TYPE,FSTYPE,MOUNTPOINTS "$ROOT_DRIVE"
fi

# Only increase partition size if not yet done on first boot
if [[ -f '/dietpi_skip_partition_resize' ]]
then
rm /dietpi_skip_partition_resize
rm -v /dietpi_skip_partition_resize
else
# Failsafe: Sync changes to disk before touching partitions
sync
Expand Down

0 comments on commit 122c030

Please sign in to comment.