Created
July 31, 2017 14:47
-
-
Save xuhang57/4eef44e4ff080e03be2d833b16142305 to your computer and use it in GitHub Desktop.
Build Network Block Device Kernel Module On CentOS7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uname -r | |
sudo su | |
# useradd builder | |
# groupadd builder | |
cd /home/centos | |
# Get Source Code | |
wget http://vault.centos.org/7.2.1511/updates/Source/SPackages/kernel-3.10.0-327.28.3.el7.src.rpm | |
rpm -ivh kernel-3.10.0-327.28.3.el7.src.rpm | |
# Build Preparation | |
mkdir -p ~/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS} | |
echo '%_topdir %(echo $HOME)/rpmbuild' > ~/.rpmmacros | |
cd ~/rpmbuild/SPECS | |
rpmbuild -bp --target=$(uname -m) kernel.spec | |
cd ~/rpmbuild/BUILD/kernel-3.10.0-327.28.3.el7/linux-3.10.0-327.28.3.el7.centos.x86_64/ | |
# Build | |
make menuconfig | |
# Device Driver -> Block devices -> Set “M” On “Network block device support” | |
make prepare && make modules_prepare && make | |
make M=drivers/block -j8 | |
modinfo drivers/block/nbd.ko | |
cp drivers/block/nbd.ko /lib/modules/3.10.0-327.28.3.el7.x86_64/extra/ | |
depmod -a && sudo modprobe nbd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I had to add:
sed -i 's/REQ_TYPE_SPECIAL/REQ_TYPE_DRV_PRIV/' drivers/block/nbd.c
Before "make" to compile successfully, according to this it was renamed:
https://centosfaq.org/centos/nbd-does-not-compile-for-3100-514262el7x86_64/
All the rest was very useful, nice work!