Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Kernel & Hardware
  • Search

How do I set a fallback root filesystem?

Kernel not recognizing your hardware? Problems with power management or PCMCIA? What hardware is compatible with Gentoo? See here. (Only for kernels supported by Gentoo.)
Post Reply
Advanced search
10 posts • Page 1 of 1
Author
Message
leyvi
l33t
l33t
Posts: 806
Joined: Fri Sep 08, 2023 1:22 pm

How do I set a fallback root filesystem?

  • Quote

Post by leyvi » Sat May 23, 2026 6:28 pm

I have full system backups that can be booted off of on a separate drive, in case my primary root filesystem has issues. How do I tell my system to try booting off of that if the primary root fails?
Top
zen_desu
Guru
Guru
Posts: 529
Joined: Fri Oct 25, 2024 3:14 pm
Location: your area

Re: How do I set a fallback root filesystem?

  • Quote

Post by zen_desu » Sat May 23, 2026 7:12 pm

the simplest way would be additional boot entries with a different root= arg

a more elegant system could possibly be added into an initramfs but it seems simpler to just have different boot entries for different cases.

if you were to use ugrd and force it to build in the "backup" root info, but the bootloader generally passes the "main" root info, it will failover using the built in info, but i don't think this is a reasonable scheme to generally use
µgRD dev
Wiki writer
Top
Hu
Administrator
Administrator
Posts: 24556
Joined: Tue Mar 06, 2007 5:38 am

Re: How do I set a fallback root filesystem?

  • Quote

Post by Hu » Sat May 23, 2026 8:57 pm

More generally, what does it mean that "the primary root fails"? Does that mean the primary root block device was not found, and so could not be mounted? Is it a failure if the root block device is found, but contains a filesystem that cannot be mounted? Is it a failure if the root filesystem mounts, but then init crashes, resulting in a kernel panic? What if init works fine, but critical programs from the boot runlevel are broken, causing the system to be effectively unusable? Some failure modes require considerably more state tracking than others to detect that a failure has happened and that a recovery is needed.
Top
leyvi
l33t
l33t
Posts: 806
Joined: Fri Sep 08, 2023 1:22 pm

Re: How do I set a fallback root filesystem?

  • Quote

Post by leyvi » Sat May 23, 2026 9:05 pm

zen_desu wrote: Sat May 23, 2026 7:12 pm the simplest way would be additional boot entries with a different root= arg

a more elegant system could possibly be added into an initramfs but it seems simpler to just have different boot entries for different cases.

if you were to use ugrd and force it to build in the "backup" root info, but the bootloader generally passes the "main" root info, it will failover using the built in info, but i don't think this is a reasonable scheme to generally use
Thanks. I don't know if that works so well in my use case though, which is EFIStub with LUKS.

I love µGRD by the way, I keep meaning to try and contribute, but I haven't gotten the chance.
Top
leyvi
l33t
l33t
Posts: 806
Joined: Fri Sep 08, 2023 1:22 pm

Re: How do I set a fallback root filesystem?

  • Quote

Post by leyvi » Sat May 23, 2026 9:25 pm

Hu wrote: Sat May 23, 2026 8:57 pm More generally, what does it mean that "the primary root fails"? Does that mean the primary root block device was not found, and so could not be mounted? Is it a failure if the root block device is found, but contains a filesystem that cannot be mounted? Is it a failure if the root filesystem mounts, but then init crashes, resulting in a kernel panic? What if init works fine, but critical programs from the boot runlevel are broken, causing the system to be effectively unusable? Some failure modes require considerably more state tracking than others to detect that a failure has happened and that a recovery is needed.
Basically any of the problems you've just named.

The reason I set up these backups is because I do a lot of unhinged tinkering with my software, which sometimes results in an unbootable machine, in which case a backup of the last functioning installation is nice to have. Some problems I have encountered include (but are not limited to):
  • /sbin/init is gone.
  • Messed-up PAM configuration.
All of these were my fault, and I'd rather not have to panic next time I mess with something I don't entirely understand and urgently need to use my computer.

You're right that this would require a lot of state tracking. Maybe EFI variables? The only problem with those is that they work different on every system, and if you mess something up, you may brick your motherboard.
Top
Hu
Administrator
Administrator
Posts: 24556
Joined: Tue Mar 06, 2007 5:38 am

Re: How do I set a fallback root filesystem?

  • Quote

Post by Hu » Sat May 23, 2026 10:02 pm

I called out the case of broken user programs because that is so hard to handle with a wrapper that can automatically recognize that the next boot needs to use fallback mode. Since you want to handle that case, my advice is to keep two bootloader entries for each working kernel, one with root=maindrive and one with root=backupdrive. Then the user can pick whichever is appropriate, based on whether the user (you) is aware that a prior boot failed badly.
Top
leyvi
l33t
l33t
Posts: 806
Joined: Fri Sep 08, 2023 1:22 pm

Re: How do I set a fallback root filesystem?

  • Quote

Post by leyvi » Sun May 24, 2026 10:18 am

Hu wrote: Sat May 23, 2026 10:02 pm I called out the case of broken user programs because that is so hard to handle with a wrapper that can automatically recognize that the next boot needs to use fallback mode. Since you want to handle that case, my advice is to keep two bootloader entries for each working kernel, one with root=maindrive and one with root=backupdrive. Then the user can pick whichever is appropriate, based on whether the user (you) is aware that a prior boot failed badly.
This could obviously be done with grub. Can it be done with efibootmgr? It doesn't seem to have as much configurability (obviously, it's not a full bootloader).

EDIT I
Obviously yes, with the kernel parameter. But I have my root(s) on LUKS, so it isn't so simple. I just let µGRD handle that stuff.
Top
Hu
Administrator
Administrator
Posts: 24556
Joined: Tue Mar 06, 2007 5:38 am

Re: How do I set a fallback root filesystem?

  • Quote

Post by Hu » Sun May 24, 2026 1:26 pm

If root=/dev/mapper/crypt-root is always used, then you need to vary which raw block device is passed to cryptsetup open.
Top
leyvi
l33t
l33t
Posts: 806
Joined: Fri Sep 08, 2023 1:22 pm

Re: How do I set a fallback root filesystem?

  • Quote

Post by leyvi » Tue Jun 02, 2026 1:49 pm

Found something interesting, check it out: https://wiki.archlinux.org/title/Truste ... _registers.

See registers 3, 4, 5, 13, and 23.
Top
leyvi
l33t
l33t
Posts: 806
Joined: Fri Sep 08, 2023 1:22 pm

Re: How do I set a fallback root filesystem?

  • Quote

Post by leyvi » Wed Jun 03, 2026 1:24 pm

Some of those registers are for general use. Some others keep track of recent boot attempts.
Top
Post Reply

10 posts • Page 1 of 1

Return to “Kernel & Hardware”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Authors
Gentoo is a trademark of the Gentoo Foundation, Inc. and of Förderverein Gentoo e.V.
The contents of this document, unless otherwise expressly stated, are licensed under the CC-BY-SA-4.0 license.
The Gentoo Name and Logo Usage Guidelines apply.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy