Fedora 40 - Failed to mount sysroot.mount on a LUKS-encrypted partition

Specs:

  • Fedora 40
  • BTRFS file system with LUKS encryption
  • Installed on an internal M.2 NVME drive

Problem
My Fedora installation boots into emergency mode due to an issue with reading a superblock on my drive, preventing sysroot.mount from being mounted. From journalctl and dmesg, I found the following (provided in picture form):

I attempted to access the LUKS-encrypted BTRFS partition from a LiveCD version of Fedora, but I could not. I may not have been doing it right though as I am an inexperienced user. Is there any way to fix it or at least recover the data? This has been my main partition since October of last year and I have lots of data that I cannot afford to lose on it.

Cause

I was attempting to build an application from its source code when my system crashed. To try again, I force-restarted my system to find it stuck in emergency mode.

umount the file system, and retry mounting it with options ro,rescue=usebackuproot,nologreplay e.g.

# mount -o ro,rescue=usebackuproot,nologreplay /dev/mapper/luks- /mnt

You will need to complete the dev mapper path to the block device. If this mount fails, post the last lines from dmesg or even dmesg | grep -i btrfs is OK.

If it works, I suggest refreshing backups now while it’s possible. Anything important. Next, umount the file system and mount with rescue=usebackuproot, e.g.

# mount -o rescue=usebackuproot /dev/mapper/luks- /mnt

If the mount works without error, try rebooting and see if it’s really fixed. If it doesn’t work, post the last lines of dmesg so we can see the btrfs errors. And also then do:

btrfs check --readonly /dev/mapper/luks- filling in the rest of the dev mapper path to the block device.