You are not logged in.

#1 2025-08-04 20:40:57

dratos97391
Member
Registered: 2016-08-04
Posts: 55

[SOLVED] Restore borked btrfs drive from snapshot

Hi,

I want to restore my / and /home partition from a snapper snapshot

# crontab -l
3 * * * * snap-sync --UUID 49129cfd-81e8-415c-86c0-922831bab720 --subvolid 5 --noconfirm

But I am unsure of the exact steps to do it and still get a running arch system.




<<<<Background>>>>

I bought a new laptop but started getting some btrfs errors:

dmesg:

[  536.480936] BTRFS warning (device sdb2): checksum verify failed on logical 144785408 mirror 1 wanted 0xeacc3b04 found 0x37e3adde level 0
[  536.481048] BTRFS error (device sdb2): parent transid verify failed on logical 144785408 mirror 2 wanted 9504 found 7786
[  536.481148] BTRFS warning (device sdb2): checksum verify failed on logical 144785408 mirror 1 wanted 0xeacc3b04 found 0x37e3adde level 0
[  536.481237] BTRFS error (device sdb2): parent transid verify failed on logical 144785408 mirror 2 wanted 9504 found 7786
[  541.730202] BTRFS warning (device sdb2): checksum verify failed on logical 144785408 mirror 1 wanted 0xeacc3b04 found 0x37e3adde level 0
[  541.730495] BTRFS error (device sdb2): parent transid verify failed on logical 144785408 mirror 2 wanted 9504 found 7786
[  541.730613] BTRFS warning (device sdb2): checksum verify failed on logical 144785408 mirror 1 wanted 0xeacc3b04 found 0x37e3adde level 0
[  541.730715] BTRFS error (device sdb2): parent transid verify failed on logical 144785408 mirror 2 wanted 9504 found 7786
[  541.730844] BTRFS warning (device sdb2): checksum verify failed on logical 144785408 mirror 1 wanted 0xeacc3b04 found 0x37e3adde level 0
[  541.731003] BTRFS error (device sdb2): parent transid verify failed on logical 144785408 mirror 2 wanted 9504 found 7786
[  545.243722] BTRFS warning (device sdb2): checksum verify failed on logical 144785408 mirror 1 wanted 0xeacc3b04 found 0x37e3adde level 0
[  545.243826] BTRFS error (device sdb2): parent transid verify failed on logical 144785408 mirror 2 wanted 9504 found 7786
[  545.243846] BTRFS error (device sdb2 state A): Transaction aborted (error -5)
[  545.243851] BTRFS: error (device sdb2 state A) in do_free_extent_accounting:2960: errno=-5 IO failure
[  545.243875] BTRFS info (device sdb2 state EA): forced readonly
[  545.243878] BTRFS error (device sdb2 state EA): failed to run delayed ref for logical 6652563456 num_bytes 4096 type 184 action 2 ref_mod 1: -5
[  545.243882] BTRFS: error (device sdb2 state EA) in btrfs_run_delayed_refs:2160: errno=-5 IO failure
[  545.254371] systemd-journald[339]: /var/log/journal/4e8071ae802142b8893422e18256fefc/system.journal: Journal file corrupted, rotating.
[  545.254394] systemd-journald[339]: Failed to rotate /var/log/journal/4e8071ae802142b8893422e18256fefc/system.journal: Read-only file system

The system usually enters read only mode a while after booting, but I can boot.

btrfs check gives me:
http://0x0.st/8hZi.txt


So what I did was to run memtest and saw that I got FAIL pretty quickly on my memory, and I got new sticks of RAM. Now I tested the new ram and it seems okay, but the / and home volume (sda2) still have the same issues, it could probably be corrupted metadata that was written to disk. I also did a SMART check and it all checks out nicely:

http://0x0.st/8hZ-.txt


fdisk info:

Disk /dev/sdb: 238,47 GiB, 256060514304 bytes, 500118192 sectors
Disk model: LITEONIT LMT-256
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 4E57B3AC-BFD4-4EE9-9CE1-21E05B20B290

Device       Start       End   Sectors  Size Type
/dev/sdb1     2048   1050623   1048576  512M EFI System
/dev/sdb2  1050624 500117503 499066880  238G Linux filesystem

So the question is:

How do I restore / since I got snapshots with snapper and snap-sync?
My plan is to boot from an usb-stick, and somehow restore from my second hdd that got some backups of the snapshots, but Im unsure if a mere file-copy of @ and @home will restore everything to its previous state or if I should perform some steps before I format the drive?

Note snapper undochange does not work since I get the dmesg errors mentioned above.

Last edited by dratos97391 (2025-08-05 11:50:03)

Offline

#2 2025-08-05 07:41:47

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 69,144

Re: [SOLVED] Restore borked btrfs drive from snapshot

How do I restore / since I got snapshots with snapper and snap-sync?
My plan is to boot from an usb-stick, and somehow restore from my second hdd that got some backups of the snapshots, but Im unsure if a mere file-copy of @ and @home will restore everything to its previous state or if I should perform some steps before I format the drive?

https://wiki.archlinux.org/title/Snappe … e_snapshot but I'd caution to maybe not mess around w/ the snapshots as long as the FS itself is in an inconsistent state.
Have a backup of the disk (seriously) and escalate https://man.archlinux.org/man/btrfs-scrub.8.en , https://man.archlinux.org/man/btrfs-check.8.en and https://man.archlinux.org/man/btrfs-rescue.8.en to sanitize the filesystem.
Then re-evaluate the need to restore a snapshot.

Offline

#3 2025-08-05 11:52:11

dratos97391
Member
Registered: 2016-08-04
Posts: 55

Re: [SOLVED] Restore borked btrfs drive from snapshot

Thanks Seth, pleasure to get some solid advice as always.


Only a reformat helped.

Good things to keep in mind for next time:
1. efi/boot partition does not need to be reformatted since its separate
2. use rsync to keep permissions
3. fdisk is not needed, just a format not a whole re-partition, if using fdisk be aware of changing UUIDs in grub.cfg and fstab

Offline

Board footer

Powered by FluxBB