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 + |
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 |
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> | ^~~~~~~~~ |
root@linux:/home/gsf/code/bcache-tools/bcache-tools-master# make cc -O2 -Wall -g `pkg-config --cflags uuid blkid` make-bcache.c bcache.o `pkg-config --libs uuid blkid` -o make-bcache /usr/bin/ld: /tmp/ccsteIC1.o: in function `write_sb': /home/gsf/code/bcache-tools/bcache-tools-master/make-bcache.c:277: undefined reference to `crc64' collect2: error: ld returned 1 exit status make: *** [<builtin>: make-bcache] Error 1 |
<*> Block device as cache |
root@linux:/home/gsf/linux-5.18.11# qemu-system-x86_64 -kernel arch/x86_64/boot/bzImage -drive file=rootfs.f2fs,if=ide,format=raw,id=myid0 --nographic -append "root=/dev/sda console=ttyS0" -hdb disk_raw_5G_B.qcow -hdc disk_raw_3G_C.qcow -device nvme,drive=nvme1,serial=deadbeaf,num_queues=8 -drive file=disk10G.qcow,if=none,id=nvme1 -smp 4 -net nic,macaddr=52:54:00:12:34:56,model=e1000 -net bridge,id=net0,helper=/usr/lib/qemu/qemu-bridge-helper,br=virbr0 |
# ls /dev (guest中执行的命令) cpu_dma_latency sda tty26 tty56 fd sda1 tty27 tty57 full sdb tty28 tty58 ---sdb fuse sdc tty29 tty59 ---sdc nvme0 tty17 tty47 vcsu1 nvme0n1 tty18 tty48 vga_arbiter nvme0n1p1 tty19 tty49 zero |
virbr0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255 ether 52:54:00:5e:c9:bb txqueuelen 1000 (Ethernet) RX packets 299 bytes 25524 (25.5 KB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 431 bytes 1335005 (1.3 MB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 |
# wget http://192.168.122.1/make-bcache (上面ifconfig看到的ip地址) Connecting to 192.168.122.1 (192.168.122.1:80) saving to 'make-bcache' make-bcache 100% |********************************| 1273k 0:00:00 ETA 'make-bcache' saved # wget http://192.168.122.1/bcache-super-show Connecting to 192.168.122.1 (192.168.122.1:80) saving to 'bcache-super-show' bcache-super-show 100% |********************************| 908k 0:00:00 ETA 'bcache-super-show' saved # chmod 777 make-bcache # chmod 777 bcache-super-show # ls bcache-super-show make-bcache |
# /root/make-bcache -B /dev/sdb UUID: 3a5fa145-1cc9-44e0-b91c-1beaf245355f Set UUID: 25fceacc-0546-4c32-80d0-5c9881a1d67f version: 1 block_size: 1 data_offset: 16 # # /root/make-bcache -C /dev/sdc UUID: c66b56a8-bb3e-4d8e-9b9f-3b402cd6b258 Set UUID: fe0af6ee-67e8-49c3-bfec-5633ba05f782 version: 0 nbuckets: 6144 block_size: 1 bucket_size: 1024 nr_in_set: 1 nr_this_dev: 0 first_bucket: 1 |
# echo /dev/sdb > /sys/fs/bcache/register [ 2157.866302] bcache: register_bdev() registered backing device sdb # # 命令完成后,dev目次中会生成bcache0设备 # ls /dev/ autofs ptmx tty21 tty51 bcache0 pts tty22 tty52 bsg random tty23 tty53 |
# echo /dev/sdc > /sys/fs/bcache/register [ 146.450348] bcache: bch_journal_replay() journal replay done, 0 keys in 1 entries, seq 4 [ 146.453397] bcache: register_cache() registered cache device sdc 如果不注册cache device,就执行attach命令,会报下面错误: # echo "fe0af6ee-67e8-49c3-bfec-5633ba05f782" > /sys/block/bcache0/bcache/attach [ 114.804472] bcache: __cached_dev_store() Can't attach fe0af6ee-67e8-49c3-bfec-5633ba05f782 [ 114.804472] : cache set not found sh: write error: No such file or directory |
# /root/bcache-super-show /dev/sdc sb.magic ok sb.first_sector 8 [match] sb.csum 5E71456A3E5F13A8 [match] sb.version 3 [cache device] dev.label (empty) dev.uuid c66b56a8-bb3e-4d8e-9b9f-3b402cd6b258 dev.sectors_per_block 1 dev.sectors_per_bucket 1024 dev.cache.first_sector 1024 dev.cache.cache_sectors 6290432 dev.cache.total_sectors 6291456 dev.cache.ordered yes dev.cache.discard no dev.cache.pos 0 dev.cache.replacement 0 [lru] cset.uuid fe0af6ee-67e8-49c3-bfec-5633ba05f782 (该值用于写入backing dev的attach文件中) |
# echo "fe0af6ee-67e8-49c3-bfec-5633ba05f782" > /sys/block/bcache0/bcache/attach [ 151.527075] bcache: bch_cached_dev_run() cached dev sdb is running already [ 151.528160] bcache: bch_cached_dev_attach() Caching sdb as bcache0 on set fe0af6ee-67e8-49c3-bfec-5633ba05f782 |
# mkfs.f2fs /dev/bcache0 F2FS-tools: mkfs.f2fs Ver: 1.13.0 (2019-09-24) Info: Disable heap-based policy Info: Debug level = 0 Info: Trim is enabled Info: [/dev/bcache0] Disk Model: QEMU HARDDISK Info: Segments per section = 1 Info: Sections per zone = 1 Info: sector size = 512 Info: total sectors = 10485744 (5119 MB) Info: zone aligned segment0 blkaddr: 512 Info: format version with "Linux version 5.18.11-g50a65f78b667 (root@linux) (gcc (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0, GNU ld (GNU Binutils for Ubuntu) 2.34) #20 SM" Info: [/dev/bcache0] Discarding device Info: This device doesn't support BLKSECDISCARD Info: Discarded 5119 MB Info: Overprovision ratio = 2.810% Info: Overprovision segments = 148 (GC reserved = 79) Info: format successful [ 1491.536112] mkfs.f2fs (194) used greatest stack depth: 13264 bytes left |
# mkdir /mnt/bcachemp 创建一个目次用于挂载/dev/bcache0 # mount /dev/bcache0 /mnt/bcachemp [ 1672.244480] F2FS-fs (bcache0): Found nat_bits in checkpoint [ 1672.366811] F2FS-fs (bcache0): Mounted with checkpoint version = 19642f45 [ 1672.371205] mount (196) used greatest stack depth: 13144 bytes left # df -h Filesystem Size Used Available Use% Mounted on /dev/root 98.0M 74.5M 23.5M 76% / devtmpfs 44.9M 0 44.9M 0% /dev tmpfs 46.8M 0 46.8M 0% /dev/shm tmpfs 46.8M 52.0K 46.7M 0% /tmp tmpfs 46.8M 20.0K 46.8M 0% /run /dev/nvme0n1p1 10.0G 3.4G 6.6G 34% /mnt/nvmemp /dev/bcache0 5.0G 340.0M 4.7G 7% /mnt/bcachemp (bcache 挂载乐成 |
欢迎光临 ToB企服应用市场:ToB评测及商务社交产业平台 (https://dis.qidao123.com/) | Powered by Discuz! X3.4 |