Skip to content
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

About dockerfile build kernel image #17

Closed
syntaxbender opened this issue Sep 27, 2024 · 2 comments
Closed

About dockerfile build kernel image #17

syntaxbender opened this issue Sep 27, 2024 · 2 comments

Comments

@syntaxbender
Copy link

syntaxbender commented Sep 27, 2024

Hi mate, thx for this project. I have a question about this lines from dockerfile. Why do you compile 2x "Image" file? The last compile looks like overwrite previous compiled Image file. What could I be missing?

# Compile default VM guest image
RUN make -C $BUILD_DIR/linux defconfig kvm_guest.config \
 && make -C $BUILD_DIR/linux -j$(nproc) Image # the first compiled image file

# Customize guest image
COPY src/conf/custom.conf $BUILD_DIR/linux/kernel/configs/custom.config
RUN make -C $BUILD_DIR/linux custom.config \
 && make -C $BUILD_DIR/linux -j$(nproc) Image \ 
 && mv $BUILD_DIR/linux/arch/arm64/boot/Image $BUILD_DIR/kernel.img # this is the second compiled image file
@ptrsr
Copy link
Owner

ptrsr commented Sep 28, 2024

Hi @syntaxbender , thank you for your interest in the project.

You have a keen eye. Rebuilding the kernel image is done on purpose, and the reason is quite peculiar.

You see, this is the kernel image which the VM (QEMU) uses to start the virtual raspberry pi. Normally, the kernel has a lot of plugins for things like file system and networking support. However, as we use an external kernel, we cannot use these plugins. Therefore, certain functionalities do not work in the virtual machine by default. Luckily we can include these plugins in the kernel image using the rules in custom.conf.

In practise this may require experimenting with kernel parameter rules (custom.conf) to get a certain application to run. In my use case, Docker in the virtual pi (yes, really).

As each experimentental test build requires rebuilding the kernel image, it is smart to cache the "bare bone" kernel image before modification. This saves a lot of time in between test builds. So;

  1. Cache bare bones kernel build
  2. Include plugins in cached kernel build

Recompilation time went from minutes to seconds, and its barely noticable in a full docker build.

I hope that answered your question!

@syntaxbender
Copy link
Author

thx mate, it's a good idea haha. i close the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants