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
[ Parent | Reply to this comment ]
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 ]
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 ]
Both times btrfs-convert grumbles /dev/sda1 would be mounted.
But it definitively is not.
Enough frustration for today.
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
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 ]
[ Send Message | View Weblogs ]
[ Parent | Reply to this comment ]