aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2021-07-22 19:30:38 +0200
committerSven Gothel <[email protected]>2021-07-22 19:30:38 +0200
commit6bafdbead3f434c9a10891f75a012c881aa57974 (patch)
tree96cbb8c2ba153403a8f513d4277b67e8764cf6fd
parent7994a6ebee8c3dba909b36da64ce4c8100f36238 (diff)
stage2 mutable image: Fix resize2fs once: 'parted resizepart' needs fake tty input; Place service after rw-remount
-rw-r--r--stage2/01-sys-tweaks/files/resize2fs_manual.sh17
-rwxr-xr-xstage2/01-sys-tweaks/files/resize2fs_once28
-rw-r--r--stage2/01-sys-tweaks/files/resize2fs_once.service6
3 files changed, 40 insertions, 11 deletions
diff --git a/stage2/01-sys-tweaks/files/resize2fs_manual.sh b/stage2/01-sys-tweaks/files/resize2fs_manual.sh
new file mode 100644
index 0000000..c7500b6
--- /dev/null
+++ b/stage2/01-sys-tweaks/files/resize2fs_manual.sh
@@ -0,0 +1,17 @@
+
+ROOTFS_DIR=
+
+if true ; then
+
+install -m 644 resize2fs_once.service "${ROOTFS_DIR}/lib/systemd/system/"
+install -m 755 resize2fs_once "${ROOTFS_DIR}/etc/init.d/"
+
+systemctl unmask resize2fs_once
+systemctl enable resize2fs_once
+
+else
+
+systemctl disable resize2fs_once
+systemctl mask resize2fs_once
+
+fi
diff --git a/stage2/01-sys-tweaks/files/resize2fs_once b/stage2/01-sys-tweaks/files/resize2fs_once
index d4d5e39..dbeba59 100755
--- a/stage2/01-sys-tweaks/files/resize2fs_once
+++ b/stage2/01-sys-tweaks/files/resize2fs_once
@@ -17,19 +17,30 @@ case "$1" in
ROOT_DEV="/dev/${ROOT_DEV_BASE}"
# Test ROOT_DEV deduction: (1) ROOT_DEV substring of ROOT_PART starting equal
if [ -n "${ROOT_PART} -a -n "${ROOT_DEV} -a -z "${ROOT_PART##"${ROOT_DEV}"*}" ]; then
- PARTED_OUT=`parted -s -m $ROOT_DEV unit B print`
+ PARTED_OUT=`parted -s -m ${ROOT_DEV} unit B print`
PART_NO=`echo "$PARTED_OUT" | grep ext4 | awk -F: ' { print $1 } '`
# Test ROOT_DEV deduction: (2) identified partition number
if [ "${ROOT_PART}" = "${ROOT_DEV}p${PART_NO}" -o "${ROOT_PART}" = "${ROOT_DEV}${PART_NO}" ]; then
+ PART_START=`echo "${PARTED_OUT}" | grep "^${PART_NO}:" | awk -F: ' { print substr($2,1,length($2)-1) } '`
PART_END=`echo "${PARTED_OUT}" | grep "^${PART_NO}:" | awk -F: ' { print substr($3,1,length($3)-1) } '`
- PART_NEW_END=`parted -s -m $ROOT_DEV unit B print free | tail -1 | awk -F: ' { print substr($3,1,length($3)-1) } '`
+ PART_NEW_END=`parted -s -m ${ROOT_DEV} unit B print free | tail -1 | awk -F: ' { print substr($3,1,length($3)-1) } '`
if [ -n "${PART_END}" -a -n "${PART_NEW_END}" -a ${PART_NEW_END} -gt ${PART_END} ]; then
- echo "Resize partition ${PART_NO} from ${PART_END} to ${PART_NEW_END}"
- parted -s $ROOT_DEV unit B resizepart ${PART_NO} ${PART_NEW_END}
+ echo "Resize partition ${PART_NO} from ${PART_START} - ${PART_END} to ${PART_NEW_END}"
+ # Nope: parted -s ${ROOT_DEV} unit B resizepart ${PART_NO} ${PART_NEW_END}
+ # Nope: parted -s ${ROOT_DEV} rm ${PART_NO}
+ # Nope: parted -s ${ROOT_DEV} unit B mkpart primary ${PART_START} ${PART_NEW_END}
+ parted "${ROOT_DEV}" ---pretend-input-tty <<EOF
+unit B
+resizepart
+${PART_NO}
+Yes
+${PART_NEW_END}
+quit
+EOF
echo "Resize fs on partition ${PART_NO}, ${ROOT_PART}"
resize2fs $ROOT_PART
else
- echo "Resize partition 2 requirement failed: End ${PART_END} < new_end ${PART_NEW_END}"
+ echo "Resize partition 2 failed: End ${PART_END} >= new_end ${PART_NEW_END}"
fi
else
echo "ROOT_PART ${ROOT_PART} not matching partition ${PART_NO} of ROOT_DEV ${ROOT_DEV}."
@@ -37,9 +48,10 @@ case "$1" in
else
echo "ROOT_DEV ${ROOT_DEV} not a substring of ROOT_PART ${ROOT_PART}."
fi
- systemctl disable resize2fs_once
- systemctl mask resize2fs_once
- mv /etc/init.d/resize2fs_once /etc/init.d/resize2fs_once.disabled
+ systemctl disable resize2fs_once.service
+ systemctl mask resize2fs_once.service
+ # mv /etc/init.d/resize2fs_once /etc/init.d/resize2fs_once.disabled
+ # mv /etc/init.d/resize2fs_disable /etc/init.d/resize2fs_disable.disabled
log_end_msg $?
;;
*)
diff --git a/stage2/01-sys-tweaks/files/resize2fs_once.service b/stage2/01-sys-tweaks/files/resize2fs_once.service
index c3f9307..b808476 100644
--- a/stage2/01-sys-tweaks/files/resize2fs_once.service
+++ b/stage2/01-sys-tweaks/files/resize2fs_once.service
@@ -1,8 +1,8 @@
[Unit]
Description=Resize the root filesystem to fill partition
DefaultDependencies=no
-After=
-Before=systemd-remount-fs.service local-fs-pre.target sysinit.target
+After=systemd-remount-fs.service
+Before=local-fs.target
[Service]
Type=oneshot
@@ -10,6 +10,6 @@ RemainAfterExit=yes
ExecStart=/etc/init.d/resize2fs_once start
[Install]
-WantedBy=systemd-remount-fs.service
+WantedBy=local-fs.target
Alias=resize2fs_once.service