今天突然发现CentOS系统没有nbd模块,只能重新装下,下面记录下整个编译过程:
系统:CentOS6.5
内核: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
至此,nbd模块已经成功编译。
下面加载nbd模块并查看成功装载后的情况:
[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]#
新闻热点
疑难解答