ubuntu编译龙蜥6.6内核源码
1.下载龙蜥内核源码
1.备份apt源
mv /etc/apt/sources.list /etc/apt/sources.list.bak
2.配置阿里云apt源
sudo bash -c "cat << EOF > /etc/apt/sources.list && apt update
deb http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse
EOF"
3.安装git
sudo apt update
sudo apt install git
4.下载龙蜥内核源码
git clone https://gitee.com/anolis/cloud-kernel.git -b release/release-6.6.52-2.y
cd cloud-kernel-release-release-6.6.52-2.y
2.编译6.6.52内核
1.安装编译内核时依赖需安装包:
sudo apt update
sudo apt install build-essential libncurses-dev bison flex libssl-dev libelf-dev bc rsync cpio liblz4-tool zstd libncurses5-dev coreutils debhelper
2.编译内核
sudo make menuconfig
sudo make -j8
sudo make modules_install
sudo make install
sudo update-grub
3.报错1:如果报错显示
make[1]: *** [/home/a/cloud-kernel-release-release-6.6.52-2.y/Makefile:1921:.] 错误 2
make: *** [Makefile:234:__sub-make] 错误 2
就需要执行make显示如下报错
a@a-Lenovo-Product:~/cloud-kernel-release-release-6.6.52-2.y$ make
CALL scripts/checksyscalls.sh
DESCEND objtool
INSTALL libsubcmd_headers
make[3]: *** 没有规则可制作目标“debian/canonical-certs.pem”,由“certs/x509_certificate_list” 需求。 停止。
make[2]: *** [scripts/Makefile.build:480:certs] 错误 2
make[1]: *** [/home/a/cloud-kernel-release-release-6.6.52-2.y/Makefile:1921:.] 错误 2
make: *** [Makefile:234:__sub-make] 错误 2
需要禁用.config下的certs.pem
sudo vim .config
禁用如下:
#CONFIG_MODULE_SIG_KEY="certs/signing_key.pem"
CONFIG_MODULE_SIG_KEY_TYPE_RSA=y
# CONFIG_MODULE_SIG_KEY_TYPE_ECDSA is not set
CONFIG_SYSTEM_TRUSTED_KEYRING=y
#CONFIG_SYSTEM_TRUSTED_KEYS="debian/canonical-certs.pem"
CONFIG_SYSTEM_EXTRA_CERTIFICATE=y
CONFIG_SYSTEM_EXTRA_CERTIFICATE_SIZE=4096
CONFIG_SECONDARY_TRUSTED_KEYRING=y
CONFIG_SYSTEM_BLACKLIST_KEYRING=y
CONFIG_SYSTEM_BLACKLIST_HASH_LIST=""
CONFIG_SYSTEM_REVOCATION_LIST=y
#CONFIG_SYSTEM_REVOCATION_KEYS="debian/canonical-revoked-certs.pem"