Change ext4 to Btrfs and load a timeshift backup

Hi!
I’ve been thinking about change my system to Btrfs. This is my plan

  1. Format disk to Btrfs, same partitioning as before
  2. Load the timeshift backup
    2.1. Chage the UUID"s in fstab

If all work as should be, then config Btrfs, subvolumes and snapshots.

What do you guys think, any step I need to add??

1 Like

Well, if you want to have subvolumes, then you should create those before restoring your backups, because I do not believe that you can convert a regular directory into a subvolume. Conversely, a subvolume does act as a directory.

Something to keep into account, through ─ even though it may not apply to you ─ is that if you have /usr on a separate subvolume, then you should modify /etc/mkinitcpio.conf and rebuild your initramfs.

If you’re going with the default Manjaro setup for the initramfs and /usr is either on a separate filesystem or on a distinct subvolume, then you’ll need to add the usr and shutdown hooks. Don’t add the fsck hook because btrfs doesn’t use that ─ it has its own integrity check built-in.

I have however found that replacing the udev hook ─ and other required hooks that depend on the udev hook ─ and letting systemd take care of the configuration of the initramfs is easier, and it shaves a second off of the boot time.

This is the pertinent line from my own /etc/mkinitcpio.conf:arrow_down:

HOOKS=(base systemd autodetect modconf block keyboard sd-vconsole filesystems shutdown)

The sd-vconsole hook will automatically configure your initramfs with the correct keyboard layout, and the systemd hook will detect the correct modules to add, including if /usr is on a separate filesystem or subvolume.

1 Like

Hi!
Thanks 4 for your ideas!!!
I’m thinking in just 3 subv, @,@home,@var, for now.

1 Like

This can work if you just copy the data from the snapshot instead of restoring. However, there is another alternative:

  1. Live convert ext4 to btrfs
  2. Create the desired subvolumes
  3. Move data to the subvolumes
  4. Update fstab, mkinitcpio.conf and grub configuration

This way you don’t need the extra partition or drive to shift the data. However, clean install with btrfs and migrating the data will result in a cleaner setup.

Hi!
After read a little more about Btrfs, the ideas of @Aragorn, and make some test in a vm. This is my new plan:

  1. Using manjaro-architect install the system with Btrfs,subvolums,kde,etc
  2. Once the system is installed, install timeshift, load the backup.
  3. Install snapper, make configs files for all subvolums, config them
1 Like

Hi!

I think isn’t support converting / partitions

I already have the backup in other drive ( / and /home). I don’t use /home for personal information, I have it all in other drive, just change path of the /home forders.
So I think a cleaner install would be better

Was about to open a topic until I came across this thread. I am also considering converting my existing system partition from ext4 to btrfs. But after reading the Arch wiki I’m a little confused. It mentions an /ext2_saved subvolume, which I’m guessing is a backup of existing data. Where exactly is this created?

I’d appreciate it if you laid out a step by step conversion guide.

HI!
The ext2_saved subvolum is an *image file created with your system when it was a extX filesystem.
Right now I’m creating a How-To, I’ll post it when It’s done

2 Likes

Looking forward to the guide. Thanks.

Hi!
This is the guide, as it now is a beta version but I would like to post it so anyone can propose anything to add, remove,etc. Besides formatting, typos, etc.

How-To BTRFS and Snapshots

How-To BTRFS and SNAPSHOTS for N@@bs

  1. Install system in BTRFS format on a sdd disk using manjaro-architect.iso
    1.1 Partitions
    • boot fat32 /boot/efi 512M EFI
    • root btrfs / 50G options " noatime,sdd,clear_cache,commit=120,compress=zstd,subvolid=256
    • home btrfs /home 70G options " noatime,sdd,clear_cache,commit=120,compress=zstd,subvolid=256

1.2 Subvolums
- @ /
- @home /home

  1. Snapper

2.1 Create config files for each Partition
- We need root acces
- # snapper -c root create-config /
- # snapper -c home create-config /home

2.2 Config the snapper config files
- We need root acces
- The method is the same por any config file (/ /home)
- # nano /etc/snapper/configs/root
- Edit the variable ALLOW_USERS="@USER"
- Edit “limits for timeline cleanup” section #this is my own
Hourly=“0”
Daily=“2”
Weekly=“4”
Monthy=“12”
Yearly=“1”

2.3 Adding @USER permissions to the snapshots dirs
- # chmod a+rw /.snapshots/
- # chmod a+rw /home/.snapshots/

2.4 Enable and start snapper services
- We need root acces
- # systemctl start snapper-timeline.timer
- # systemctl enable snapper-timeline.timer
- # systemctl start snapper-cleanup.timer
- # systemctl enable snapper-cleanup.timer

2.5 Enable grub-btrfs services
- We need root acces
- # systemctl start grub-btrfs.path
- # systemctl enable grub-btrfs.path

2.6 List the snapshots created
- As @USER
- $ snapper -c list

2.7 Create a snapshot manualy
-As @USER
- $ snapper -c create -c timeline --description

2.8 Changing permissions of snapshots
- By default all snapshots are set as Read-Only
- Check snapshops permissions as @USER
- $ btrfs property list -ts /.snapshots//snapshot/ # for @
- $ btrfs property list -ts /home/.snapshops//snapshot # for @home
- Changing snaphots permissions to Write
- We need root acces
- # sudo btrfs property set -ts /.snapshots//snapshot/ ro false #for @
- # sudo btrfs property set -ts /home/.snaphots//snapshot/ ro false #for @home

Now we`ll see all root snapshots created on grub and we’ll be able to boot up with any of them

  1. Snapper-gui
    • It’s a front-end of snapper.
    • You can create, edit,load, delete any snapshot created
    • It let you load or create a snapshot including other subvolums like @home

If you don’t like/want to use snapper and snapper-gui,there’s another alternative, Timeshift.

How-To convert to btrfs

How-To Convert an ext2/3/4 filesystem in a btrfs system

- I come to the conclusion that this type of conversion isn't recommended. It could couse a lot of problems, non booteable systems, corrupt/loss data, etc. So I made my own workaround
  1. Do a full backup of your system, / and /home with Timeshift or other application who use RSYNC

  2. Boot up with a live system

  3. Do the partitioning using btrfs,in my case, I made /boot/efi / /home,it’ll create only the subvolume @ for / (that happens in all my tryouts).

3.1 Cheching subvolumes
- We need root acces
- # btrfs subvolume list

In this case, using the live we need to mount the / partition first.
- # mount /dev/sdXN /mnt
- # btrfs subvolume list /mnt

  1. Creating other subvolumes

    • In this case we’re going to create a subvolume for /home, it will be @home.
    • With our / partition mounted in /mnt, we’re going to delete the /home folder
      • rm -rf /mnt/home

    • Then we create a the @home subvolume
      • btrfs subvolume create /mnt/@home

    • Now we can mount the /home partition into the subvolume
      • mount /dev/sdXN /mnt/@home

  2. Restoring the backup

    • You could use any application or you could use rsync to do it.
  3. Edit the fstab

    • Change the old UUID to the news, the partitions format and mount options

      nano /mnt/etc/fstab

  4. Reinstall Grub

Looking forward to your feedbacks

2 Likes

Just reinstall Manjaro and copy the data to Documents etc.

Hi!
It’s more restore your system than just copy the personal data.
I have all personal data in other drive, so for me is restoring the system

Thanks for this. Looking into moving to manjaro + btrfs and that helped a lot