安裝
apt install bcache-tools
建立資料碟(必須大於快取碟)
make-bcache -B /dev/sdx1
建立快取碟(ram disk 不適用)
make-bcache --block 4k --bucket 2M -C /dev/sdy1
指定 資料碟的快取碟
echo $(bcache-super-show /dev/sdy1|grep cset.uuid|awk '{print $2}') >/sys/block/bcache0/bcache/attach
make-bcache -B /dev/sda /dev/sdb -C /dev/sdc
查詢 bcache 運作狀態
cat /sys/block/bcache0/bcache/state
no cache: 沒有 cache 設備
clean: 正常,cache clean
dirty: 正常,cache 模式 writeback,cache 狀態 dirty
inconsistent: 有問題,cache 及 資料沒有同步
查詢cache 模式
cat /sys/block/bcache0/bcache/cache_mode
[writethrough] writeback writearound none
更改 cache 模式
echo writeback > /sys/block/bcache0/bcache/cache_mode
bcache 裝置顯示
/dev/bcacheN
/dev/bcache/by-uuid/UUID
/dev/bcache/by-label/LABEL
停用設備
echo 1 > /sys/block/sdX/sdX[Y]/bcache/stop
停止快取
echo 1 > /sys/block/sdX/sdX[Y]/bcache/detach
安全移除快取
echo <cache-set-uuid> > /sys/block/bcache0/bcache/detach
釋放已使用裝置
echo 1 > /sys/fs/bcache/<cache-set-uuid>/stop
重新載入 bcache 裝置
partprobe (apt install parted)
echo /dev/sdX > /sys/fs/bcache/register
echo /dev/sdY > /sys/fs/bcache/register
Force flush of cache to backing device
echo 0 > /sys/block/bcache0/bcache/writeback_percent
相關檔案 /etc/tmpfile.d/bcache.conf
w /sys/block/bcache0/bcache/sequential_cutoff - - - - 1M
w /sys/block/bcache0/bcache/cache_mode - - - - writeback
沒有留言:
張貼留言