yum install -y kernel-devel elfutils-libelf-devel
# 下载对应的内核源码包
wget https://mirrors.aliyun.com/centos-vault/7.7.1908/os/Source/SPackages/kernel-3.10.0-1062.el7.src.rpm
rpm -ihv kernel-3.10.0-1062.el7.src.rpm
cd /root/rpmbuild/SOURCES/
tar xvf linux-3.10.0-1062.el7.tar.xz -C /usr/src/kernels/
cd /usr/src/kernels/
# 配置源码
mv $(uname -r) $(uname -r)-old
mv linux-3.10.0-1062.el7 $(uname -r)
# 编译安装
cd $(uname -r)
make mrproper
cp ../$(uname -r)-old/Module.symvers ./
cp /boot/config-$(uname -r) ./.config
make oldconfig
make prepare
make scripts
sed -i 's/REQ_TYPE_SPECIAL/7/g' drivers/block/nbd.c
make CONFIG_BLK_DEV_NBD=m M=drivers/block
cp drivers/block/nbd.ko /lib/modules/$(uname -r)/kernel/drivers/block/
depmod -a
# 查看nbd模块
modinfo nbd
# 重启主机
reboot
mkdir alpine
cd alpine
wget https://raw.githubusercontent.com/alpinelinux/alpine-make-vm-image/master/alpine-make-vm-image && chmod +x alpine-make-vm-image
wget https://raw.githubusercontent.com/alpinelinux/alpine-make-vm-image/master/example/configure.sh && chmod +x configure.sh
cat > repositories <<EOF
http://mirror.lzu.edu.cn/alpine/v3.11/main
http://mirror.lzu.edu.cn/alpine/v3.11/community
EOF
./alpine-make-vm-image \
--image-format qcow2 \
--repositories-file ./repositories \
--mirror-uri http://mirror.lzu.edu.cn/alpine \
--image-size 1G \
--packages "ca-certificates ssl_client chrony less logrotate openssh sudo" \
--script-chroot \
alpine-v3.11-$(date +%Y-%m-%d).qcow2 -- ./configure.sh
gzip alpine-v3.11-$(date +%Y-%m-%d).qcow2