Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please add support for bcache #6

Open
Massimo-B opened this issue Sep 21, 2017 · 3 comments
Open

Please add support for bcache #6

Massimo-B opened this issue Sep 21, 2017 · 3 comments

Comments

@Massimo-B
Copy link

Please add support to create a initramfs with bcache support to be able to boot from bcache devices.

@globalcitizen
Copy link

Based on https://evilpiepirate.org/git/linux-bcache.git/tree/Documentation/bcache.txt it seems that:

To make bcache devices known to the kernel, echo them to /sys/fs/bcache/register:

  echo /dev/sdb > /sys/fs/bcache/register
  echo /dev/sdc > /sys/fs/bcache/register

To register your bcache devices automatically, you could add something like
this to an init script:

  echo /dev/sd* > /sys/fs/bcache/register_quiet

It'll look for bcache superblocks and ignore everything that doesn't have one.

Registering the backing device makes the bcache show up in /dev; you can now
format it and use it as normal. But the first time using a new bcache device,
it'll be running in passthrough mode until you attach it to a cache. See the
section on attaching.

The devices show up at /dev/bcacheN, and can be controlled via sysfs from
/sys/block/bcacheN/bcache:

  mkfs.ext4 /dev/bcache0
  mount /dev/bcache0 /mnt

Cache devices are managed as sets; multiple caches per set isn't supported yet
but will allow for mirroring of metadata and dirty data in the future. Your new
cache set shows up as /sys/fs/bcache/<UUID>

General takeaway:

  • Not yet configuration stable (addition of multiple caches may cause a later need for code changes)
  • Support should be very easy to add, because auto-scanning as a default behaviour should be safe and there is a small number of common device prefixes that would tend to be used with SSD drives
  • I don't have a test system so can't validate any code

Proposal for defaults/initrd.scripts:

if [ -e /sys/fs/bcache ]
then
   # friendly message about bcache being detected goes here
   echo /dev/sd* /dev/nvm* > /sys/fs/bcache/register_quiet
fi

@gitowok
Copy link

gitowok commented Oct 30, 2018

I've just implemented and tested this based on @globalcitizen's code contribution above. I'm using btrfs on bcache as root filesystem. It needed a slight tweak to work - you cant echo all the devices at once into register_quiet

I edited /usr/share/genkernel/defaults/linuxrc . This needs to be after modules are loaded and devtmpfs is mounted, but critically - BEFORE btrfs device scan. I inserted this code right before the "start iSCSI" section, around about line 417:

# bcache device registration
if [ -e /sys/fs/bcache ]
then
   # friendly message about bcache being detected goes here
   for potential_bcache_device in /dev/sd* /dev/nvm* 
   do
        echo $potential_bcache_device > /sys/fs/bcache/register_quiet
   done
fi

It should be noted that the kernel was built with bcache was compiled as built-in rather than as module. Building as a module would require editting some other files to make sure bcache module is inserted before the above code is executed.

@Flowdalic
Copy link

Note that this issue essentially duplicates https://bugs.gentoo.org/605094

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants