我正在尝试在CentOS7服务器上加载nbd网络阻止设备。但是,我得到了:
modprobe nbd
modprobe: FATAL: Module nbd not found.
如果有人能告诉我加载
nbd
模块的最佳方法,将不胜感激。最后,我希望我可以通过ansible自动化此任务。这是我的内核版本:
$ uname -r
3.10.0-327.28.3.el7.x86_64
谢谢!
最佳答案
我发现这很有用。如果这不适合您,请告诉我
uname -r
sudo su
# useradd builder
# groupadd builder
cd /home/centos
# Get Source Code, make sure you check the kernel version first and download the proper version
wget http://vault.centos.org/7.2.1511/updates/Source/SPackages/kernel-3.10.0-327.28.3.el7.src.rpm
rpm -ivh kernel-3.10.0-327.28.3.el7.src.rpm
# Build Preparation
mkdir -p ~/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
echo '%_topdir %(echo $HOME)/rpmbuild' > ~/.rpmmacros
cd ~/rpmbuild/SPECS
rpmbuild -bp --target=$(uname -m) kernel.spec
cd ~/rpmbuild/BUILD/kernel-3.10.0-327.28.3.el7/linux-3.10.0-327.28.3.el7.centos.x86_64/
# Build
make menuconfig
# Device Driver -> Block devices -> Set “M” On “Network block device support”
make prepare && make modules_prepare && make
make M=drivers/block -j8
modinfo drivers/block/nbd.ko
cp drivers/block/nbd.ko /lib/modules/3.10.0-327.28.3.el7.x86_64/extra/
depmod -a && sudo modprobe nbd
这将在CentOS7上启用nbd