# 编译 ```bash cat /etc/*release PRETTY_NAME="Debian GNU/Linux 10 (buster)" NAME="Debian GNU/Linux" VERSION_ID="10" VERSION="10 (buster)" VERSION_CODENAME=buster ID=debian HOME_URL="https://www.debian.org/" SUPPORT_URL="https://www.debian.org/support" BUG_REPORT_URL="https://bugs.debian.org/" uname -r 4.19.0-5-amd64 ``` ```bash apt install build-essential libncurses-dev bison flex libssl-dev libelf-dev curl wget git vim bc xz-utils wget https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.19.67.tar.xz unxz -v linux-4.19.67.tar.xz wget https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.19.67.tar.sign ``` ```bash gpg --verify linux-4.19.67.tar.sign gpg: directory '/root/.gnupg' created gpg: keybox '/root/.gnupg/pubring.kbx' created gpg: assuming signed data in 'linux-4.19.67.tar' gpg: Signature made Fri 16 Aug 2019 04:13:42 AM EDT gpg: using RSA key 647F28654894E3BD457199BE38DBBDC86092693E gpg: Can't check signature: No public key gpg --recv-keys 647F28654894E3BD457199BE38DBBDC86092693E gpg: key 38DBBDC86092693E: 174 signatures not checked due to missing keys gpg: key 38DBBDC86092693E: public key "Greg Kroah-Hartman " imported gpg: no ultimately trusted keys found gpg: Total number processed: 1 gpg: imported: 1 gpg --verify linux-4.19.67.tar.sign ``` ```bash tar xvf linux-4.19.67.tar cd linux-4.19.67 cp -v /boot/config-$(uname -r) .config # vi .config sh -c 'yes "" | make oldconfig' diff .config .config.old 3c3 < # Linux/x86 4.19.67 Kernel Configuration --- > # Linux/x86 4.19.37 Kernel Configuration 7c7 < # Compiler: gcc (Debian 8.3.0-6) 8.3.0 --- > # Compiler: gcc-8 (Debian 8.3.0-6) 8.3.0 12d11 < CONFIG_CC_HAS_ASM_GOTO=y 673a673 > CONFIG_X86_X32_DISABLED=y 2996c2996 < # CONFIG_AX88796B_PHY is not set --- > # CONFIG_ASIX_PHY is not set 5314d5313 < CONFIG_NOUVEAU_LEGACY_CTX_SUPPORT=y 5422,5423d5420 < # CONFIG_FB_NVIDIA is not set < # CONFIG_FB_RIVA is not set 6052c6049 < CONFIG_USB_COMMON=y --- > CONFIG_USB_COMMON=m 6952c6949 < # CONFIG_ASHMEM is not set --- > CONFIG_ASHMEM=m 6974a6972 > # CONFIG_XIL_AXIS_FIFO is not set 7581c7579,7581 < # CONFIG_ANDROID_BINDER_IPC is not set --- > CONFIG_ANDROID_BINDER_IPC=m > CONFIG_ANDROID_BINDER_DEVICES="binder" > # CONFIG_ANDROID_BINDER_IPC_SELFTEST is not set 7736d7735 < # CONFIG_NTFS_FS is not set 7978a7978 > CONFIG_SECURITY_PERF_EVENTS_RESTRICT=y 7993a7994,7996 > CONFIG_LOCK_DOWN_KERNEL=y > CONFIG_ALLOW_LOCKDOWN_LIFT_BY_SYSRQ=y > CONFIG_LOCK_DOWN_IN_EFI_SECURE_BOOT=y 8251c8254 < CONFIG_SYSTEM_TRUSTED_KEYS="" --- > # CONFIG_SYSTEM_TRUSTED_KEYS="debian/certs/debian-uefi-certs.pem" 8255a8259,8260 > CONFIG_EFI_SIGNATURE_LIST_PARSER=y > CONFIG_LOAD_UEFI_KEYS=y ``` ```bash make make modules_install make install # update-initramfs -c -k 4.19.67 # update-grub # update-grub2 sh ./arch/x86/boot/install.sh 4.19.67 arch/x86/boot/bzImage \ System.map "/boot" run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 4.19.67 /boot/vmlinuz-4.19.67 run-parts: executing /etc/kernel/postinst.d/initramfs-tools 4.19.67 /boot/vmlinuz-4.19.67 update-initramfs: Generating /boot/initrd.img-4.19.67 run-parts: executing /etc/kernel/postinst.d/zz-update-grub 4.19.67 /boot/vmlinuz-4.19.67 Generating grub configuration file ... Found linux image: /boot/vmlinuz-4.19.67 Found initrd image: /boot/initrd.img-4.19.67 Found linux image: /boot/vmlinuz-4.19.0-5-amd64 Found initrd image: /boot/initrd.img-4.19.0-5-amd64 done ``` ```bash make[1]: *** No rule to make target 'debian/certs/debian-uefi-certs.pem', needed by 'certs/x509_certificate_list'. Stop. make: *** [Makefile:1046: certs] Error 2 # 完成或者安装过程出错,可以清理上次编译的现场 # make mrproper # make clean # make distclean # make bzImage # make modules ``` # 删除 ```bash cd /lib/modules/4.19.67 find . -name '*.ko' | wc -l # end Kernel panic not syncing system is deadlocked on memory # 内存不够 rm -rf /boot/*4.19.67 rm -rf /boot/config-4.19.67 rm -rf /boot/initrd.img-4.19.67 rm -rf /boot/System.map-4.19.67 rm -rf /boot/vmlinuz-4.19.67 rm -rf /lib//modules​/4.19.67 update-grub ``` # 验证 ```bash uname -a Linux debian 4.19.67 #1 SMP Mon Aug 19 23:49:58 EDT 2019 x86_64 GNU/Linux ``` # 参考 * [The Linux Kernel Archives](https://www.kernel.org/) * [How to compile and install Linux Kernel 5.1.14 from source code](https://www.cyberciti.biz/tips/compiling-linux-kernel-26.html) * [linux内核基础及其编译安装](https://blog.51cto.com/9124573/1713255) * [What does “make oldconfig” do exactly in the Linux kernel makefile?](https://stackoverflow.com/questions/4178526/what-does-make-oldconfig-do-exactly-in-the-linux-kernel-makefile) * [Compiled kernel 4.19 will not boot: “Kernel panic not syncing : System is deadlocked on memory”](https://unix.stackexchange.com/questions/492667/compiled-kernel-4-19-will-not-boot-kernel-panic-not-syncing-system-is-deadlo) * [linux.git](https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/) * [编译Linux内核](https://www.cnblogs.com/wang_yb/p/3899439.html)