How to load network block device on CentOS7

13.4k views Asked by At

I am trying to load the nbd network block device on my CentOS7 server. However, I got:

modprobe nbd
modprobe: FATAL: Module nbd not found.

It would be really appreciated if anyone could tell me the best way to have nbd module loaded. And eventually, I hope I can automate this tasks via ansible.

Here is my kernel version:

$ uname -r
3.10.0-327.28.3.el7.x86_64

Thanks!

1

There are 1 answers

5
Lucas H. Xu On BEST ANSWER

I found this is useful. Please let me know if this doesn't work for you

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

This will enable the nbd on CentOS7