Skip to content

Commit 181999e

Browse files
committed
WIP: to-disk test flow & fixes
1 parent 92cab58 commit 181999e

File tree

9 files changed

+90
-88
lines changed

9 files changed

+90
-88
lines changed

examples/.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
test.img
2+
backups
3+
bootc-bls/bootc
4+
bootc-bls/extra/usr/lib/dracut/modules.d/37bootc/bootc-initramfs-setup
5+
bootc-uki/VARS_CUSTOM.secboot.qcow2.template
6+
bootc-uki/bootc
7+
bootc-uki/extra/usr/lib/dracut/modules.d/37bootc/bootc-initramfs-setup
8+
bootc-uki/secureboot/
9+
systemd-bootx64.efi

examples/bootc-bls/build

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,12 @@ set -eux
44

55
cd "${0%/*}"
66

7-
cargo build --release --bin bootc --bin bootc-initramfs-setup
7+
# cargo build --release --features=composefs-backend
88

99
cp ../../target/release/bootc .
1010
cp ../../target/release/bootc-initramfs-setup extra/usr/lib/dracut/modules.d/37bootc/
1111

12-
mkdir -p tmp
13-
1412
podman build \
1513
-t quay.io/fedora/fedora-bootc-bls:42 \
1614
-f Containerfile \
17-
--iidfile=tmp/iid \
1815
.

examples/bootc-uki/Containerfile.stage1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ COPY bootc /usr/bin
44

55
RUN passwd -d root
66

7-
# need to have composefs setup root in the initramfs so we need this
7+
# need to have bootc-initramfs-setup in the initramfs so we need this
88
RUN set -x; \
99
kver=$(cd /usr/lib/modules && echo *); \
1010
dracut -vf --install "/etc/passwd /etc/group" /usr/lib/modules/$kver/initramfs.img $kver;

examples/bootc-uki/Containerfile.stage2

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ RUN --mount=type=secret,id=key \
99
set -eux
1010

1111
mkdir -p /etc/kernel /etc/dracut.conf.d
12-
echo "console=ttyS0,115200 composefs=${COMPOSEFS_FSVERITY} selinux=1 enforcing=0 systemd.debug_shell=1 root=UUID=6523f8ae-3eb1-4e2a-a05a-18b695ae656f rw" > /etc/kernel/cmdline
12+
echo "console=ttyS0,115200 composefs=${COMPOSEFS_FSVERITY} selinux=1 enforcing=0 audit=0 systemd.debug_shell=1 root=UUID=4f68bce3-e8cd-4db1-96e7-fbcaf984b709 rw" > /etc/kernel/cmdline
1313

14+
rm "/etc/yum.repos.d/fedora-cisco-openh264.repo"
1415
dnf install -y systemd-ukify sbsigntools systemd-boot-unsigned
1516
kver=$(cd /usr/lib/modules && echo *)
17+
mkdir -p "/boot/EFI/Linux"
1618
ukify build \
1719
--linux "/usr/lib/modules/$kver/vmlinuz" \
1820
--initrd "/usr/lib/modules/$kver/initramfs.img" \
@@ -24,7 +26,7 @@ RUN --mount=type=secret,id=key \
2426
--secureboot-certificate "/run/secrets/cert" \
2527
--measure \
2628
--json pretty \
27-
--output "/boot/$kver.efi"
29+
--output "/boot/EFI/Linux/$kver.efi"
2830
sbsign \
2931
--key "/run/secrets/key" \
3032
--cert "/run/secrets/cert" \
@@ -39,7 +41,7 @@ RUN --mount=type=bind,from=kernel,target=/_mount/kernel <<EOF
3941
mkdir -p /boot/EFI/Linux
4042
# We put the UKI in /boot for now due to composefs verity not being the
4143
# same due to mtime of /usr/lib/modules being changed
42-
cp /_mount/kernel/boot/$kver.efi /boot/EFI/Linux/$kver.efi
44+
cp -r /_mount/kernel/boot/* /boot/
4345
EOF
4446

4547
FROM base as final-final

examples/bootc-uki/build.base

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,17 @@ set -eux
44

55
cd "${0%/*}"
66

7-
cargo build --release --bin bootc --bin bootc-initramfs-setup
7+
# cargo build --release --features=composefs-backend
8+
9+
IMAGE="quay.io/fedora/fedora-bootc-base-uki:42"
810

911
cp ../../target/release/bootc .
1012
cp ../../target/release/bootc-initramfs-setup extra/usr/lib/dracut/modules.d/37bootc/
1113

1214
mkdir -p tmp
1315

1416
podman build \
15-
-t quay.io/fedora/fedora-bootc-base-uki:42 \
17+
-t "$IMAGE" \
1618
-f Containerfile.stage1 \
1719
--iidfile=tmp/iid \
1820
.

examples/bootc-uki/build.final

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,15 @@ set -eux
44

55
cd "${0%/*}"
66

7-
cargo build --release --bin bootc
7+
# cargo build --release --features=composefs-backend
8+
9+
IMAGE="quay.io/fedora/fedora-bootc-base-uki:42"
810

911
cp ../../target/release/bootc .
1012

11-
rm -rf tmp/sysroot
13+
mount /dev/vdb3 tmp
14+
15+
# rm -rf tmp/sysroot
1216
mkdir -p tmp/sysroot/composefs
1317

1418
IMAGE_ID="$(sed s/sha256:// tmp/iid)"
@@ -37,11 +41,12 @@ sudo podman build \
3741
--build-arg=COMPOSEFS_FSVERITY="${COMPOSEFS_FSVERITY}" \
3842
-f Containerfile.stage2 \
3943
--secret=id=key,src=secureboot/db.key \
40-
--secret=id=cert,src=secureboot/db.crt \
41-
--iidfile=tmp/iid2
44+
--secret=id=cert,src=secureboot/db.crt
4245

4346
rm -rf tmp/efi
4447
mkdir -p tmp/efi
4548
./bootc internals cfs --repo tmp/sysroot/composefs oci pull containers-storage:"${IMAGE_ID}"
4649
./bootc internals cfs --repo tmp/sysroot/composefs oci compute-id --bootable "${IMAGE_ID}"
4750
./bootc internals cfs --repo tmp/sysroot/composefs oci prepare-boot "${IMAGE_ID}" --bootdir tmp/efi
51+
52+
umount tmp

examples/bootc-uki/install-grub.sh

Lines changed: 0 additions & 29 deletions
This file was deleted.

examples/bootc-uki/install-systemd-boot.sh

Lines changed: 0 additions & 45 deletions
This file was deleted.

examples/to-disk.sh

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/bin/bash
2+
3+
set -euxo pipefail
4+
5+
bootc_project="/srv/bootc"
6+
IMAGE="quay.io/fedora/fedora-bootc-bls:42"
7+
8+
if [[ "$PWD" != "$bootc_project/examples" ]]; then
9+
echo "Run this command from $bootc_project/examples"
10+
exit 1
11+
fi
12+
13+
if [[ ! -f systemd-bootx64.efi ]]; then
14+
echo "Needs /srv/bootc/examples/systemd-bootx64.efi to exists for now"
15+
exit 1
16+
fi
17+
18+
rm -rf ./test.img
19+
rm -rf ./test.img
20+
truncate -s 15G test.img
21+
22+
# --env RUST_LOG=debug \
23+
# --env RUST_BACKTRACE=1 \
24+
# -v /srv/bootc/target/release/bootc:/usr/bin/bootc:ro,Z \
25+
podman run \
26+
--rm --privileged \
27+
--pid=host \
28+
-v /dev:/dev \
29+
-v /var/lib/containers:/var/lib/containers \
30+
-v /var/tmp:/var/tmp \
31+
-v $PWD:/output \
32+
--security-opt label=type:unconfined_t \
33+
"${IMAGE}" \
34+
bootc install to-disk \
35+
--composefs-native \
36+
--bootloader=systemd \
37+
--source-imgref "containers-storage:$IMAGE" \
38+
--target-imgref="$IMAGE" \
39+
--target-transport="docker" \
40+
--filesystem=ext4 \
41+
--wipe \
42+
--generic-image \
43+
--via-loopback \
44+
--karg "selinux=1" \
45+
--karg "enforcing=0" \
46+
--karg "audit=0" \
47+
/output/test.img
48+
49+
# Manual systemd-boot installation
50+
losetup /dev/loop0 test.img
51+
partx --update /dev/loop0
52+
mkdir -p efi
53+
mount /dev/loop0p2 efi
54+
55+
cp systemd-bootx64.efi efi/EFI/fedora/grubx64.efi
56+
mkdir -p efi/loader
57+
echo "timeout 5" > efi/loader/loader.conf
58+
rm -rf efi/EFI/fedora/grub.cfg
59+
60+
umount efi
61+
losetup -d /dev/loop0

0 commit comments

Comments
 (0)