ubuntu20.04 调试bcache源码

搭建单步调试bcache的环境,/dev/sdb作为backing dev, /dev/sdc作为cache dev。

一、宿主机环境

1)安装ubuntu 20.04 :

参考ubuntu20.04 搭建kernel调试环境第一篇--安装系统_ubuntu kernel-CSDN博客安装,其中的第六节(安装qemu)、第七节(安装apache服务)安装完成即可。

2)配置网络

host(ubuntu系统)和guest(qemu运行的系统,待调试)之间需共享文件,所以需要配置网络。

参考ubuntu20.04 搭建kernel调试环境第六篇(上)--网络配置_ubuntu20 menuconfig-CSDN博客,按其中的第三节(ubuntu宿主机配置步骤)、第4节(buildroot配置)、第五节(启动虚拟机)配置,最终能ping通外网就行。

二、静态编译bcache-tools工具

guest运行的kernel是我们自己编译的,busybox只支持一些简单的命令,动态库也很少,所以无法使用apt-get install bcache-tools方式安装bcache的用户态工具。需要自己下载源码,然后用静态方式编译出可执行文件。

1)git下载bcache-tools源码:
git clone https://github.com/g2p/bcache-tools.git

2) Makefile改成静态编译

root@linux:/home/gsf/code/bcache-tool-git/bcache-tools# git diff Makefile
diff --git a/Makefile b/Makefile
index c824ae3..ccea7ee 100644
--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,8 @@ PREFIX=/usr
 UDEVLIBDIR=/lib/udev
 DRACUTLIBDIR=/lib/dracut
 INSTALL=install
-CFLAGS+=-O2 -Wall -g
+CFLAGS+=-O2 -Wall -g -static
+

3)编译bcache-tools

root@linux:/home/gsf/code/bcache-tool-git/bcache-tools# make

root@linux:/home/gsf/code/bcache-tool-git/bcache-tools# make install
install -m0755 make-bcache bcache-super-show    /usr/sbin/  (关注这一行中的两个文件)
install -m0755 probe-bcache bcache-register        /lib/udev/
install -m0644 69-bcache.rules    /lib/udev/rules.d/
install -m0644 -- *.8 /usr/share/man/man8/
install -D -m0755 initramfs/hook    /usr/share/initramfs-tools/hooks/bcache
install -D -m0755 initcpio/install    /usr/lib/initcpio/install/bcache
install -D -m0755 dracut/module-setup.sh /lib/dracut/modules.d/90bcache/module-setup.sh

可能遇到的错误1:

Perhaps you should add the directory containing `uuid.pc'
to the PKG_CONFIG_PATH environment variable
No package 'uuid' found
Package blkid was not found in the pkg-config search path.
Perhaps you should add the directory containing `blkid.pc'
to the PKG_CONFIG_PATH environment variable
No package 'blkid' found
make-bcache.c:11:10: fatal error: blkid.h: No such file or directory
   11 | #include <blkid.h>
      |          ^~~~~~~~~

解决:apt-get install libblkid-dev

可能遇到的错误2:

root@linux:/home/gsf/code/bcache-tools/bcache-tools-master# make
cc -O2 -Wall -g `pkg-config --cflags uuid blkid`    make-bca
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值