CentOS6 compilation and load nbd module, centos6nbd Module
Today, we suddenly found that the CentOS system does not have the nbd module and can only be reinstalled. The entire compilation process is recorded below:
System: CentOS6.5
Kernel: 2.6.32-431. el6.x86 _ 64
[root@localhost ~]# yum install -y kernel-headers kernel-devel[root@localhost ~]# wget ftp://ftp.redhat.com/pub/redhat/linux/enterprise/6ComputeNode/en/os/SRPMS/kernel-2.6.32-431.el6.src.rpm[root@localhost ~]# rpm -ivh kernel-2.6.32-431.el6.src.rpm[root@localhost ~]# cd ~/rpmbuild/SOURCES/
[root@localhost SOURCES]# tar jxf linux-2.6.32-431.el6.tar.bz2 -C /usr/src/kernels/[root@localhost SOURCES]# cd /usr/src/kernels/
[root@localhost kernels]# mv $(uname -r) $(uname -r)-old
[root@localhost kernels]# mv linux-2.6.32-431.el6 $(uname -r)[root@localhost kernels]# cd $(uname -r)
[root@localhost 2.6.32-431.el6.x86_64]# make mrproper
[root@localhost 2.6.32-431.el6.x86_64]# cp ../$(uname -r)-old/Module.symvers .[root@localhost 2.6.32-431.el6.x86_64]# cp /boot/config-$(uname -r) ./.config
[root@localhost 2.6.32-431.el6.x86_64]# make oldconfig
[root@localhost 2.6.32-431.el6.x86_64]# make prepare
[root@localhost 2.6.32-431.el6.x86_64]# make scripts
[root@localhost 2.6.32-431.el6.x86_64]# make CONFIG_BLK_DEV_NBD=m M=drivers/block[root@localhost 2.6.32-431.el6.x86_64]# cp drivers/block/nbd.ko /lib/modules/$(uname -r)/kernel/drivers/block/
[root@localhost 2.6.32-431.el6.x86_64]# depmod -a
So far, the nbd module has been compiled successfully.
Next, load the nbd module and check the information after successful loading:
[root@localhost image]# modprobe nbd max_part=8[root@localhost image]# ll /dev/nbd*brw-rw---- 1 root disk 43, 0 Nov 20 21:24 /dev/nbd0brw-rw---- 1 root disk 43, 16 Nov 20 21:24 /dev/nbd1brw-rw---- 1 root disk 43, 160 Nov 20 21:24 /dev/nbd10brw-rw---- 1 root disk 43, 176 Nov 20 21:24 /dev/nbd11brw-rw---- 1 root disk 43, 192 Nov 20 21:24 /dev/nbd12brw-rw---- 1 root disk 43, 208 Nov 20 21:24 /dev/nbd13brw-rw---- 1 root disk 43, 224 Nov 20 21:24 /dev/nbd14brw-rw---- 1 root disk 43, 240 Nov 20 21:24 /dev/nbd15brw-rw---- 1 root disk 43, 32 Nov 20 21:24 /dev/nbd2brw-rw---- 1 root disk 43, 48 Nov 20 21:24 /dev/nbd3brw-rw---- 1 root disk 43, 64 Nov 20 21:24 /dev/nbd4brw-rw---- 1 root disk 43, 80 Nov 20 21:24 /dev/nbd5brw-rw---- 1 root disk 43, 96 Nov 20 21:24 /dev/nbd6brw-rw---- 1 root disk 43, 112 Nov 20 21:24 /dev/nbd7brw-rw---- 1 root disk 43, 128 Nov 20 21:24 /dev/nbd8brw-rw---- 1 root disk 43, 144 Nov 20 21:24 /dev/nbd9[root@localhost image]#