今天突然发现CentOS系统没有nbd模块,只能重新装下,下面记录下整个编译过程:
[[email protected] ~]# yum install -y kernel-headers kernel-devel [[email protected] ~]# wget ftp://ftp.redhat.com/pub/redhat/linux/enterprise/6ComputeNode/en/os/SRPMS/kernel-2.6.32-431.el6.src.rpm [[email protected] ~]# rpm -ivh kernel-2.6.32-431.el6.src.rpm [[email protected] ~]# cd ~/rpmbuild/SOURCES/ [[email protected] SOURCES]# tar jxf linux-2.6.32-431.el6.tar.bz2 -C /usr/src/kernels/ [[email protected] SOURCES]# cd /usr/src/kernels/ [[email protected] kernels]# mv $(uname -r) $(uname -r)-old [[email protected] kernels]# mv linux-2.6.32-431.el6 $(uname -r) [[email protected] kernels]# cd $(uname -r) [[email protected] 2.6.32-431.el6.x86_64]# make mrproper [[email protected] 2.6.32-431.el6.x86_64]# cp ../$(uname -r)-old/Module.symvers . [[email protected] 2.6.32-431.el6.x86_64]# cp /boot/config-$(uname -r) ./.config [[email protected] 2.6.32-431.el6.x86_64]# make oldconfig [[email protected] 2.6.32-431.el6.x86_64]# make prepare [[email protected] 2.6.32-431.el6.x86_64]# make scripts [[email protected] 2.6.32-431.el6.x86_64]# make CONFIG_BLK_DEV_NBD=m M=drivers/block [[email protected] 2.6.32-431.el6.x86_64]# cp drivers/block/nbd.ko /lib/modules/$(uname -r)/kernel/drivers/block/ [[email protected] 2.6.32-431.el6.x86_64]# depmod -a
至此,nbd模块已经成功编译。
下面加载nbd模块并查看成功装载后的情况:
[[email protected] image]# modprobe nbd max_part=8 [[email protected] image]# ll /dev/nbd* brw-rw---- 1 root disk 43, 0 Nov 20 21:24 /dev/nbd0 brw-rw---- 1 root disk 43, 16 Nov 20 21:24 /dev/nbd1 brw-rw---- 1 root disk 43, 160 Nov 20 21:24 /dev/nbd10 brw-rw---- 1 root disk 43, 176 Nov 20 21:24 /dev/nbd11 brw-rw---- 1 root disk 43, 192 Nov 20 21:24 /dev/nbd12 brw-rw---- 1 root disk 43, 208 Nov 20 21:24 /dev/nbd13 brw-rw---- 1 root disk 43, 224 Nov 20 21:24 /dev/nbd14 brw-rw---- 1 root disk 43, 240 Nov 20 21:24 /dev/nbd15 brw-rw---- 1 root disk 43, 32 Nov 20 21:24 /dev/nbd2 brw-rw---- 1 root disk 43, 48 Nov 20 21:24 /dev/nbd3 brw-rw---- 1 root disk 43, 64 Nov 20 21:24 /dev/nbd4 brw-rw---- 1 root disk 43, 80 Nov 20 21:24 /dev/nbd5 brw-rw---- 1 root disk 43, 96 Nov 20 21:24 /dev/nbd6 brw-rw---- 1 root disk 43, 112 Nov 20 21:24 /dev/nbd7 brw-rw---- 1 root disk 43, 128 Nov 20 21:24 /dev/nbd8 brw-rw---- 1 root disk 43, 144 Nov 20 21:24 /dev/nbd9 [[email protected] image]#
时间: 2024-11-03 05:20:00