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
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