Buildroot #
Buildroot can generate minimal VM image with custom kernel in multiple architectures:
Set up #
- Download and extract.
- Ensure the packages are installed:
bc
libnurses
libssl-dev
libelf-dev
Build for QEMU #
- Use the pre-set configuration:
make qemu_x86_64_defconfig
and make further changes withmake menuconfig
. - In
Build options
, configuremake
parallelism.
Kernel #
- In
Kernel
, use custom kernel config fragment file- kernel configuration:
use the architecture default configuration
- kernel configuration:
- To build a custom kernel version, need to select the corresponding kernel header in
ToolChain
- To modify kernel options:
make linux-menuconfig
Rebuild #
- Clean rebuild a package:
make <package>-dirclean
, this will remove the package’s builddir inoutput/build
.make linux-dirclean
will clean up Linux kernel.
- Re-run
make & make install
:make <package>-rebuild
Packages #
- In
Target packages
,Networking applications
, checkdropbear
. The ssh server will be started as part of/etc/init.d/rcS
.
Overlay directory tree #
Add files you want to include in the VM root file-system. To enable networking in the guest:
cat << EOF >> /etc/network/interfaces
auto eth0
iface eth0 inet dhcp
EOF
Add this file into the overlay directory.
Boot QEMU #
../tree/bin/qemu-system-x86_64 -enable-kvm \
-kernel ../buildroot-2020.02/output/images/bzImage \
-hda ../buildroot-2020.02/output/images/rootfs.ext4 \
-m 1G \
-append "root=/dev/sda rw console=ttyS0" \
-serial stdio \
-device virtio-rng-pci \
-device e1000,netdev=net0 \
-netdev user,id=net0,hostfwd=tcp::5555-:22