1*59cbe840SWarner LoshSo to make a Linux initrd: 2*59cbe840SWarner Losh 3*59cbe840SWarner Losh(1) mkdir .../initrd 4*59cbe840SWarner Losh(2) mkdir -p .../initrd/boot/defaults 5*59cbe840SWarner Losh(3) cd src/stand; make install DESTDIR=.../initrd 6*59cbe840SWarner Losh(4) Copy kernel to .../initrd/boot/kernel 7*59cbe840SWarner Losh(5) cd .../initrd 8*59cbe840SWarner Losh(6) cp boot/loader.kboot init 9*59cbe840SWarner Losh(7) find . | sort | cpio -o -H newc | gzip > /tmp/initrd.cpio 10*59cbe840SWarner Losh(8) download or build your linux kernel 11*59cbe840SWarner Losh(9) qemu-system-x86_64 -kernel ~/vmlinuz-5.19.0-051900-generic \ 12*59cbe840SWarner Losh -initrd /tmp/initrd.cpio \ 13*59cbe840SWarner Losh -m 256m -nographic \ 14*59cbe840SWarner Losh -monitor telnet::4444,server,nowait -serial stdio \ 15*59cbe840SWarner Losh -append "console=ttyS0" 16*59cbe840SWarner Losh (though you may need more than 256M of ram to actually boot FreeBSD and do 17*59cbe840SWarner Losh anything interesting with it and the serial console to stdio bit hasn't 18*59cbe840SWarner Losh been the most stable recipe lately). 19*59cbe840SWarner Losh 20*59cbe840SWarner LoshNotes: 21*59cbe840SWarner LoshFor #6 you might need to strip loader.kboot if you copy it directly and don't 22*59cbe840SWarner Losh use make install. 23*59cbe840SWarner LoshFor #7 the sort is important, and you may need LC_ALL=C for its invocation 24*59cbe840SWarner LoshFor #7 gzip is but one of many methods, but it's the simplest to do. 25*59cbe840SWarner LoshFor #9, this means we can automate it using methods from 26*59cbe840SWarner Losh src/tools/boot/rootgen.sh when the time comes. 27*59cbe840SWarner Losh#9 also likely generalizes to other architectures 28*59cbe840SWarner LoshFor #8, see https://kernel.ubuntu.com/~kernel-ppa/mainline/ to download 29*59cbe840SWarner Losh a kernel suitable for testing... For arm, I've been using the 30*59cbe840SWarner Losh non 64k page kernels and 5.19 seems to not suck. 31*59cbe840SWarner Losh 32*59cbe840SWarner Loshaarch64: 33*59cbe840SWarner Loshqemu-system-aarch64 -m 1024 -cpu cortex-a57 -M virt \ 34*59cbe840SWarner Losh -kernel ~/linuxboot/arm64/kernel/boot/vmlinuz-5.19.0-051900-generic \ 35*59cbe840SWarner Losh -initrd ~/linuxboot/arm64/initrd.img -m 256m -nographic \ 36*59cbe840SWarner Losh -monitor telnet::4444,server,nowait -serial stdio \ 37*59cbe840SWarner Losh -append "console=ttyAMA0" 38*59cbe840SWarner Losh 39*59cbe840SWarner LoshGeneral 40*59cbe840SWarner Losh 41*59cbe840SWarner LoshAdd -g -G to have gdb stop and wait for the debugger. This is useful for 42*59cbe840SWarner Loshdebugging the trampoline (hbreak will set a hardware break that's durable across 43*59cbe840SWarner Loshcode changes). If you set the breakpoint for the trampoline and it never hits, 44*59cbe840SWarner Loshthen there's likely no RAM there and you got the PA to load to wrong. When 45*59cbe840SWarner Loshdebugging the trampiline and up to that, use gdb /boot/loader. When debugging 46*59cbe840SWarner Loshthe kernel, use kernel.full to get all the debugging. hbreak panic() is useful 47*59cbe840SWarner Loshon the latter since you'll see the original panic, not the panic you get from 48*59cbe840SWarner Loshthere not being an early console. 49