Changing root filesystem from ext4 back to btrfs--what needs to be done?

I currently have a Freedombox Pioneer running with the root filesystem on an external SSD. I set this up quite some time back after having a failure of btrfs on the micro-SD card. After trying numerous repair procedures, none of which fixed the problem, I set up an SSD with an EXT4 system and have been running FBX from it. Doing so does generate some errors and warnings, mostly to do with snapshots.

At the time I used rsync to copy the files from the btrfs image to the SSD ext4 partition (the SSD was connected to my laptop with a SATA to USB adapter). Now that I’m thinking that going back to btrfs might be worthwhile, my question is beyond simply creating the file system, what other steps are needed? Do I need to create any subvolumes in order to replicate the original FBX filesystem? Is an extra step needed to enable snapshots?

I’ve found threads the use btrfs replace but I don’t see that as being an option here.

TIA

Can be done, but I would make a new FreedomBox install on btrfs and then import the data from the old disk.

This may get complicated, here is a summary.

#assuming you have only a / filesystem here …

You will need to use tar on a quiescent system. There may be a tooli I’m not aware of these days, but my way goes like this…

  • create your target btrfs /
  • shut down
  • boot in single user mode, better if you mount / read only
  • Mount your btrfs device on /mnt/newroot
  • /mnt/newroot#tar cf - -C / . | tar xf -
  • there will be a way to keep the tar cf command in the / filesystem if needed, maybe something like --no-span or --exclude-path=/mnt/newroot

After that you have to fix the boot partition in grub and fix up /etc/fstab device paths to point to btrfs root. I would still expect some issues to work through after that.

Start with a new install, it will take work to get data migrated but at least your problems will be understandable.

You will also need to move your boot and swap partitions, so leave room for that on your disk.

When that is all done see the post on btrfs maintenance and reduce the number of filesystem snapshots so you only have a few at time.

1 Like

Thanks for the tip on btrfs maintenance.

I won’t be doing this through the Freedombox but rather offline using my laptop as the controlling system. The FB’s SSD will be attached with a SATA to USB adapter. Then I’ll use rsync to copy to another USB attached drive temporarily, reformat the root partition (boot and swap will remain untouched), and rsync back. Then modify fstab and such as needed.

So long as nothing special is needed other than simply setting up the btrfs partition, things should go well.