How to install using btrfs in RAID10 mode?
As a test I want to install Ubuntu 11.10 onto a btrfs file system in raid10 mode. However, I have no clue on how I should go about that. I have tried the installer, and then creating the fs in the terminal. However, that didn't work out. When I went back to the graphical interface I couldn't install. Because it didn't have any mount points. So, how should I do this?
After using the alternate installer and dropping to a shell I did the following: mkfs.btrfs -m raid10 -d raid10 /dev/sda /dev/sdb /dev/sdc /dev/sdd then you also need to run: btrfs dev scan
Then when choosing the partition to install to, select one of the above and mount that to /. Leave all partitions untouched.
This installs the system, however, installing the bootloader fails...
Solution 1:
OK, part of my problem was that I wanted to install Ubuntu Server. I have finally succeeded. To install Ubuntu Server on btrfs RAID10, use the following steps:
- Run the livecd of Ubuntu Desktop
- Use gparted to create btrfs partitions on all the disks you want to use in the btrfs RAID10 setup, be sure to leave 1 MB at the beginning of the disks for GRUB. (I leave 1 MB on all the disks, so that I could always move grub to another disk, when I replace a disk with a new/larger one.
- Save the new partition table
- shutdown
- launch the Ubuntu server installer
- at the partitioning step, break out of the installer and go to the terminal
-
in the terminal type the following command to create a btrfs RAID10 for data and metadata (Note use the partitions, not the disks!):
mkfs.btrfs -m raid10 -d raid10 /dev/sda1 /dev/sdb1 /dev/sdc1 /dev/sdd1
IMPORTANT: execute the following command:
btrfs dev scan
- go back to the partition part of the installer
- select any one disk and choose to use that as btrfs and mountpoint root
- proceed installer as normal
So this works fine, however, I later found out that this does not do what I had expected. I have 16-G, 500G and 2x 750G hard disks.
I expected to be able to use 910G. However, raid is a bit different in btrfs I got 320G. What I wanted to use is raid1, because this will create 2 copies of each data block, even if you add 4 disks (unlike the normal raid1). So now, using raid1 in btrfs I do get the 910G.
Solution 2:
I have spent a couple of hours in trying to install Ubuntu 12.04 Beta 2 Server on a RAID-1 btrfs system. The answer of balchmar has helped me a lot, thanks! However, I ended up using a slightly different approach and wanna mention it here for completeness:
-
Prepare your disk partitioning.
You can use the LiveCD or -as in my case- a previously installed 12.04 Ubuntu server installation. Important: I had to learn that, contrary to what is mentioned in the btrfs wiki, I had to use partitions instead of entire devices like /dev/sda, so that grub can install into the MBR by the Ubuntu Installer. So, here's the partition I used. Note that I use two identical 500GB disks and two partitions each, one for btrfs and one for swap:Disk /dev/sda: 500.1 GB, 500107862016 bytes 255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x0004f49a Device Boot Start End Blocks Id System /dev/sda1 * 2048 945508351 472753152 83 Linux /dev/sda2 945508352 976771071 15631360 82 Linux swap / Solaris Disk /dev/sdb: 500.1 GB, 500107862016 bytes 255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x0002505f Device Boot Start End Blocks Id System /dev/sdb1 2048 945508351 472753152 83 Linux /dev/sdb2 945508352 976771071 15631360 82 Linux swap / Solaris
Start a default Ubuntu 12.04 Server installation until the disk partition part. Don't make any selection there yet.
-
Press CTRL-ALT-F2 and enter the console. Issue the following commands, which will create a RAID-1 btrfs filesystem over /dev/sda1 and /dev/sdb1, labeling it RAID1:
make.btrfs -L RAID1 -m raid1 -d raid1 /dev/sda1 /dev/sdb1 && btrfs device scan
Press CTRL-ALT-F1 to go back to the installer and choose to manually partition your disk.
You can now choose /dev/sda1 and define the mount point '/'. Important: Do not choose to format the file system as this would delete your previously created RAID-1 one! (you may now also choose to make use of the previously defined swap devices, of course.)
Continue the installation as normal. All data will be now installed on your RAID-1 btrfs!
-
Not sure this is needed, but some people mention one has to run
btrfs filesystem balance
after the initial boot. You can check the result by issuing the following command:
$ sudo btrfs filesystem show
Label: 'RAID1' uuid: 49d2eaed-d598-462f-a768-e6e0d43dc7ce
Total devices 2 FS bytes used 635.45MB
devid 1 size 450.85GB used 1.26GB path /dev/sda1
devid 2 size 450.85GB used 1.26GB path /dev/sdb1
Btrfs Btrfs v0.19
To see that RAID-1 is actually used for data and metadata, issue
$ sudo btrfs filesystem df /
Data, RAID1: total=1.00GB, used=568.07MB
System, RAID1: total=8.00MB, used=4.00KB
System: total=4.00MB, used=0.00
Metadata, RAID1: total=256.00MB, used=67.37MB