Btrfs:RAID Setup ================ :author: Aaron Ball :email: nullspoon@iohq.net I recently became very interested in http://en.wikipedia.org/wiki/Logical_Volume_Manager_%28Linux%29[LVM] and its ability to have a volume that spans multiple drives. I was just about to do an LVM setup when I began researching https://btrfs.wiki.kernel.org/index.php/Main_Page[btrfs] in more depth. It is rumored to be the next replacement for https://ext4.wiki.kernel.org/index.php/Main_Page[ext4], the default Linux filesystem (in most cases). It also happpens to support volumes that span multiple devices (http://en.wikipedia.org/wiki/Standard_RAID_levels[raid], though software raid albeit), aside from a whole https://btrfs.wiki.kernel.org/index.php/Main_Page#Features[list] of other functionalities. Being a person who really enjoys trying new, cool, and often unstable things (who doesn't love a good learning experience), I decided to set up a http://en.wikipedia.org/wiki/Standard_RAID_levels#RAID_5[raid 5] using btrfs with three whopping one terabyte drives. If all goes well, I should be able to loose one drive and still have 2 terabytes ( [3-1]*1000 = 2000 ) fully functional. [[getting-started]] == Getting Started Creating a btrfs filesystem is as simple as creating an ext4 filesystem (or any other filesystem for that matter). You use the mkfs command. However, I created a raid setup, so I needed a few more parameters. Here's what I used. ---- mkfs.btrfs -m raid5 -d raid5 /dev/sdb /dev/sdc /dev/sdd ---- Well that was easy. What'd we just do? [cols=",",options="header",] |================================================================ |mkfs.btrfs |duh |-m raid5 |Sets the metadata up to use raid 5 |-d raid5 |Set the data up to use raid 5 |/dev/sdb /dev/sdc /dev/sdd |Span our volume across these devices |================================================================ With that, you should now [very quickly] have a new raid 5 (or whatever you selected for your raid levels). To mount it, run the mount command on any of the raw devices in your raid. ---- mount -t btrfs /dev/sdb /mnt/oh_heyyy ---- [[compression]] == Compression Btrfs supports various kinds of seamless compression. The default is none since compression will cause a performance hit (naturally). I thought I'd give it a try anyways. I set up lzo compression (supposedly the fastest compression, but less effective) about half way through my sync job (forgot to do it initially). The original total size of the files in each home directory came to 386 GB (lots of users for a home system). The end result after compression was 377 GB, so I ended up saving 9 GB of space while still getting an amazing transfer rate (see the link:#Benchmarks[ benchmarks] section). Keep in mind though that I enabled compression after I had already synced a good 100 GB of files, so there is a good portion of that data that isn't compressed. Despite that though, 9 GB of space isn't too bad, especially given the performance. [[handy-commands]] == Handy Commands Here's what commands I'm using most frequently up to this point. * **btrfs fi**[lesystem] **show**: Shows a list of filesystems and their corresponding devices. * **btrfs fi**[lesystem] **label