Commit 86b4db8e authored by Dorota Czaplejewicz's avatar Dorota Czaplejewicz
Browse files

base: Expand root in initramfs

Scripts based on cloud-initramfs-growroot
parent 55d8e5bb
Pipeline #4903 passed with stages
in 3 minutes and 38 seconds
......@@ -13,6 +13,7 @@ Architecture: arm64
Depends:
${misc:Depends},
${shlibs:Depends},
cloud-initramfs-growroot,
flash-kernel,
jitterentropy-rngd,
u-boot-tools,
......
......@@ -3,6 +3,12 @@ Source: https://code.puri.sm/Librem5/librem5-evk-tools.git
Files: *
Copyright: 2018 Purism SPC
License: GPL-3+
Files: usr/*
Copyright: 2011 Scott Moser <scott.moser@canonical.com>, 2019 Purism SPC
License: GPL-3+
License: GPL-3+
This package is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -19,3 +25,4 @@ License: GPL-3+
.
On Debian systems, the complete text of the GNU General
Public License version 3 can be found in "/usr/share/common-licenses/GPL-3".
......@@ -23,6 +23,8 @@ case "$1" in
systemctl enable serial-getty@ttyGS0
# Mass storage is required for Ethernet+serial over USB via g_multi
truncate -s 1M /var/lib/mass_storage_dummy
# Enable resize2fs hook
dpkg-trigger update-initramfs
;;
abort-upgrade|abort-remove|abort-deconfigure)
......
......@@ -24,6 +24,7 @@ case "$1" in
;;
remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
systemctl disable serial-getty@ttyGS0
dpkg-trigger update-initramfs
;;
*)
......
#!/bin/sh
set -e
PREREQS=""
case $1 in
prereqs) echo "${PREREQS}"; exit 0;;
esac
. /usr/share/initramfs-tools/hook-functions
##
for pname in resize2fs; do
fpath=$(which "$pname") && copy_exec "$fpath" ||
{ echo "ERROR: no '$pname' in path" 1>&2; exit 1; }
done
# vi: ts=4 noexpandtab
#!/bin/sh
set -e
PREREQS="growroot"
case $1 in
prereqs) echo "${PREREQS}"; exit 0;;
esac
. /scripts/functions
msg() { echo "resize_rootfs:" "$@" ; }
fail() { [ $# -eq 0 ] || msg "$@"; exit 1; }
# if a file indicates we should do nothing, then just exit
for f in /var/lib/cloud/instance/root-grown /etc/growroot-disabled \
/etc/growroot-grown; do
[ -f "${rootmnt}$f" ] && exit 0
done
# Get the root device, root filesystem and mount options
if ! out=$(awk '$2 == mt { print }' "mt=${rootmnt}" < /proc/mounts) ; then
fail "${out}"
return
fi
# Need to do it this way, can't use '<<< "${out}"' since RHEL6 doesn't
# seem to understand it
read _rootdev _rootmnt rootfs opts unused <<EOF
${out}
EOF
# the filesystem is mounted read-only. Referencing the device leads toan invalid argument
umount ${rootmnt} || msg "failed to unmount ${ROOT}."
# this will fail in local-bottom due to the rootfs being mounted and read only
set +e
out=$(resize2fs "${ROOT}" 2>&1)
set -e
ret=$?
# this is taken from 'mountroot' function
# see /usr/share/initramfs-tools/scripts/local
mount -t ${rootfs} -o ${opts} ${ROOT} ${rootmnt} ||
fail "failed to re-mount ${ROOT}. this is bad!"
case "$ret" in
0) msg "succeeded" "$out";;
*) msg "exited '$ret'" "${out}"; exit 1;;
esac
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment