Skip to content

Commit 5089cdd

Browse files
committed
debos: Split in two recipes for rootfs and image
This reduces the time under QEMU and paves the way to generating multiple images. Signed-off-by: Loïc Minier <[email protected]>
1 parent 6087dac commit 5089cdd

File tree

4 files changed

+115
-93
lines changed

4 files changed

+115
-93
lines changed

.github/workflows/debos.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,15 @@ jobs:
9090
# these commands are run inside the container
9191
cat <<EOF
9292
cd /build
93+
# start by building the root filesystem
94+
debos qualcomm-linux-debian-rootfs.yaml
9395
# debos tries KVM and UML as backends, and falls back to building
9496
# directly on the host, but that requires loop devices; use
9597
# qemu backend explicitly even if it's slower
9698
# qemu backend also requires to set scratchsize, otherwise
9799
# the whole build is done from memory and the out of memory
98100
# killer gets triggered
99-
debos -b qemu --scratchsize 4GiB qualcomm-linux-debian.yaml
101+
debos -b qemu --scratchsize 4GiB qualcomm-linux-debian-image.yaml
100102
EOF
101103
) | sudo incus exec "${INCUS_NAME}" -- sh
102104

README.md

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ main: Primary development branch. Contributors should develop submissions based
2121

2222
To build a disk image, run debos as follows:
2323
```bash
24-
debos debos-recipes/qualcomm-linux-debian.yaml
24+
# build a root filesystem tarball
25+
debos debos-recipes/qualcomm-linux-debian-rootfs.yaml
26+
27+
# build a disk image from the root filesystem
28+
debos debos-recipes/qualcomm-linux-debian-image.yaml
2529
```
2630

2731
### Build backends
@@ -30,21 +34,24 @@ By default, debos will try to pick a fast build backend; it will try to use its
3034

3135
To build large images, the debos resource defaults might not be sufficient. Consider raising the default debos memory and scratchsize settings. This should provide a good set of minimum defaults:
3236
```bash
33-
debos --fakemachine-backend qemu --memory 1GiB --scratchsize 4GiB debos-recipes/qualcomm-linux-debian.yaml
37+
debos --fakemachine-backend qemu --memory 1GiB --scratchsize 4GiB debos-recipes/qualcomm-linux-debian-image.yaml
3438
```
3539

3640
### Build options
3741

38-
A few options are provided in the debos recipe:
42+
A few options are provided in the debos recipes; for the root filesystem recipe:
43+
- experimentalkernel: update the linux kernel to the version from experimental; default: don't update the kernel
44+
- xfcedesktop: install a Xfce desktop environment; default: console only environment
45+
46+
For the image recipe:
47+
- dtb: override the firmware provided device tree with one from the linux kernel, e.g. `qcom/qcs6490-rb3gen2.dtb`; default: don't override
3948
- image: set the output disk image filename; default: `disk.img`
4049
- imagesize: set the output disk image size; default: `4GiB`
41-
- dtb: override the firmware provided device tree with one from the linux kernel, e.g. `qcom/qcs6490-rb3gen2.dtb`; default: don't override
42-
- xfcedesktop: install a Xfce desktop environment; default: console only environment
43-
- experimentalkernel: update the linux kernel to the version from experimental; default: don't update the kernel
4450

4551
These can be passed as follows:
4652
```bash
47-
debos -t dtb:qcom/qcs6490-rb3gen2.dtb -t xfcedesktop:true -t experimentalkernel:true debos-recipes/qualcomm-linux-debian.yaml
53+
debos -t xfcedesktop:true -t experimentalkernel:true debos-recipes/qualcomm-linux-debian-rootfs.yaml
54+
debos -t dtb:qcom/qcs6490-rb3gen2.dtb debos-recipes/qualcomm-linux-debian-image.yaml
4855
```
4956

5057
## Flashing Instructions
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
{{- $dtb := or .dtb "firmware" }}
2+
{{- $image := or .image "disk.img" }}
3+
{{- $imagesize := or .imagesize "4GiB" }}
4+
5+
architecture: arm64
6+
7+
actions:
8+
- action: unpack
9+
description: Unpack root filesystem
10+
compression: gz
11+
file: rootfs.tar.gz
12+
13+
{{- if ne $dtb "firmware" }}
14+
- action: run
15+
description: Use OS device tree override (board specific)
16+
chroot: true
17+
command: |
18+
set -eu
19+
mkdir -p /etc/kernel
20+
echo {{ $dtb }} >/etc/kernel/devicetree
21+
{{- end }}
22+
23+
# parttype values are from:
24+
# https://www.freedesktop.org/wiki/Specifications/DiscoverablePartitionsSpec/
25+
- action: image-partition
26+
description: Create an image file
27+
imagename: {{ $image }}
28+
imagesize: {{ $imagesize }}
29+
partitiontype: gpt
30+
partitions:
31+
- name: esp
32+
partlabel: ESP
33+
flags: [ boot, esp ]
34+
# EFI System Partition
35+
parttype: c12a7328-f81f-11d2-ba4b-00a0c93ec93b
36+
fs: vfat
37+
start: 4MiB
38+
# size of 512MiB
39+
end: 516MiB
40+
fsck: true
41+
- name: root
42+
# Root Partition (64-bit ARM/AArch64)
43+
parttype: b921b045-1df0-41c3-af44-4c6f280d3fae
44+
fs: ext4
45+
# 4MiB after ESP
46+
start: 520MiB
47+
end: 100%
48+
fsck: true
49+
mountpoints:
50+
- mountpoint: /boot/efi/
51+
partition: esp
52+
- mountpoint: /
53+
partition: root
54+
55+
# XXX these kernel options might be specific to a kernel version or board
56+
- action: filesystem-deploy
57+
setup-fstab: true
58+
append-kernel-cmdline: clk_ignore_unused pd_ignore_unused audit=0 deferred_probe_timeout=30
59+
60+
- action: apt
61+
recommends: true
62+
description: Make system bootable with systemd-boot
63+
packages:
64+
- systemd-boot
65+
# TODO investigate why systemd-boot Recommends: shim-signed which
66+
# Depends on grub packages
67+
- shim-signed-
68+
69+
- action: run
70+
description: Create task to grow root filesystem on first boot
71+
chroot: true
72+
command: |
73+
set -eu
74+
# for growpart
75+
apt -y install cloud-guest-utils
76+
# extract the dev of the root filesystem from fstab; change UUID=id into
77+
# /dev/disk/by-uuid/id
78+
ROOTFS_DEV=$(
79+
awk '$2 == "/" {gsub("UUID=", "/dev/disk/by-uuid/"); print $1}' \
80+
/etc/fstab
81+
)
82+
# generate systemd unit to grow the second partition with above UUID
83+
cat >/etc/systemd/system/debos-grow-rootfs.service <<EOF
84+
[Unit]
85+
Description=Grow root partition and filesystem (debos)
86+
[Service]
87+
Type=oneshot
88+
ExecStartPre=-sh -c 'growpart /dev/\`lsblk -n -o pkname $ROOTFS_DEV\` 2'
89+
ExecStart=resize2fs $ROOTFS_DEV
90+
[Install]
91+
WantedBy=default.target
92+
EOF
93+
# enable unit
94+
systemctl enable debos-grow-rootfs
95+

debos-recipes/qualcomm-linux-debian.yaml renamed to debos-recipes/qualcomm-linux-debian-rootfs.yaml

Lines changed: 3 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
{{- $image := or .image "disk.img" }}
2-
{{- $imagesize := or .imagesize "4GiB" }}
3-
{{- $dtb := or .dtb "firmware" }}
41
{{- $xfcedesktop := or .xfcedesktop "false" }}
52
{{- $experimentalkernel := or .experimentalkernel "false" }}
63

@@ -187,86 +184,7 @@ actions:
187184
/etc/apt/sources.list.d/debian-experimental.sources
188185
{{- end }}
189186

190-
# parttype values are from:
191-
# https://www.freedesktop.org/wiki/Specifications/DiscoverablePartitionsSpec/
192-
- action: image-partition
193-
description: Create an image file
194-
imagename: {{ $image }}
195-
imagesize: {{ $imagesize }}
196-
partitiontype: gpt
197-
partitions:
198-
- name: esp
199-
partlabel: ESP
200-
flags: [ boot, esp ]
201-
# EFI System Partition
202-
parttype: c12a7328-f81f-11d2-ba4b-00a0c93ec93b
203-
fs: vfat
204-
start: 4MiB
205-
# size of 512MiB
206-
end: 516MiB
207-
fsck: true
208-
- name: root
209-
# Root Partition (64-bit ARM/AArch64)
210-
parttype: b921b045-1df0-41c3-af44-4c6f280d3fae
211-
fs: ext4
212-
# 4MiB after ESP
213-
start: 520MiB
214-
end: 100%
215-
fsck: true
216-
mountpoints:
217-
- mountpoint: /boot/efi/
218-
partition: esp
219-
- mountpoint: /
220-
partition: root
221-
222-
# XXX these kernel options might be specific to a kernel version or board
223-
- action: filesystem-deploy
224-
setup-fstab: true
225-
append-kernel-cmdline: clk_ignore_unused pd_ignore_unused audit=0 deferred_probe_timeout=30
226-
227-
{{- if ne $dtb "firmware" }}
228-
- action: run
229-
description: Use OS device tree override (board specific)
230-
chroot: true
231-
command: |
232-
set -eu
233-
mkdir -p /etc/kernel
234-
echo {{ $dtb }} >/etc/kernel/devicetree
235-
{{- end }}
236-
237-
- action: apt
238-
recommends: true
239-
description: Make system bootable with systemd-boot
240-
packages:
241-
- systemd-boot
242-
# TODO investigate why systemd-boot Recommends: shim-signed which
243-
# Depends on grub packages
244-
- shim-signed-
245-
246-
- action: run
247-
description: Create task to grow root filesystem on first boot
248-
chroot: true
249-
command: |
250-
set -eu
251-
# for growpart
252-
apt -y install cloud-guest-utils
253-
# extract the dev of the root filesystem from fstab; change UUID=id into
254-
# /dev/disk/by-uuid/id
255-
ROOTFS_DEV=$(
256-
awk '$2 == "/" {gsub("UUID=", "/dev/disk/by-uuid/"); print $1}' \
257-
/etc/fstab
258-
)
259-
# generate systemd unit to grow the second partition with above UUID
260-
cat >/etc/systemd/system/debos-grow-rootfs.service <<EOF
261-
[Unit]
262-
Description=Grow root partition and filesystem (debos)
263-
[Service]
264-
Type=oneshot
265-
ExecStartPre=-sh -c 'growpart /dev/\`lsblk -n -o pkname $ROOTFS_DEV\` 2'
266-
ExecStart=resize2fs $ROOTFS_DEV
267-
[Install]
268-
WantedBy=default.target
269-
EOF
270-
# enable unit
271-
systemctl enable debos-grow-rootfs
187+
- action: pack
188+
file: rootfs.tar.gz
189+
compression: gz
272190

0 commit comments

Comments
 (0)