Skip to content

Managing Bcache Devices

Info

Bcache only runs on specific SoftIron storage nodes, currently supported chassis include:

  • HD11120 (which is mapped to model name HD11xxx)
  • HD21216 (which is mapped to model name HD21xxx)

The bcache command line is used to configure bcache devices on SoftIron storage nodes. This utility can be used to add/remove bcache devices, list bcache devices, and initialize all storage devices into bcache devices based on the chassis product ID.

Overview of the bcache command

# bcache
HyperCloud Bcache Configuration

Usage:
  bcache [command]

Available Commands:
  add         Add a bcache device
  completion  Generate the autocompletion script for the specified shell
  help        Help about any command
  init        Initialize all bcache device(s)
  list        List all bcache devices
  remove      Remove bcache device(s)

bcache list

First, let's look at bcache list:

# bcache list --help
List all bcache devices

Usage:
  bcache list [flags]

Flags:
  -h, --help           help for list
      --model string   model name for storage node. valid models: 'auto', 'HD11xxx', 'HD21xxx' (default "auto")

And when we execute the command:

# bcache list
discovered chassis product ID : HD21216
BCACHE DEVICE CACHE DEVICE CADDY CACHE SERIAL BACKING DEVICE CADDY SLOT BACKING SERIAL UUID                                 
bcache0       sdg1         1     22043461AF7D sde            1     1    ZR5CZQA4       bed10d56-bf6a-45ea-9ab4-26e8f31e39a2 
bcache1       sdg2         1     22043461AF7D sdm            1     2    ZR5CT2Z3       f77b4fbf-024a-4d70-b554-d5af64c8c724 
bcache10      sda3         3     22043461AF0F sdd            3     3    ZR5CZMNX       89c2d0f8-ee63-43eb-968c-06f8b49f9815 
bcache2       sdg3         1     22043461AF7D sdi            1     3    ZR5D2WXF       d4580eb8-9533-405d-aa63-9791bcfd3b97 
bcache3       sdg4         1     22043461AF7D sdj            1     4    ZR5CYGTF       9d3b4219-65e7-47d3-b685-28d33a6f2919 
bcache4       sdk1         2     22043461AF5B sdl            2     1    ZR5CYMR9       ce1dffdd-579b-4999-8511-176ea052979b 
bcache5       sdk2         2     22043461AF5B sdc            2     2    ZR5CZBXG       44f7e9f0-0336-4ea7-bb58-df85ba6a108f 
bcache6       sdk3         2     22043461AF5B sdh            2     3    ZR5D09EL       433540ee-c22f-4519-82c9-6f36de74830b 
bcache7       sdk4         2     22043461AF5B sdf            2     4    ZR5CSMG7       07745b85-dce3-4b5a-badf-3d0d4ec9cb22 
bcache8       sda1         3     22043461AF0F sdo            3     1    ZR5CS7MG       99d9b757-8eec-4503-8f97-ff9b94979662 
bcache9       sda2         3     22043461AF0F sdn            3     2    ZR5CZXP8       40ecba77-84ad-4eb9-9e82-05da4036cb9f

This shows the product ID of the discovered chassis and the current bcache configuration.

HD21216

In the image above, you can see how the devices above map to the physical disks. The "slot" numbers are left to right, that is, the disk in the bottom left corner is caddy 1 slot 1.

bcache remove

# bcache remove --help
Remove bcache device(s)

Usage:
  bcache remove [flags]

Flags:
      --backingdev string   the backing device to remove (e.g., 'sdc')
      --bcachedev string    the bcache device to remove (e.g., 'bcache0'). to remove all bcache devices, use 'all'
      --cachedev string     the caching device to remove (e.g., 'sdd1')
  -h, --help                help for remove
      --model string        model name for storage node. valid models: 'auto', 'HD11xxx', 'HD21xxx' (default "auto")

Now, let's remove a bcache device and replace HDD sdi.

Important: Make sure there are no programs that are accessing the cache partition or the backing store -- bcache remove will not properly clean up the devices in that case.

You can remove a bcache device by supplying the bcache device name or the backing store and cache device names. For example, to remove the bcache device associated with backing store sdi, execute:

# bcache remove --backingdev sdi --cachedev sdg3

Or:

# bcache remove --bcachedev bcache2

If you supply backingdev and cachedev, and if the two devices don't map to the same bcache device, then the program will tell you and do nothing:

# bcache remove --backingdev sdi --cachedev sdk2
discovered chassis product ID : HD21216
Error: backing device sdi is not coupled with caching device sdk2
Usage:
  bcache remove [flags]

Flags:
      --backingdev string   the backing device to remove (e.g., 'sdc')
      --bcachedev string    the bcache device to remove (e.g., 'bcache0'). to remove all bcache devices, use 'all'
      --cachedev string     the caching device to remove (e.g., 'sdd1')
  -h, --help                help for remove
      --model string        model name for storage node. valid models: 'auto', 'HD11xxx', 'HD21xxx' (default "auto")

If you want to remove all the bcache devices from a node, execute:

# bcache remove --bcachedev all

bcache add

# bcache add --help
Add a bcache device

Usage:
  bcache add [flags]

Flags:
      --backingdev string   the backing device to use (e.g., 'sdc')
      --cachedev string     the caching device to use (e.g., 'sdd1')
  -h, --help                help for add
      --model string        model name for storage node. valid models: 'auto', 'HD11xxx', 'HD21xxx' (default "auto")

Let's add the bcache device back:

# bcache add --backingdev sdi --cachedev sdg3

If the backing store device or the cache device are in use by an existing bcache device, then the program will tell you and do nothing:

# bcache add --backingdev sdi --cachedev sdk2
discovered chassis product ID : HD21216
Error: backing device sdi is already associated with bcache device bcache2
Usage:
  bcache add [flags]

Flags:
      --backingdev string   the backing device to use (e.g., 'sdc')
      --cachedev string     the caching device to use (e.g., 'sdd1')
  -h, --help                help for add
      --model string        model name for storage node. valid models: 'auto', 'HD11xxx', 'HD21xxx' (default "auto")