Fedora 27(Btrfs分区SSD)无法启动,求助解决启动报错问题
Hey there, let's work through this frustrating boot issue with your Fedora 27 and Btrfs setup—you've got two main hurdles here: a corrupted Btrfs filesystem and a locked root account blocking rescue mode access. Let's tackle them one by one.
The "root account is locked" error is stopping you from getting into the rescue console, so we'll use a GRUB trick to gain access and reset the root password:
- When the GRUB menu pops up, select the rescue mode entry and press
eto edit its boot parameters. - Look for the line starting with
linux(it'll have a bunch of kernel options). At the very end of this line, addrd.break. - Press
Ctrl+Xto boot with this modified configuration. You'll drop into an emergency shell where the root filesystem is mounted read-only at/sysroot. - Remount it as read-write to make changes:
mount -o remount,rw /sysroot - Switch to the actual root environment:
chroot /sysroot - Now reset the root password (follow the prompts to enter and confirm a new one):
passwd root - Exit the chroot environment:
exit - Remount the filesystem back to read-only:
mount -o remount,ro /sysroot - Finally, start the normal init process to enter rescue mode:
exec /sbin/init
You should now have access to the rescue console without the lock error.
Now that you're in rescue mode, let's fix the Btrfs issues you're seeing (bad tree blocks, orphan entries, pending checksums):
- First, identify your Btrfs root partition. Run
blkidto list all partitions—look for the one withTYPE="btrfs"(it's usually something like/dev/mapper/fedora-rootor/dev/sda3). - Unmount the partition if it's already mounted (rescue mode might mount it automatically, so check with
mountfirst):umount /dev/your-btrfs-partition - Run a read-only check first to assess the damage (this won't modify your data):
This will confirm the bad tree blocks and other issues you saw earlier.btrfs check --readonly /dev/your-btrfs-partition - If the read-only check confirms corruption, run the repair tool. Warning: This will modify your filesystem—if you can, back up any critical data first (e.g., by connecting the SSD to another computer or using a Live USB to mount it read-only).
This command will fix orphan entries, repair bad tree blocks, and resolve the pending checksum issues.btrfs check --repair /dev/your-btrfs-partition - After repair, test mounting the partition to make sure it works:
You can navigate tomount /dev/your-btrfs-partition /mnt/mntand check if your files are accessible.
Once the filesystem is repaired, let's make sure your system can boot properly:
- If you're still in the chroot environment (from Step 1), regenerate the initramfs to ensure all filesystem drivers are up to date:
dracut -f - Update your GRUB configuration to make sure it points to the correct partition:
- For BIOS systems:
grub2-mkconfig -o /boot/grub2/grub.cfg - For UEFI systems:
grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg
- For BIOS systems:
- Exit rescue mode and reboot your laptop. Try booting with your default kernel entry—this should work now if the repair was successful.
- The
btrfs check --repaircommand is a last resort—always prioritize backing up data before running it if possible. - If you keep seeing filesystem corruption after repair, it might be a sign of SSD hardware failure. Run a SMART check to verify:
smartctl -a /dev/sda - Fedora 27 reached end-of-life years ago, so it doesn't receive security updates or bug fixes. Once you get your system up and running, consider upgrading to a supported version of Fedora for better stability.
内容的提问来源于stack exchange,提问作者horizonbrave

