$ make all -j 4 # 运用 4个线程编译, 或许要等很久, 最终生成内核文件 arch/x86/boot/bzImage
...
$ ls -lah arch/x86/boot/bzImage
-rw-r--r-- 1 root root 11M Jun 5 08:59 arch/x86/boot/bzImage
Kernel: arch/x86/boot/bzImage is ready (#1)
$ make help# 检查更多指令
假如遇到下面的犯错:
sre@sre:~/work/exp/jammy$ make all -j 8
...
make[1]: *** No rule to make target 'debian/canonical-certs.pem', needed by 'certs/x509_certificate_list'. Stop.
make[1]: *** Waitingfor unfinished jobs....
make: *** [Makefile:1900: certs] Error2
General setup -> Initial RAM filesystem and RAM disk (initramfs/initrd) support
Executable file formats -> Kernel support for ELF binaries
保存, 然后 make all -j 8 再次制造image, 然后运转:
$ qemu-system-x86_64 -kernel bzImage -initrd initramfs.cpio.gz -append "console=tty0 console=ttyS0 init=/bin/sh" -nographic
Run /init as init process
Failed to execute /init (error -8)
Run /bin/sh as init process
/bin/sh: can't access tty; job control turned off
/ # input: ImExPS/2 Generic Explorer Mouse as /devices/platform/i8042/serio1/input/input2clocksource: tsc: mask: 0xffffffffffffffff max_cycles: 0x311fac54234, max_idle_ns: 440795352581 nsclocksource: Switched to clocksource tsc
uname -a
Linux (none) 6.4.0-rc5+ #3 Wed Jun 7 08:19:32 PDT 2023 x86_64 GNU/Linux
/ # ls /bin/
...
/ # ps aux
PID USER TIME COMMAND
Executable file formats -> Kernel support for scripts starting with #!
2. File systems > Pseudo filesystems -> (/proc file system support & sysfs file system support)
set default=0
settimeout=10# Load EFI video drivers. This device is EFI so keep the# video mode while booting the linux kernel.
insmod efi_gop
insmod font
if loadfont /boot/grub/fonts/unicode.pf2
then
insmod gfxterm
set gfxmode=auto
set gfxpayload=keep
terminal_output gfxterm
fimenuentry 'myos' --class os {
insmod gzio
insmod part_msdos
linux /boot/bzImage init=/bin/sh console=ttyS0 console=tty0
initrd /boot/initramfs.cpio.gz
}