NDB recompilation on Centos 7

Recompilare NBD pe Centos 7

Gasita cu greu pe internet, asa ca share aici pana nu dispare si de pe internet: nbd nightmare pe centos 7… Nu, nu inteleg de ce nu este default in kernel, mai ales ca este folosit de qemu…



Get Source Code

First check your kernel version via:

$ uname -r

Then find the corresponding kernel source rpm under vault.centos.org, download its rpm and install it.

$ wget http://vault.centos.org/7.1.1503/updates/Source/SPackages/kernel-3.10.0-229.7.2.el7.src.rpm
# useradd builder
# groupadd builder
$ rpm -ivh kernel-3.10.0-1127.8.2.el7.src.rpm


Build Preparation

As a normal user, do following:

$ echo '%_topdir %(echo $HOME)/rpmbuild' > ~/.rpmmacros
$ cd ~/rpmbuild/SPECS
$ rpmbuild -bp --target=$(uname -m) kernel.spec
$ cd ~/rpmbuild/BUILD/kernel-3.10.0-1127.8.2.el7/linux-3.10.0-1127.8.2.el7.x86_64/
$ ls
arch     COPYING  Documentation  fs       ipc      kernel       Makefile  README          scripts   tools
block    CREDITS  drivers        include  Kbuild   lib          mm        REPORTING-BUGS  security  usr
configs  crypto   firmware       init     Kconfig  MAINTAINERS  net       samples         sound     virt

Now the source code tree is available.



In the kernel source directory, type make menuconfig for configurating the kernel configuration, select :

Device Driver -> Block devices -> Set “M” On “Network block device support”

Save the configuration and exit, now begin to make via:

$ make prepare && make modules_prepare && make

Now makeout the kernel module and copy it to modules directory:

$ make M=drivers/block -j8
$ modinfo drivers/block/nbd.ko
$ sudo cp drivers/block/nbd.ko /lib/modules/3.10.0-1127.8.2.el7.x86_64/extra/
$ sudo depmod -a && sudo modprobe nbd