Getting NBD (Network Block Device) Back in RHEL 7.x, CentOS 7.x, RHEL 6.x and CentOS 6.x
The quick and dirty way:
- Download SRC rpm for kernel you want to build module for
- Run `rpmbuild -bp kernel.spec`. While the magic is happening here go `make pbnj` or read the latest copy of 2600…oh wait thats not printed any more..crap.
- Next go to your your kernel build directory `cd /root/rpmbuild/BUILD/kernel-$(uname -r | sed ‘s/.x86_64//’)/linux-$(uname -r)`
- type `make menuconfig`
- Go to “Device Drivers | Block devices” and set “M” on “Network block device support” exit saving new kernel config.
- Next type `make prepare && make modules_prepare && make` (make is needed otherwise you are missing symbols that the nbd.ko needs)
- If your system is older, now is the time to take your significant other to dinner, catch up on some online gaming, or play with your kids.
- Next we build just the block device modules by typing`make M=drivers/block`
- We now check the module ` modinfo drivers/block/nbd.ko` if all looks good we copy it to the running kernels extra folder in /lib/modules/$(uname -r)/extra.
- We can finally now load the module via `depmod -a && modprobe nbd`.
I will be doing some testing on NBD vs GlusterFS in a coming post. The one kicker is that the NBD and GlusterFS servers will be running on a RazPi’s with a 2G USB thumbdrive for the exported block device (thanks to the vendors at conferences!) .
hi,
I stuck without nbd on a old (6.4) ;-) centos box while being in a rush, this quick reminder helped me out – so thank you very much!
Just to mention as it may be usefull for someone:
it may be easier to use –target to rpmbuild like:
rpmbuild -bp –target=$(uname -m) SPECS/kernel.spec
on centos 6.4 the path to source would be acctually in
rpmbuild/BUILD/kernel-2.6.32-358.14.1.el6/linux-2.6.32-358.14.1.el6.i686
also, it looks like you have a small typo in depmod: ‘demod -a’ -> ‘depmod -a’
thank you!
Thanks for the pointers and typo correction Paul ! Also glad to see I am not the last person left wanting to use nbd on RHEL6 ;)
Huge help with these instructions. Saved me a ton of time. Thanks a lot man. =)
Awesome. nbd is essential for environments heavy on virtualization; qemu-nbd + nbd lets you setup a block device for almost any virtual disk; this allows you to fix, say, a corrupted root filesystem for a guest easily.
Thanks for the article – worked like a charm!
I am glad to see I am not the only person who see NBD as a very useful tool ! Thanks for the feedback folks!