Hetzner bcache ssd cache setup

Activate the Rescue System and reboot into it, choose ubuntu 20.04 as the os and partition 60gb for os installation. Reboot.

bcache installation

sudo apt install libblkid-dev
sudo apt install pkg-config
sudo apt install bcache-tools

View hard drive information

sudo lsblk

Create md0

sudo apt install mdadm
sudo mdadm --create --verbose /dev/md0 --level=1 --raid-devices=2 /dev/sda /dev/sdb
sudo mkfs.ext4 -F /dev/md0

Create bcache

sudo make-bcache -C /dev/sdc4 -B /dev/md0

-C would be the cache ssd (512gb nvme SSD)

-B would be the hdd (2x3TB soft raid1)

myconfig

NAME        MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
loop0         7:0    0  42.4M  1 loop  /snap/certbot/1280
loop1         7:1    0  99.4M  1 loop  /snap/core/11420
loop2         7:2    0  61.8M  1 loop  /snap/core20/1081
sda           8:0    0   2.7T  0 disk
└─md0         9:0    0   5.5T  0 raid0
  └─bcache0 252:0    0   5.5T  0 disk  /web
sdb           8:16   0   2.7T  0 disk
└─md0         9:0    0   5.5T  0 raid0
  └─bcache0 252:0    0   5.5T  0 disk  /web
sdc           8:32   0   477G  0 disk
├─sdc1        8:33   0    16G  0 part  [SWAP]
├─sdc2        8:34   0   512M  0 part  /boot
├─sdc3        8:35   0    30G  0 part  /
└─sdc4        8:36   0 430.4G  0 part
  └─bcache0 252:0    0   5.5T  0 disk  /web

Amount of cached data

# cat /sys/block/bcache0/bcache/dirty_data
0.0k

Writeback information

# cat /sys/block/bcache0/bcache/writeback_
writeback_delay                writeback_percent              writeback_rate_debug           writeback_rate_p_term_inverse  writeback_running
writeback_metadata             writeback_rate                 writeback_rate_d_term          writeback_rate_update_seconds

View cache mode

$ cat /sys/block/bcache0/bcache/cache_mode
[writethrough] writeback writearound none

Change cache strategy

# echo writearound > /sys/block/bcache0/bcache/cache_mode
$ cat /sys/block/bcache0/bcache/cache_mode
writethrough writeback [writearound] none

Leave a Comment

Your email address will not be published. Required fields are marked *