Skip to content

Instantly share code, notes, and snippets.

@seeekr
Last active April 24, 2022 21:58

Revisions

  1. seeekr revised this gist Dec 11, 2014. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions x_reference.md
    Original file line number Diff line number Diff line change
    @@ -6,3 +6,5 @@ btrfs rebalance command: http://askubuntu.com/a/412307
    essence of that: don't use -mconvert=raid0 since that would mean "use raid0 for metadata also" which is not advisable

    running fdisk in non-interactive mode: http://xmodulo.com/how-to-run-fdisk-in-non-interactive-batch-mode.html

    additional docs by coreos that already point in the right direction and that are probably a candidate for introducing explicit information about getting up and running with RAID: https://coreos.com/docs/cluster-management/debugging/btrfs-troubleshooting/
  2. seeekr revised this gist Dec 11, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion setup-raid-coreos.sh
    Original file line number Diff line number Diff line change
    @@ -20,7 +20,7 @@ sudo btrfs device add /dev/sdb1 /mnt
    # convert to raid of given type; don't use -mconvert=raid0 but not sure if it's beneficial to add -mconvert=raid1 when making a RAID1 (I think it might be!)
    sudo btrfs balance start -dconvert=raid$raidtype /mnt

    # should take a bit
    # might take a bit, depending on how much data there is to copy over

    # verify things have worked
    sudo btrfs fi df /mnt
  3. seeekr revised this gist Dec 11, 2014. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion setup-raid-coreos.sh
    Original file line number Diff line number Diff line change
    @@ -17,7 +17,7 @@ sudo mount /dev/disk/by-label/ROOT /mnt
    # add btrfs device
    sudo btrfs device add /dev/sdb1 /mnt

    # convert to raid of given type
    # convert to raid of given type; don't use -mconvert=raid0 but not sure if it's beneficial to add -mconvert=raid1 when making a RAID1 (I think it might be!)
    sudo btrfs balance start -dconvert=raid$raidtype /mnt

    # should take a bit
    @@ -32,4 +32,5 @@ sudo btrfs fi df /mnt
    #Metadata, single: total=8.00MiB, used=0.00
    #unknown, single: total=16.00MiB, used=0.00

    # clean up
    sudo umount /mnt
  4. seeekr renamed this gist Dec 11, 2014. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  5. seeekr revised this gist Dec 11, 2014. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions reference.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    original pointers from @marineam at https://github.com/coreos/docs/issues/222#issuecomment-66562561

    btrfs adding devices and rebalancing: https://btrfs.wiki.kernel.org/index.php/Using_Btrfs_with_Multiple_Devices#Adding_new_devices

    btrfs rebalance command: http://askubuntu.com/a/412307
  6. seeekr created this gist Dec 11, 2014.
    6 changes: 6 additions & 0 deletions reference.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    btrfs adding devices and rebalancing: https://btrfs.wiki.kernel.org/index.php/Using_Btrfs_with_Multiple_Devices#Adding_new_devices

    btrfs rebalance command: http://askubuntu.com/a/412307
    essence of that: don't use -mconvert=raid0 since that would mean "use raid0 for metadata also" which is not advisable

    running fdisk in non-interactive mode: http://xmodulo.com/how-to-run-fdisk-in-non-interactive-batch-mode.html
    35 changes: 35 additions & 0 deletions setup-raid-coreos.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    #!/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
    7 changes: 7 additions & 0 deletions single-partition.layout
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    # 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