HOWTO: Convert a BBQ system to btrfs

Forum rules
Share your brain ;)
User avatar
RandomCharacter
Gangbanger
Posts: 323
Joined: Thu Aug 15, 2013 5:25 pm

HOWTO: Convert a BBQ system to btrfs

Unread post by RandomCharacter » Fri Oct 03, 2014 8:58 pm

Yesterday, I installed BBQ Hot Dog. I have an eye toward moving away from Arch Linux and making BBQ my primary system. Therefore, I want it to be on btrfs. While it was not complicated, I thought others might be interested (and a couple of guys on the irc channel expressed such an interest).

I started with a few specific goals. First, of course, was just to get my new system on btrfs and make sure it would boot, successfully. Next, I wanted it to use my two fast internal drives in a RAID-0 configuration. Finally, I decided I would try not having /home on separate partitions, but making it a subvolume of the main filesystem.

So, first I created two 40 GB partitions, one on each disk drive. Next, I installed Hot Dog to one of the partitions, letting bbqinstaller format it as ext4. Then I made the grub config and verified that the new system would boot.

Next, I booted to another Linux system (a live iso would do just as well), because the filesystem being converted cannot be mounted. The command to do the conversion was simple:

Code: Select all

btrfs-convert /dev/sda6
This ran in about 5 seconds given the fresh, minimal installation. I rebooted again. Success! However, there was some error early in the reboot. I made the grub.cfg again, and the next boot was error free.

The next step was to add the other partition on the other drive to the btrfs array. Since this was being done to an existing filesystem, it was necessarily a two-step process:

Code: Select all

btrfs device add /dev/sdb6 /
btrfs balance start -dconvert=raid0 -mconvert=raid1 /
It was my choice to stripe the data and mirror the metadata. User data could be mirrored instead of striped, if desired. This step also succeeded and I now had my BBQ system running on two-drive RAID0.

The final thing I wanted to accomplish was to make /home into a btrfs subvolume instead of simply a directory under root. It took a little thought, but it was easy in the end. I did this as root so that no one would be using /home while I made the change:

Code: Select all

mv /home /homeold
btrfs subvolume create /home
cp -ar /homeold/* /home
Easy peasy! I logged in as my normal user and verified that it was using the new subvolume. There are a couple of advantages to making important directories be btrfs subvolumes. One is that a subvolume can be mounted, although I have never used this feature. The reason I like it is snapshots. I can make a snapshot of / without including /home, and vice versa. I use this ability when making backups and for possible restores.

So, that's it. Not too bad, was it?

Tim

ADDENDUM 9-Oct-2014

Well, I had some problems, some simple and some not so much. I think I am to a "solid" place now.

1) Since the filesystem was converted, it came to have a different UUID from the original ext4. At least, I think that's why it changed. So, I had to edit fstab with the new UUID.

2) Also, even though it didn't seem to be causing problems, I also edited the filesystem in fstab to include the standard options for btrfs, "rw,relatime,space_cache". And I edited the filesystem type from ext4 to btrfs. Finally, I made the final field a 0 instead of 1, because btrfs's should not be fsck'ed.

3) This was the difficult problem. The filesystem became full, even though it was 80 GB in size and less than three GB were being used. It could not be written to because of being full. I tried a lot of stuff and did a lot of searches. To make a long story short, I fixed it by remounting it as rw, then running "btrfs subv delete /ext2_saved". That was a subvolume where btrfs had saved the ext4 filesystem when the btrfs-convert was run. After that, I ran "btrfs balance start /", which relocated all of the filesystem's data chunks.
Last edited by RandomCharacter on Thu Oct 09, 2014 11:13 pm, edited 1 time in total.

User avatar
rust collector
Motörhead
Posts: 535
Joined: Mon Jan 13, 2014 3:56 pm
Location: no_nb

Re: HOWTO: Convert a BBQ system to btrfs

Unread post by rust collector » Fri Oct 03, 2014 9:20 pm

Thanks Tim!

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: HOWTO: Convert a BBQ system to btrfs

Unread post by machinebacon » Fri Oct 03, 2014 9:21 pm

Thank you Tim for the write-up, to be honest I should have (!) actually changed to btrfs a long time ago but there's too much data on too many hard drives spread over forty-something partitions, and it would need a lot of organization and copying first. Will happen sometime in 2015 I guess ;)
..gnutella..

User avatar
RandomCharacter
Gangbanger
Posts: 323
Joined: Thu Aug 15, 2013 5:25 pm

Re: HOWTO: Convert a BBQ system to btrfs

Unread post by RandomCharacter » Thu Oct 09, 2014 11:16 pm

See the top post for some additional info, due to problems I had. The new info is at the bottom.

This was the first time I have converted from ext4 to btrfs. I usually make the btrfs filesystem prior to installing a distro, and install to the btrfs. The conversion caused a few glitches.

Tim

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: HOWTO: Convert a BBQ system to btrfs

Unread post by machinebacon » Fri Oct 10, 2014 9:25 am

Hmmm, one of the reasons I never play with btrfs :) But thanks for the addendum. It was quite clear that UUID would cause problems (I hate UUID with a passion!)
..gnutella..

Post Reply