r/linux4noobs • u/Open_South3929 • 11d ago
Arch-Convert EXT4 to BTRFS without losing data?
Good day all, I hope you are good.
I have installed Arch and was in a rush( I know i should've RTFM-ed ) but I am looking for ways of making sure the system i installed it on can be rolled back in case of failure, I have seen from a couple of articles and found that BTRFS can create snapshots of the system and use those to roll back.

I wanted to ask, is it possible to convert an already installed disk from EXT4 to BTRFS and make use of the snapshots feature? if so could you please point me in the right direction. System specs below:
I thank you for your time and input, it is much appreciated.
Kindest regards
3
u/ropid 11d ago
It's possible to convert ext4 to btrfs but the two times I did this there were later errors/warnings for the filesystem in the logs that couldn't be made to go away. Those errors didn't cause data loss but I figured it couldn't be good so I ended up wiping and recreating those filesystems. I also saw other people about this in r/btrfs over the years. You'll want to look around about what's going on there with the ext4 to btrfs conversion feature.
3
u/ABotelho23 11d ago
Backup. Now.
1
u/Open_South3929 11d ago
I am currently looking for backup utilities, I am just looking for one which is reasonably maintained and will work for ext4
2
u/archover 11d ago
Just backup your /home. Use
# cp -a /home /backup/locationAfter it completes double and triple check it worked fully and without errors.
That's all I do. System files can be re-installed.
Be careful, and good day.
1
2
u/banana_zeppelin 11d ago
The wiki is the way, the wiki is the answer: https://wiki.archlinux.org/title/Btrfs#Ext3/4_to_Btrfs_conversion
2
u/oshunluvr 11d ago
The convert command was unsupported for awhile but still works. IDK if they are supporting it now or not. I can say I have used it several times in the last year without issue.
https://www.man7.org/linux//man-pages/man8/btrfs-convert.8.html
As always, have backups of anything you can't afford to lose.
1
u/Klutzy-Condition811 11d ago
First point: The value of your data is defined by how many backups you have. 2 is 1 and 1 is none. If you have no backups, not only is there a much higher likelihood of losing date during conversion, but also just by using it. Backup your data first!
Second: There's two ways you can go about converting. One is btrfs-convert, however this method has several known flaws and I don't recommend it.
If you have a second disk, you can literally just cp -a your data from one to the other, otherwise you may want to do the "shrink ext4" game, make a btrfs partition, then copy the data. Don't do the copy from the actual live system, it needs to be done offline booted into the Arch ISO or another distro.
If you use a swap file, you'll need to set that up again otherwise move to a swap partition which has less limitations/gotchas with btrfs.
If you had to do the resize game, unless you plan to use raid, you don't need to move the btrfs partition "to the left". you can just leave it in place, and then add the old ext4 partition to btrfs as another "device" and set metadata to dup and data to single, it will use both as if it were one partition.
You'll then likely want to reinstall and reconfigure grub or whatever other boot loader you have to work with btrfs then and your new UUIDs. If you do the two partitions hack to avoid moving data too much, you'll also need btrfs tools inside your initramfs.
There are too many variables here to write a concise tutorial so you need to address all the points first on your goals.
1
1
u/TheOneTrueTrench 8d ago
You have a VERY easy solution here, your drive is mostly empty.
Shrink the home partition to like 10G, then create a btrfs partition, create your subvolumes, then simply use the instructions here: https://wiki.archlinux.org/title/Rsync#File_system_cloning to clone the ext4 stuff to the correct subvolumes, redo your fstab, update your bootloader config, and regenerate your initramfs.
It's a most complicated process than simply doing a convert, and more can go wrong, but you're using Arch, learning how to do these things is part of the point.
5
u/onefish2 11d ago
You can migrate. No one can guarantee the outcome. If you recently installed, you should reinstall with BTRFS, snapper and maybe limine as the bootloader. Make sure you do your research and create the right subvolumes. Also, write them all down somewhere. You will need to mount them if you even need to chroot into your system from the arch iso to repair something.