You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# NOTE: the NOOBS partition layout confuses parted. For now, let's only
386
+
# agree to work with a sufficiently simple partition layout
387
+
if [ "$PART_NUM"-ne 2 ];then
388
+
whiptail --msgbox "Your partition layout is not currently supported by this tool. You are probably using NOOBS, in which case your root filesystem is already expanded anyway." 20 60 2
389
+
return 0
390
+
fi
391
+
392
+
LAST_PART_NUM=$(parted "$ROOT_DEV" -ms unit s p | tail -n 1 | cut -f 1 -d:)
393
+
if [ $LAST_PART_NUM-ne$PART_NUM ];then
394
+
whiptail --msgbox "$ROOT_PART is not the last partition. Don't know how to expand" 20 60 2
395
+
return 0
396
+
fi
397
+
398
+
# Get the starting offset of the root partition
399
+
PART_START=$(parted "$ROOT_DEV" -ms unit s p | grep "^${PART_NUM}"| cut -f 2 -d: | sed 's/[^0-9]//g')
400
+
[ "$PART_START" ] ||return 1
401
+
# Return value will likely be error for fdisk as it fails to reload the
402
+
# partition table because the root fs is mounted
403
+
fdisk "$ROOT_DEV"<<EOF
404
+
p
405
+
d
406
+
$PART_NUM
407
+
n
408
+
p
409
+
$PART_NUM
410
+
$PART_START
411
+
412
+
p
413
+
w
414
+
EOF
415
+
ASK_TO_REBOOT=1
416
+
417
+
# now set up an init.d script
418
+
cat <<EOF > /etc/init.d/resize2fs_once &&
419
+
#!/bin/sh
420
+
### BEGIN INIT INFO
421
+
# Provides: resize2fs_once
422
+
# Required-Start:
423
+
# Required-Stop:
424
+
# Default-Start: 3
425
+
# Default-Stop:
426
+
# Short-Description: Resize the root filesystem to fill partition
427
+
# Description:
428
+
### END INIT INFO
429
+
430
+
. /lib/lsb/init-functions
431
+
432
+
case "\$1" in
433
+
start)
434
+
log_daemon_msg "Starting resize2fs_once" &&
435
+
resize2fs "$ROOT_PART" &&
436
+
update-rc.d resize2fs_once remove &&
437
+
rm /etc/init.d/resize2fs_once &&
438
+
log_end_msg \$?
439
+
;;
440
+
*)
441
+
echo "Usage: \$0 start" >&2
442
+
exit 3
443
+
;;
444
+
esac
445
+
EOF
446
+
chmod +x /etc/init.d/resize2fs_once &&
447
+
update-rc.d resize2fs_once defaults &&
448
+
if [ "$INTERACTIVE"= True ];then
449
+
whiptail --msgbox "Root partition has been resized.\nThe filesystem will be enlarged upon the next reboot" 20 60 2
0 commit comments