Skip to content

Instantly share code, notes, and snippets.

@seeekr
Last active April 24, 2022 21:58
Show Gist options
  • Save seeekr/1afa1e5ce3ad6e998367 to your computer and use it in GitHub Desktop.
Save seeekr/1afa1e5ce3ad6e998367 to your computer and use it in GitHub Desktop.
Using RAID with CoreOS (btrfs; RAID0, RAID1)
#!/bin/sh
# replace with whatever your additional device is called
# /dev/sda should be where your CoreOS install lives right now
newdevice="/dev/sdb"
# 0 or 1
raidtype="0"
# make sure to download the single-partition.layout file as well
# create single primary partition on $newdevice (you could also run fdisk interactively, choose p command and use defaults it suggests)
sudo sfdisk $newdevice < single-partition.layout
# mount current root; I suppose /dev/sda9 would work as well?
sudo mount /dev/disk/by-label/ROOT /mnt
# add btrfs device
sudo btrfs device add /dev/sdb1 /mnt
# convert to raid of given type
sudo btrfs balance start -dconvert=raid$raidtype /mnt
# should take a bit
# verify things have worked
sudo btrfs fi df /mnt
# should show something like...
#Data, RAID0: total=6.00GiB, used=303.25MiB
#System, DUP: total=8.00MiB, used=16.00KiB
#System, single: total=4.00MiB, used=0.00
#Metadata, DUP: total=108.06MiB, used=18.78MiB
#Metadata, single: total=8.00MiB, used=0.00
#unknown, single: total=16.00MiB, used=0.00
sudo umount /mnt
# partition table of /dev/sdb
unit: sectors
/dev/sdb1 : start= 2048, size=937701040, Id=83
/dev/sdb2 : start= 0, size= 0, Id= 0
/dev/sdb3 : start= 0, size= 0, Id= 0
/dev/sdb4 : start= 0, size= 0, Id= 0
@seeekr
Copy link
Author

seeekr commented Dec 11, 2014

Here's another piece of documentation I hadn't seen: https://coreos.com/docs/cluster-management/debugging/btrfs-troubleshooting/#adding-a-new-physical-disk
Maybe it's even easier and the "create partition" step isn't even required. That hadn't worked for me when trying to add the disk to btrfs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment