Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add emerg-automount module for autodetecting and mounting a root device in emergency mode #694

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ArrayBolt3
Copy link

dracut is currently only able to find and mount the root device if it is told exactly where to look. If something happens to the system that causes disk identification info to change (for instance cloning a partition and forgetting to change the root UUID specified on the kernel command line), it's possible for dracut to be unable to locate the root filesystem. In this instance the user is dropped unceremoniously into an emergency shell, where they are left to "figure out" how to mount the root filesystem on their own. Depending on the skill level of the user, this may be impossible.

This pull request makes it much easier for a new user to get their system to boot after being dropped into an emergency shell. It adds a new dracut module, 95emerg-automount, that automates the process of finding and mounting a root filesystem "in the dark" (i.e. without prior info about which filesystem to mount or where it is located). Roughly speaking, the algorithm used is:

  • Find all available disk partitions.
  • For each partition, mount it, and see if it looks like a usable root filesystem.
  • Present a list of all usable-looking root filesystems to the user, along with what OS they appear to contain.
  • Allow the user to choose which of these to boot.
  • Mount the chosen filesystem to /sysroot and instruct the user to exit the emergency shell.

This script is NOT run automatically when the emergency shell is entered, as mounting arbitrary partitions comes with security risks and just blindly mounting everything to check it was not considered an acceptable solution. Instead, a small emergency hook is added that informs the user they can try to automount the root partition if they want to by running automount.sh. If they don't want to, they don't have to.

In the event a user has multiple operating systems installed on the same system, it can be difficult to determine which one is the correct one to boot. In order to make things easier, the module's installation routine copies /etc/os-release from the root filesystem into the initramfs. This allows the automounter to determine which OS release the user is trying to boot. The automounter can then compare this OS release info with the OS release info from each partition it scans for usability. If it finds a match, it knows the user probably wants to boot that OS, in which case it will show that partition to the user with a "this is probably what you want to boot" message, and will automatically attempt to boot it if the user doesn't choose the OS to boot (i.e. they just hit Enter when asked what to do).

TODOs

  • There's a mechanism for detecting which root filesystem is most likely to be the one the user wants to boot, but it seems to be being foiled by some part of dracut messing with the /etc/os-release file that module-setup.sh gets to see. Probably using rather than a Dracut install command will fix this.
  • All operating systems with a matching OS release will be seen as "this is probably what you want to boot" and they will all be shown with this messaging. This could be confusing, so it may be better to only mark the first "probably correct" OS and always attempt to boot it if the user fails to choose which OS to try booting.
  • Needs a LOT more testing with various different filesystems, partitioning setups, multiboot configurations, and distros.

Changes

  • Add a new dracut module, 95emerg-automount, with the features listed above.

Checklist

  • I have tested it locally
    • Note: I have only tested it on Fedora 40, and have not tested all codepaths. It needs more rigorous testing. this is being pushed out "early" to get feedback sooner rather than later.
  • I have reviewed and updated any documentation if relevant
  • I am providing new code and test(s) for it

Fixes dracutdevs/dracut#2589.

@ArrayBolt3 ArrayBolt3 requested a review from a team as a code owner October 2, 2024 04:55
@github-actions github-actions bot added the modules Issue tracker for all modules label Oct 2, 2024
@ArrayBolt3 ArrayBolt3 marked this pull request as draft October 2, 2024 23:40
@ArrayBolt3
Copy link
Author

Sadly this seems to not work as intended on Debian. While it is able to mount the root filesystem to the proper location, it appears that dracut-initqueue is dead-set on finding the requested root device even though there's a usable filesystem mounted to /sysroot. Getting this to be useful on more than Fedora will take some more work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
modules Issue tracker for all modules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

auto-detect, prompt for potential root devices in case the root= device is misconfigured or missing
1 participant