-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Patch/rocko3 #75
Patch/rocko3 #75
Changes from 1 commit
1c8da62
fcad25e
1b3f5a8
718b5cf
6b9dc3d
e7c44d9
8823915
859753e
870425a
8c00033
9bbf171
59ef398
3c9f280
cf26973
872ca86
1abad60
63c42f2
6947b47
b649176
1038f13
b83d149
4b90604
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,30 +2,74 @@ | |
|
||
set -eu | ||
|
||
PART_NUMBER=3 | ||
THIS_SCRIPT="$(basename $0)" | ||
|
||
log () { | ||
echo ${THIS_SCRIPT}: $1 > /dev/kmsg | ||
} | ||
|
||
disable () { | ||
log "Deactivating this automatic resizer" | ||
update-rc.d -f expandfs.sh remove | ||
} | ||
|
||
case $(mount | grep "on / ") in | ||
/dev/mmcblk0*) | ||
ROOT_DEVICE="/dev/mmcblk0" | ||
ROOT_PARTITION="/dev/mmcblk0p$PART_NUMBER" | ||
EXPAND_PARTITION="/dev/mmcblk0p" | ||
;; | ||
/dev/sda*) | ||
ROOT_DEVICE="/dev/sda" | ||
ROOT_PARTITION="/dev/sda$PART_NUMBER" | ||
EXPAND_PARTITION="/dev/sda" | ||
;; | ||
*) | ||
echo "Cannot determine boot device." | ||
log "Cannot determine root device." | ||
disable | ||
exit 1 | ||
;; | ||
esac | ||
|
||
START_BLOCK=$(parted $ROOT_DEVICE -ms unit s p | grep "^$PART_NUMBER" | cut -f 2 -d: | sed "s/s$//") | ||
log "Fixing backup GPT position" | ||
parted ${ROOT_DEVICE} print Fix | ||
|
||
parted -ms $ROOT_DEVICE rm $PART_NUMBER | ||
LAST_PART="$(parted ${ROOT_DEVICE} -ms unit s p | tail -n 1 | cut -d ':' -f 1)" | ||
if [ "x${LAST_PART}" == "x" ] | ||
then | ||
log "Cannot find last partition of root device." | ||
disable | ||
exit 1 | ||
fi | ||
|
||
parted -ms $ROOT_DEVICE unit s -- mkpart primary ext3 $START_BLOCK -1 | ||
EXPAND_PARTITION="${EXPAND_PARTITION}${LAST_PART}" | ||
|
||
MAXSIZE="$(parted ${ROOT_DEVICE} -s unit MB print list | grep Disk | cut -d' ' -f 3 | tr -d MB)" | ||
if [ "x${MAXSIZE}" == "x" ] | ||
then | ||
log "Error obtaining maximum partition size" | ||
disable | ||
exit 1 | ||
fi | ||
|
||
partprobe $ROOT_DEVICE | ||
resize2fs $ROOT_PARTITION | ||
log "Resizing ${EXPAND_PARTITION} to maximum" | ||
parted ${ROOT_DEVICE} -s resizepart ${LAST_PART} ${MAXSIZE}M | ||
res=$? | ||
if [ $res -ne 0 ] | ||
then | ||
log "Error resizing partition" | ||
disable | ||
exit 1 | ||
fi | ||
|
||
partprobe ${ROOT_DEVICE} | ||
|
||
log "Resizing file system on ${EXPAND_PARTITION}" | ||
resize2fs ${EXPAND_PARTITION} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For whatever reason, this just refused to work:
Adding that check here seems reasonable. |
||
res=$? | ||
if [ $res -ne 0 ] | ||
then | ||
log "Error resizing file system" | ||
disable | ||
exit 1 | ||
fi | ||
|
||
update-rc.d -f expandfs.sh remove | ||
disable | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. BTW, not a regression: parted also gets stuck on lacking entropy. Possibly because it pulls in some uuid lib which first of all wants to initialized some randomness. I'm checking if we can avoid that. Alternatively, we could send the whole thing into background so that the first boot is not delayed. At least we need to think about the watchdog in case we no longer start it prematurely during early boot. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left over debug print? But "Fix" is not a known parameter to parted.