Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions mkrootfs-platform.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,22 @@ done
shift $((OPTIND - 1))

BASE_PKG="base-full"
PLAT_PKG=
PLAT_PKG="base-$PLATFORM"
KERNEL_PKG=

PLATFORMS="bootstrap full rpi pbp rockpro64 unmatched"
PLATFORMS="bootstrap full rpi pbp rockpro64 unmatched ec2"

for pkg in ${PLATFORMS}; do
if [ "$pkg" = "$PLATFORM" ]; then
case "$PLATFORM" in
bootstrap) BASE_PKG="base-bootstrap" ;;
full) ;;
rpi) KERNEL_PKG="linux-rpi" ;;
ec2) PLAT_PKG="systemd-boot !base-full-firmware"; KERNEL_PKG="linux-lts" ;;
*) KERNEL_PKG="linux-lts" ;;
esac
exec ./mkrootfs.sh -b "$BASE_PKG" \
-p "base-$PLATFORM $KERNEL_PKG $EXTRA_PKGS" \
-p "$PLAT_PKG $KERNEL_PKG $EXTRA_PKGS" \
-f "$PLATFORM" "$@"
fi
done
Expand All @@ -46,5 +47,5 @@ echo "unknown PLATFORM type: $PLATFORM"
echo
echo "supported platform types: full bootstrap"
echo " rpi pbp rockpro64"
echo " unmatched"
echo " unmatched ec2"
exit 1
5 changes: 5 additions & 0 deletions sfdisk/ec2
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
label: gpt
unit: sectors
first-lba: 2048
name=boot, size=@BOOT_SIZE@, type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B
name=root
36 changes: 22 additions & 14 deletions unrootfs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,7 @@
# License: BSD-2-Clause
#

readonly PROGNAME=$(basename "$0")

msg() {
printf "\033[1m$@\n\033[m"
}

die() {
msg "ERROR: $@"
exit 1
}

if [ "$(id -u)" != "0" ]; then
die "must be run as root"
fi
. ./lib.sh

usage() {
cat <<EOF
Expand Down Expand Up @@ -114,4 +101,25 @@ if [ -n "$BL_DEV" -a -r "${ROOT_DIR}/etc/default/u-boot-device" ]; then
"${ROOT_DIR}/usr/bin/install-u-boot" "${BL_DEV}" "${ROOT_DIR}"
fi

if [ -n "$BL_DEV" -a -r "${ROOT_DIR}/etc/default/systemd-boot" ]; then
[ -d /dev/disk/by-uuid ] || die "/dev/disk/by-uuid not found, gen-systemd-boot would be misled"
mount_pseudo
# NOTE(yoctozepto): aarch64 requires console= config, else it hangs (as of 20240731 on EC2 t4g)
# TODO(yoctozepto): aarch64 rootfs already has the initramfs
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@q66 Despite that I wrote just about aarch64, now also x86_64 gets the initramfs before this stage. It gets created whenever linux-lts is installed due to initramfs hooks. It was not the case even though the history suggests the same hook was installed (was it blocked from running?). Anyhow, that effort is partially wasted because the initramfs generator has no idea about the UUID of the block device for resume operations - it is going to miss it. Thus, I could skip installing linux-lts at rootfs level and postpone it till now (then get just one, proper build) - this is a bit ugly as it splits the pkg installation effort (also, as an alternative, the entire non-bootstrap part of pkgs could be installed on a loop device for sanity - although this introduces more complexity in the process) - or the previous behaviour could be restored - or else we simply decide to waste the original initramfs build and be fine with that (that's also an option). WDYT?

# TODO(yoctozepto): aarch64 rootfs includes many dtbs
chroot ${ROOT_DIR} /bin/sh -i <<EOF
set -e
bootctl install --no-variables
update-initramfs -c -k all
echo 'SD_BOOT_CMDLINE="console=tty0 console=ttyS0"' >> /etc/default/systemd-boot
gen-systemd-boot
cat > /etc/default/agetty << EOF2
EXTRA_GETTYS="/dev/ttyS0"
EOF2
EOF
if [ $? -ne 0 ]; then
die "Installing systemd-boot failed."
fi
fi

msg "Successfully installed Chimera."