# compile ```bash su - echo 'jack ALL=(ALL) ALL' >> /etc/sudoers #################################### # 换source sudo mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak sudo curl -fsS -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo sudo rm -rf /etc/yum.repos.d/epel.repo sudo yum clean all sudo yum makecache fast sudo yum makecache sudo rpm -qa|grep epel-release |xargs --no-run-if-empty sudo yum remove -y sudo yum install -y epel-release #################################### # 编译环境 sudo yum group install "Development Tools" -y sudo yum install ncurses-devel bison flex elfutils-libelf-devel openssl-devel -y # sudo yum install -y ncurses-devel make gcc bc bison flex elfutils-libelf-devel openssl-devel grub2 # sudo yum install -y hmaccalc zlib-devel binutils-devel elfutils-libelf-devel ################################### sudo rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org sudo rpm -Uvh https://www.elrepo.org/elrepo-release-7.0-4.el7.elrepo.noarch.rpm sudo yum --disablerepo=\* --enablerepo="elrepo-kernel" list available sudo yum -y --enablerepo=elrepo-kernel install kernel-lt.x86_64 kernel-lt-devel.x86_64 # sudo grub2-set-default 0 && sudo grub2-mkconfig -o /etc/grub2.cfg ################################### # stable: # wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.4.10.tar.xz # longterm: wget https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.19.94.tar.xz # yum install aria2 # aria2c -s 10 https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.19.94.tar.xz aria2c -s 20 https://mirror.tuna.tsinghua.edu.cn/kernel/v4.x/linux-4.19.95.tar.xz unxz -v linux-4.19.94.tar.xz tar xvf linux-4.19.94.tar cd linux-4.19.94 # ls /boot/config* # cp -v /boot/config-3.10.0-1062.el7.x86_64 .config # cp -v /boot/config-$(uname -r) .config cp -v /boot/config-4.4.209-1.el7.elrepo.x86_64 .config ## 打开内核参数 vim .config # Ensure the following 9P options are enabled in the kernel configuration. CONFIG_NET_9P=y CONFIG_NET_9P_VIRTIO=y CONFIG_NET_9P_RDMA=y CONFIG_NET_9P_DEBUG=y (Optional) CONFIG_9P_FS=y CONFIG_9P_FS_POSIX_ACL=y CONFIG_PCI=y CONFIG_VIRTIO_PCI=y # and these PCI and virtio options: CONFIG_PCI=y CONFIG_VIRTIO_PCI=y CONFIG_PCI_HOST_GENERIC=y (only needed for the QEMU Arm 'virt' board) sh -c 'yes "" | make oldconfig' # make bzImage # make modules make make modules_install make install ######################## sudo awk -F \' '$1=="menuentry " {print i++ " : " $2}' /etc/grub2.cfg sudo grub2-editenv list sudo grub2-set-default 0 && sudo grub2-editenv list ########## # yum install psmisc lsof htop bind-utils wget curl vim nmap traceroute whois -y sudo yum install -y traceroute htop whois psmisc bc aria2 nmap openssh-server lsof net-tools curl wget git vim jq socat conntrack ipvsadm ipset sysstat libseccomp gcc gcc-c++ cmake make bzip2 automake autoconf libtool flex bison pcre-devel zlib-devel openssl openssl-devel bridge-utils bind-utils libnfnetlink-devel libnl3 libnl3-devel systemd-devel libuuid-devel device-mapper-persistent-data lvm2 libmnl-devel libnftnl-devel libnetfilter_conntrack-devel libnetfilter_queue-devel libpcap-devel ``` # ref * [Compile Linux Kernel on CentOS7](https://linuxhint.com/compile-linux-kernel-centos7/) * [我需要创建一个自设的内核](https://wiki.centos.org/zh/HowTos/Custom_Kernel) * http://mirror.bjtu.edu.cn/kernel/linux/kernel/ * http://mirror.tuna.tsinghua.edu.cn/kernel