How to convert a Wheezy (or newer) system to btrfs

Posted by gpall on Wed 7 Mar 2012 at 11:16

Newer GRUBs can handle a /boot partition which is btrfs, so you need not have a separate /boot partition formatted as ext3/4.


The assumption of this how to is that all your filesystem is on a single partition. If you have separate /usr/, /var (etc) partitions, modify accordingly.

So, let's start.

1. Backup! I have no responsibility for whatever damages whatsoever!

2. download and write to a CD or USB stick a debian Wheezy or newer live CD.

3. Boot with that CD or USB stick

4. fsck -f /dev/sdaX (assuming /dev/sdaX is the root filesystem's partition)

5. Install your favorite editor (mine is joe) and btrfs-tools (if not already available)

6. btrfs-convert /dev/sdX

7. mount /dev/sdX /mnt

8. populate /mnt/proc, /mnt/dev, /mnt/sys like that:

mount -o bind /dev /mnt/dev
mount -o bind /sys /mnt/sys
mount -o bind /proc /mnt/proc

9. chroot /mnt

10. edit /etc/fstab, find the line for the root mountpoint (/) and change the partition from UUID to plain /dev/sdX, change the filesystem from ext3/ext4 to btrfs, change the options to just 'defaults' and change the last number of that line from 1 to 0 (the passes).

11. ls -la /boot
You will see a file named something like that: initrd.img-3.1.0-1-686-pae
The string after 'initrd.img-' is the kernel name and you will use it in the next command (12).

12. mkinitramfs 3.1.0-1-686-pae -o /boot/initrd.img-3.1.0-1-686-pae

13. grub-install /dev/sdX

14. update-grub

15. exit (exiting chroot environment)

16. umount /mnt/proc, umount /mnt/dev, umount /mnt/sys, umount /mnt

17. reboot and pray!

18. After a while you should be into your system again, and with a 'mount' you will verify that you are now running on btrfs.

19. Give as root the following:
update-initramfs -u -t -kall

20. Change back in /etc/fstab the /dev/sdX to UUID style by looking at ls -la /dev/disk/by-uuid/ | grep sd?

If all has gone fine, you can delete the backup that the conversion process has created which is /ext2_saved

Delete it with that:
btrfs subvolume delete /ext2_saved

 

 


Posted by mcortese (85.158.xx.xx) on Thu 8 Mar 2012 at 11:01
[ View Weblogs ]
10. edit /etc/fstab, find the line for the root mountpoint (/) and change the partition from UUID to plain /dev/sdX
Why is this needed?

[ Parent | Reply to this comment ]

Posted by Anonymous (94.223.xx.xx) on Tue 24 Apr 2012 at 14:25
maybe the UUID changes on conversion? (not sure about)

[ Parent | Reply to this comment ]

Posted by Anonymous (31.151.xx.xx) on Wed 25 Apr 2012 at 17:17
if you add usb disk of other disk /dev/sda can suddenly change to /dev/sdb for example.
use the command blkid to get all the UUID's.

With the us of UUID every disk is uniquely identified, this way you dont end up with an unbootable system.

[ Parent | Reply to this comment ]

Posted by rjc (86.22.xx.xx) on Sun 29 Apr 2012 at 16:40
Hi,
In order to make it easier to find this article it might be a good idea to fix the tag: brfs -> btrfs.
Cheers,
rjc

[ Parent | Reply to this comment ]

Posted by Anonymous (79.242.xx.xx) on Tue 12 Jun 2012 at 17:35
I tried this with a recent wheezy on my T23 with two different PartedMagic-Live-CDs... (one was the newest one)

Both times btrfs-convert grumbles /dev/sda1 would be mounted.

But it definitively is not.

Enough frustration for today.

[ Parent | Reply to this comment ]

Posted by Anonymous (79.242.xx.xx) on Wed 13 Jun 2012 at 02:55
Retry wit a current version of grml . , , , , , , [SUCCESS]

[ Parent | Reply to this comment ]

Posted by Lennie (2001:0xx:0xx:0xxx:0xxx:0xxx:xx) on Sat 25 Aug 2012 at 15:07
If you have "errors=remount-ro" in your fstab voor extX-filesystem, you should remove it as btrfs does not understand the option.

Also I suggest enabling noatime or your snapshots will use more diskspace every first time a snapshotted file is opened (so not the snapshot but the file that was snapped and you don't even need to write to it)

[ Parent | Reply to this comment ]

Sign In

Username:

Password:

[Register|Advanced]

 

Flattr

 

Current Poll

What do you use for configuration management?








( 700 votes ~ 10 comments )