Improper shutdown and ejection of Linux drive, results in "sysroot.mount loaded failed failed /sysroot"

Specs:

  • F37 / G43
  • BTRFS filesystem
  • Installed on a M.2 NVMe drive, plugged in via USB 3.0 cable

Problem

After an improper shutdown and ejection of my Linux drive, my Linux drive only boots to emergency mode. I have the following errors in dmesg, journalctl, and systemctl.

systemctl:

`sysroot.mount loaded failed failed /sysroot`

dmesg and journalctl:

BTRFS: error (device sda3: state EA): open_ctree failed

BTRFS: error (device sda3: state A) in __btrfs_run_delayed_items:1153: errono=-17 Object already exists

BTRFS: error (device sda3: state EA) in cleanup_transaction:1958: errno=-17 Object already exists

BTRFS: error (device sda3: state EA) in btrfs_replay_log:2395: errno=-17 Object already exists (Failed to recover log tree)

Failed to mount sysroot.mount - /sysroot.

When I use an external live boot and try to mount the external Linux drive with:

mount /dev/sda3 /mnt

I get the following error:

mount(2) system call failed: File Exists

Cause

I use Linux in a M.2 external drive, and I accidentally unplugged my external M.2 drive while Linux was running sudo dnf upgrade -y && flatpak upgrade -y. After the accidentally unplugging, I decided to hold down the power button as the system was hanging for several minutes; I thought it was stuck and needed a hard reset.

Upon booting the system back up, and booting to the latest kernel 6.1.9, I was met with emergency mode. I ran journalctl, dmesg, and systemctl, and received the aforementioned findings. This was the result of an improper shutdown during dnf upgrade.

I have BTRFS snapshots, but I’m unable to mount the root and home directories: /dev/sda3 due to:

mount(2) system call failed: File Exists

Solution

This would not be correct for mounting a btrfs file system. The user needs to mount a file system partition subvolume and not the device.
If you use lsblk -f it should show you the device of interest with the partitions & UUIDs so you can tell exactly what to mount.

Note that a btrfs file system will, by default in fedora, have subvolumes ‘root’ and ‘home’ that are mounted at ‘/’ and ‘/home’ respectfully.

You probably need to give the mount command the proper file system type and options to mount a btrfs subvolume. In my /etc/fstab I see the options as subvol=root,compress=zstd:1 for the partition mounted at /, and it uses the UUID instead of the partition name. This means the mount command should look something like
mount -t btrfs -o subvol=root,compress=zstd:1 UUID=XXXX /mnt when trying to mount the root file system of the device of interest on /mnt.

I found the solution!

Try running this from live boot to see if it reports any errors:

btrfs check -p --readonly /dev/sda3

If nothing else you can discard the log and lose any writes that were still in flight when the drive was pulled, but it should at least get you back up:

btrfs rescue zero-log /dev/sda3

From:
https://www.reddit.com/r/Fedora/comments/10xmcp1/comment/j7w90wd/?utm_source=share&utm_medium=web2x&context=3

1 Like