TransWikia.com

Can I change my Bcache settings on the fly?

Ask Ubuntu Asked on December 29, 2021

I made a fresh install of ubuntu 20.04 on my desktop, and then, from within the installation, created a bcache device to put my /home

sudo make-bcache -C /dev/sdb4 -B /dev/sda1

Where /dev/sdb is the ssd and /dev/sda is the hdd.
But after doing so, editing fstab, and transferring the data into the partition, I realized that I never set it to –writeback mode or specified the cache replacement policy

make-bcache --help
Usage: make-bcache [options] device
    -C, --cache     Format a cache device
    -B, --bdev      Format a backing device
    -b, --bucket        bucket size
    -w, --block     block size (hard sector size of SSD, often 2k)
    -o, --data-offset   data offset in sectors
        --cset-uuid     UUID for the cache set
        --writeback     enable writeback
        --discard       enable discards
        --cache_replacement_policy=(lru|fifo)
    -h, --help      display this help and exit

Is it possible to change the configuration of my existing bcache to do that without losing data or would I be better starting over?

One Answer

You can change both replacement policy and cache mode via the /sys interfaces while the system is running. Just echo the appropriate setting word to the file and it changes the setting.

The control file contents show the available options and current setting when you read them - for example:

# cat /sys/fs/bcache/[you cache id]/cache0/cache_replacement_policy
[lru] fifo random

and

# cat /sys/block/[your bcache device]/bcache/cache_mode
writethrough writeback [writearound] none

Answered by Rob AKA on December 29, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP