-
-
Notifications
You must be signed in to change notification settings - Fork 32
Add Raspberry Pi image generation support #335
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
Found a bug in grml-debootstrap that existed before this PR - installing a VM image to a device such as |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some initial comments, without any further consideration
|
|
||
| # RPi images *require* non-free-firmware as the raspi-firmware package resides | ||
| # there, and Raspberry Pis are not bootable without it. | ||
| if [ -z "$_opt_non_free" ] && [ "$RPI" ]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think this will need a warning, or better it should abort if non-free(-firmware) was not requested
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently there isn't an option for just enabling non-free-firmware but not the entirety of non-free. Should that be implemented, or is the job --non-free already does good enough?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added an error message with bailout if --non-free isn't specified. If we want something that only enables non-free-firmware when possible, I'd be happy to add that too.
AFAIK, VM images were never supposed to be written to devices by grml-debootstrap. @mika ? |
|
@zeha By installing a VM image directly to a device, I mean using a command line such as |
Hm, what's the use case for |
|
Off the top of my head, I know people oftentimes store VMs in LVM volumes
rather than in files. I don't know for sure why, but I suspect performance
plays a role.
For the Raspberry Pi case specifically, being able to install directly to a
physical device would be useful to prevent someone from having to generate
an image, flash the image, and then resize the image to occupy the entire
disk. They can just install straight to the device and use it.
…On Tue, Apr 8, 2025 at 1:39 AM Michael Prokop ***@***.***> wrote:
@zeha <https://github.com/zeha> By installing a VM image directly to a
device, I mean using a command line such as --target /dev/sda --vm, not
using --vmfile. I probably just used the wrong terminology.
Hm, what's the use case for --target /dev/sda --vm exactly, as in: why
install an VM into a block device at all and not into a plain file only?
(Not claiming that there's no use case for it, but to clarify actual needs
and how far we should go with supporting that :))
—
Reply to this email directly, view it on GitHub
<#335 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AZAFFERDXAATHKG3WH2BST32YNVLBAVCNFSM6AAAAAB2P3MTM6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDOOBVGM4TCMZZGM>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
[image: mika]*mika* left a comment (grml/grml-debootstrap#335)
<#335 (comment)>
@zeha <https://github.com/zeha> By installing a VM image directly to a
device, I mean using a command line such as --target /dev/sda --vm, not
using --vmfile. I probably just used the wrong terminology.
Hm, what's the use case for --target /dev/sda --vm exactly, as in: why
install an VM into a block device at all and not into a plain file only?
(Not claiming that there's no use case for it, but to clarify actual needs
and how far we should go with supporting that :))
—
Reply to this email directly, view it on GitHub
<#335 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AZAFFERDXAATHKG3WH2BST32YNVLBAVCNFSM6AAAAAB2P3MTM6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDOOBVGM4TCMZZGM>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Ah I see, thx4info! |
|
JFTR, this is even documented in man grml-debootstrap:
(Note the example.) |
dcfd735 to
39411c8
Compare
39411c8 to
34c2baa
Compare
|
Ran thorough tests to ensure things worked as expected. "Working" is defined as "the build doesn't error out, the produced image is bootable without having to take any special steps, the
I did fix a couple of bugs in the original PR as I went, but both fixes required small, non-invasive changes. |
|
Kicksecure isn't really thrilled with the boot process that raspi-firmware uses by default, due to its effects on things like booting into older kernels, and customizing kernel parameters at boot time. If possible, we'd like to be using U-Boot and grub-efi-arm64 instead. I filed some feature requests upstream (https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1102607, https://salsa.debian.org/raspi-team/image-specs/-/issues/78) to see if this can be changed. If things do change in that area and GRUB + U-Boot booting for the Pi is officially supported in Debian, could grml-debootstrap use that boot flow instead, or at least offer it as an option? (Obviously we're more than happy to send the patch for this, I just want to make sure this will be acceptable in the future so we can do project planning.) |
I'm personally not really a huge fan of Raspberry devices, but I assume there are users out there who might benefit from it. So IMO it's also about how intrusive this change would become, and how we can ensure that things keep working. |
|
I'm not sure, I'm not exactly handy with Docker, and based on the documentation it looks like pi-ci is both an emulator and image generator, there doesn't appear to be a documented easy way to boot a custom image with it. Newer versions of QEMU have support for emulating the Raspberry Pi 4B, which might be able to be used somehow, but even then you have to specify the kernel and initramfs to boot directly (QEMU doesn't emulate the boot firmware's behavior of reading config.txt and figuring out what to boot from that). I guess it would be possible to kinda sorta emulate the boot firmware by mounting the build image, finding config.txt, parsing out the kernel and initramfs lines, copying those out of the image, then unmounting the image and booting the kernel + initramfs + image with QEMU. I'd be willing to give that a shot, though be warned that I'm not particularly experienced with CI systemd either :P |
|
It's published on dockerhub so the CI image does not have to be built from source code at least. Not sure that is still relevant...
So such as test would not directly test if either config.txt based kernel direct boot is functional. Let alone if GRUB based booting is functional.
That sounds rather complex and may not be very useful as it would not test on the CI if the image is actually bootable. It would test kernel + initramfs and anything after that. Not sure how useful that would be? Is CI testing mandatory? |
What we like and appreciate about CI testing is, that we catch any possible side-effects/breakages with any changes within g-d very early. It definitely improves our options to redesign/rewrite things, as well as accept contributions. |
To add my thought: everything that's not CI tested will break. When we'll do a refactor, nobody will test stuff that's not automatically tested, and it will just be broken. My personal view is that it's close to mandatory. |
nod && ACK! |
|
kk, then I guess I'll be adding CI to this 👍 |
|
Unfortunately, it looks like CI is going to end up being very slow if we want to use QEMU's RPi4 emulation. QEMU is unable to use KVM when emulating a Raspberry Pi 4B because the CPU in the RPi supports EL3, which can be emulated but not virtualized using KVM and QEMU. https://gitlab.com/qemu-project/qemu/-/issues/1073 has some more info on this. It is possible to boot a generated Raspberry Pi image using a more VM-friendly machine type, but it doesn't result in as accurate of Raspberry Pi emulation, which might be undesirable. Should I use the faster but less accurate mode, or the slower, more accurate one? |
|
I'll go ahead and implement this using the faster but less accurate virtualization. It's all that's necessary to make sure the image was built properly, the accurate mode is probably only necessary for making sure the kernel or firmware itself is functional on the official hardware itself (which isn't what we need to test, that should be being tested by other projects). |
|
Raspberry PI image CI testing added. https://github.com/ArrayBolt3/grml-debootstrap/actions/runs/14696085489 will show the results once the tests are done running. (I got them to pass fully in a separate branch first.) |
mika
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Briefly went over the code except for grml-debootstrap itself (had to explicitly load the diff to even see it for code review, that was unexpected :-/). I want to clarify the --imagesize vs. --vmsize situation before looking further into the actual grml-debootstrap code changes.
What's definitely missing yet before we can submit this, are according doc changes in grml-debootstrap.8.txt :)
(Thanks for working on this!)
| --vmfile \ | ||
| --vmsize 3G \ | ||
| ${extra_buildopts} \ | ||
| --imagesize 3G \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, is there a good reason why we couldn't continue using --vmsize and need to replace it with --imagesize? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could keep using --vmsize for sure, but I wanted to switch to --imagesize since now that the argument can be used for more than just VM images, I marked --vmsize as deprecated. They mean the same thing, I figured using the newer syntax would be less confusing, especially since this build command might be building an RPi image, not strictly a VM image (though it will later boot that not-really-a-VM-image in a VM so I guess it doesn't really matter that much).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. I'm not yet sure about this change, while I agree that consistency is important and if we keep it backwards compatible at least for now that should be fine. @zeha what's your take on the --vmfile vs --imagesize situation? 🤔
(BTW, AFAICS if someone uses VMSIZE=4G as environment variable on the command line, then this is no longer accepted due to the [ -n "$VMSIZE" ] || VMSIZE="2G" removal, nor?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed the environment variable issue. Will leave this thread open so zeha can comment on the --vmsize/--imagesize stuff.
|
While working on the docs, I'm realizing the |
|
Tested the new default interfaces commit on my RPi4, works like a charm, don't need to do anything special for the network to work out of the box. CI passes and documentation is updated. |
|
Hmm, that's a good point. I didn't realize environment variables were
a legal way to pass in parameters. That may require some rework.
…On Sun, May 4, 2025 at 11:54 AM Michael Prokop ***@***.***> wrote:
@mika commented on this pull request.
________________________________
In tests/docker-build-vm.sh:
> grml-debootstrap \
--debug \
--force \
- --vmfile \
- --vmsize 3G \
+ ${extra_buildopts} \
+ --imagesize 3G \
I see. I'm not yet sure about this change, while I agree that consistency is important and if we keep it backwards compatible at least for now that should be fine. @zeha what's your take on the --vmfile vs --imagesize situation? 🤔
(BTW, AFAICS if someone uses VMSIZE=4G as environment variable on the command line, then this is no longer accepted due to the [ -n "$VMSIZE" ] || VMSIZE="2G" removal, nor?)
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
|
Reworked, tested locally, |
|
Thanks, LGTM. I think we should be good to apply this, though I'm afraid it's nothing we can get into Debian/trixie at this stage. To not block ourselves for further changes/fixes of grml-debootstrap that are supposed to go into Debian/trixie, we need to postpone this merge until the trixie freeze is gone. Assigning this to our 2025/Q3 project/milestone accordingly, any further testing/feedback appreciated in the meanwhile! :) |
|
Just rebased this on the current git master. Looks like CI passes: https://github.com/ArrayBolt3/grml-debootstrap/actions/runs/20687641909 Currently testing a cross-build from amd64, will also test "build on RPi, booted on RPi" and see what happens. |
Thanks, please ping us once you think it's ready for review @ArrayBolt3 Our
Is that a GH issue or do we need to adjust/fix something, @zeha? 🤔 |
|
@mika, @zeha I believe this is ready for review. Both an amd64 cross-build (installing directly to an SD card) and an arm64 native build (installing directly to a USB drive) worked. Both installations were bootable on a Raspberry Pi 4B (and the USB native installation was done from within the amd64 cross-build installation). |
zeha
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from a glance it looks ok to me
Adds Raspberry Pi installation and image generation support. Cross-builds are supported (you can create a working Raspberry Pi image on an amd64 machine).
Some notes:
cmdline.txtfor the kernel in a highly non-ideal way, using a device path rather than a UUID for identifying the root directory. This has to be manually patched to get the image to boot at all.--defaultinterfacesto grml-debootstrap, since the/etc/network/interfacesfile used in the raspi.debian.net images is just a pointer to/etc/network/interfaces.d, which grml-debootstrap doesn't copy over. Using--defaultinterfaceswill prevent this from being a problem, not using it will mean you'll have no network when you boot the system.Fixes #114