Note: using encrypted btrfs root partition done during installation from anaconda installer, using nvidia card, uefi system.
I recently ran into trouble with fedora linux on my laptop (nvidia) after following this guide:
https:/asus-linux.org/wiki/fedora-guide/
This basically installed a custom asus kernel and a rpm package to control keyboard lights. My system quickly became very unstable and I removed the rpm package by dnf erase command and did same for the custom kernel.
I was able to boot into the older kernel.
I later messed up my grub file while reverting the changes that I made while following the above guide.
I realised that when I got errors while updating grub after editing it.
My system became unbootable.
So I successfully chrooted with a live usb and reconfigured the grub properly as per the guide.
So far so good , everything went smooth, with grub now corrected, I expected to reboot properly, but I now got into grub command line (without rescue)
This was predicted in the above guide at the end of it.
I have no idea how to boot from encrypted btrfs partition from grub.
Please help me.
I did ls in the grub output:
(proc) β donβt know what it is. Contains luks_script
(hd0) β nvme SSD disk where fedora is installed
(hd0,gpt1) β fat boot partition efi grub folders inside it
(hd0,gpt2) β has vmlinuz and intramfs for various kernel versions.
(hd0, gpt3) β encrypted btrfs partition
How do I boot fedora from grub command line, I have a btrfs encrypted root partition and uefi system and nvidia card. A permanent solution would be great but a temporary one will be helpful too. Let me know if any further details are needed
I just ran a fresh install of Fedora 34 with the Workstation iso + UEFI + btrfs + luks.
Youβll probably be able to see what config youβll need specific to your system using cat in the grub shell and some tab complete.
ls (hd0,gpt2)/loader/entries/
cat (hd0,gpt2)/loader/entries/ (tab complete here to pick one of your configs)
In there will be your root=UUID=, rootflags=subvol= and rd.luks.uuid= options which would/could be unique to your system.
Hereβs the grub boot commands for mine and you can adapt them to your system.
load_video
set gfxpayload=keep
insmod gzio
linux (hd0,gpt2)/vmlinuz-5... root=UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx ro rootflags=subvol=root rd.luks.uuid=luks-yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy quiet
initrd (hd0,gpt2)/initramfs-5...
For those β¦, use tab complete to finish the filenames for the kernel version you want to use. Iβd pick the newest one you know works.
If you canβt find the rd.luks.uuid (or just donβt want to type it), it might be saved in the initramfs imageβs /etc/crypttab so it will figure it out anyways though not with the rescue initramfs.
It works,
I followed the instructions step-by-step and was able to login and use my desktop. I clicked on the shut down button, the screen went black. With a blinking underscore, I waited but nothing was happening. So I forcefully powered my laptop off. Rebooting it again landed me back to the grub command line.
Do I need to do this everytime I login or was the fix supposed to be permanent?
After initrd the last command I typed boot.
Also I am unable to see fedora splash screen for entering password, instead I see it in the generic way without any splash screen with the fedora logo.
Update: I again tried it, I followed the instructions and logged in to my desktop. This time I reinstalled the kernel and nvidia drivers using dnf reinstall. Then I powered my laptop off. This time it took 3-4 minutes for it to power off properly(2 minutes timeout for user session manager).
But again on powering on, still back at grub
Tldr:
Your method works but itβs not permanent, it has to be followed every time I power on my laptop, this is inconvenient. Can you suggest me a way to make these changes permanent? Do I need to modify grub file in /etc/default/grub and make any changes?? Please let me know.
So this was just a temporary fix as youβve discovered. I suspect youβll need to reinstall grub2 again with the efi step from your link:
dnf reinstall grub2-efi grub2-efi-modules shim
I havenβt done this myself yet.
As for the splash screen, thatβs because I omitted rhgb from the end of the linux line. As long as itβs in your /etc/defaults/grub, it will end up in your config once fixed so youβll have the normal graphics luks prompt.
Iβll give this all a try in my VM to see how it goes.
You might have additional customizations on that GRUB_CMDLINE_LINUX your system needs. grub2-mkconfig and grubby will reference that when generating configs.
[root@fedora boot]# cat /boot/grub2/grub.cfg
#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub2-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#
### BEGIN /etc/grub.d/00_header ###
set pager=1
if [ -f ${config_directory}/grubenv ]; then
load_env -f ${config_directory}/grubenv
elif [ -s $prefix/grubenv ]; then
load_env
fi
if [ "${next_entry}" ] ; then
set default="${next_entry}"
set next_entry=
save_env next_entry
set boot_once=true
else
set default="${saved_entry}"
fi
if [ x"${feature_menuentry_id}" = xy ]; then
menuentry_id_option="--id"
else
menuentry_id_option=""
fi
export menuentry_id_option
if [ "${prev_saved_entry}" ]; then
set saved_entry="${prev_saved_entry}"
save_env saved_entry
set prev_saved_entry=
save_env prev_saved_entry
set boot_once=true
fi
function savedefault {
if [ -z "${boot_once}" ]; then
saved_entry="${chosen}"
save_env saved_entry
fi
}
function load_video {
if [ x$feature_all_video_module = xy ]; then
insmod all_video
else
insmod efi_gop
insmod efi_uga
insmod ieee1275_fb
insmod vbe
insmod vga
insmod video_bochs
insmod video_cirrus
fi
}
terminal_output console
if [ x$feature_timeout_style = xy ] ; then
set timeout_style=menu
set timeout=35
# Fallback normal timeout code in case the timeout_style feature is
# unavailable.
else
set timeout=35
fi
### END /etc/grub.d/00_header ###
### BEGIN /etc/grub.d/01_users ###
if [ -f ${prefix}/user.cfg ]; then
source ${prefix}/user.cfg
if [ -n "${GRUB2_PASSWORD}" ]; then
set superusers="root"
export superusers
password_pbkdf2 root ${GRUB2_PASSWORD}
fi
fi
### END /etc/grub.d/01_users ###
### BEGIN /etc/grub.d/08_fallback_counting ###
insmod increment
# Check if boot_counter exists and boot_success=0 to activate this behaviour.
if [ -n "${boot_counter}" -a "${boot_success}" = "0" ]; then
# if countdown has ended, choose to boot rollback deployment,
# i.e. default=1 on OSTree-based systems.
if [ "${boot_counter}" = "0" -o "${boot_counter}" = "-1" ]; then
set default=1
set boot_counter=-1
# otherwise decrement boot_counter
else
decrement boot_counter
fi
save_env boot_counter
fi
### END /etc/grub.d/08_fallback_counting ###
### BEGIN /etc/grub.d/10_linux ###
insmod part_gpt
insmod ext2
search --no-floppy --fs-uuid --set=root 56d708e0-a930-4e95-bdf4-87f57e8639b3
insmod part_gpt
insmod fat
search --no-floppy --fs-uuid --set=boot 52AA-D46F
# This section was generated by a script. Do not modify the generated file - all changes
# will be lost the next time file is regenerated. Instead edit the BootLoaderSpec files.
#
# The blscfg command parses the BootLoaderSpec files stored in /boot/loader/entries and
# populates the boot menu. Please refer to the Boot Loader Specification documentation
# for the files format: https://www.freedesktop.org/wiki/Specifications/BootLoaderSpec/.
# The kernelopts variable should be defined in the grubenv file. But to ensure that menu
# entries populated from BootLoaderSpec files that use this variable work correctly even
# without a grubenv file, define a fallback kernelopts variable if this has not been set.
#
# The kernelopts variable in the grubenv file can be modified using the grubby tool or by
# executing the grub2-mkconfig tool. For the latter, the values of the GRUB_CMDLINE_LINUX
# and GRUB_CMDLINE_LINUX_DEFAULT options from /etc/default/grub file are used to set both
# the kernelopts variable in the grubenv file and the fallback kernelopts variable.
if [ -z "${kernelopts}" ]; then
set kernelopts="root=UUID=c522780f-98a9-4378-a529-962710c0fc21 ro rootflags=subvol=root rd.luks.uuid=luks-64edc611-fbc0-436f-9524-43bfcc64be14 rhgb quiet "
fi
insmod blscfg
blscfg
### END /etc/grub.d/10_linux ###
### BEGIN /etc/grub.d/10_reset_boot_success ###
# Hiding the menu is ok if last boot was ok or if this is a first boot attempt to boot the entry
if [ "${boot_success}" = "1" -o "${boot_indeterminate}" = "1" ]; then
set menu_hide_ok=1
else
set menu_hide_ok=0
fi
# Reset boot_indeterminate after a successful boot
if [ "${boot_success}" = "1" ] ; then
set boot_indeterminate=0
# Avoid boot_indeterminate causing the menu to be hidden more then once
elif [ "${boot_indeterminate}" = "1" ]; then
set boot_indeterminate=2
fi
# Reset boot_success for current boot
set boot_success=0
save_env boot_success boot_indeterminate
### END /etc/grub.d/10_reset_boot_success ###
### BEGIN /etc/grub.d/12_menu_auto_hide ###
if [ x$feature_timeout_style = xy ] ; then
if [ "${menu_show_once}" ]; then
unset menu_show_once
save_env menu_show_once
set timeout_style=menu
set timeout=60
elif [ "${menu_auto_hide}" -a "${menu_hide_ok}" = "1" ]; then
set orig_timeout_style=${timeout_style}
set orig_timeout=${timeout}
if [ "${fastboot}" = "1" ]; then
# timeout_style=menu + timeout=0 avoids the countdown code keypress check
set timeout_style=menu
set timeout=0
else
set timeout_style=hidden
set timeout=1
fi
fi
fi
### END /etc/grub.d/12_menu_auto_hide ###
### BEGIN /etc/grub.d/14_menu_show_once ###
if [ x$feature_timeout_style = xy ]; then
if [ "${menu_show_once_timeout}" ]; then
set timeout_style=menu
set timeout="${menu_show_once_timeout}"
unset menu_show_once_timeout
save_env menu_show_once_timeout
fi
fi
### END /etc/grub.d/14_menu_show_once ###
### BEGIN /etc/grub.d/20_linux_xen ###
### END /etc/grub.d/20_linux_xen ###
### BEGIN /etc/grub.d/20_ppc_terminfo ###
### END /etc/grub.d/20_ppc_terminfo ###
### BEGIN /etc/grub.d/30_os-prober ###
### END /etc/grub.d/30_os-prober ###
### BEGIN /etc/grub.d/30_uefi-firmware ###
menuentry 'UEFI Firmware Settings' $menuentry_id_option 'uefi-firmware' {
fwsetup
}
### END /etc/grub.d/30_uefi-firmware ###
### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
### END /etc/grub.d/40_custom ###
### BEGIN /etc/grub.d/41_custom ###
if [ -f ${config_directory}/custom.cfg ]; then
source ${config_directory}/custom.cfg
elif [ -z "${config_directory}" -a -f $prefix/custom.cfg ]; then
source $prefix/custom.cfg
fi
### END /etc/grub.d/41_custom ###
[root@fedora boot]#
Great explanation, well done. I followed the instructions step-by-step as you said. After rebooting I still land on grub. Do I need to change my boot options in bios?
While doing what you said, I guess I realised I did the same thing as chroot as stated in my first post.
I followed this guide
This was what I did to fix my grub, after this I landed in grub after booting.
If you take a close look at this article, it says the problem I am facing was expected, it also provides a solution to this(my) problem. Unfortunately I was not able to understand the solution.
Here is the link
In case if time permits, I suggest you to read through this article completely. It might help us to get to the solution.
First off (or it was first of all before I noticed the loader things), hereβs some of my assumptions:
I donβt think thereβs a problem with you systemβs EFI boot select because itβs able to run grub.
I expect you only have one copy of grub2 installed.
I think grub canβt find its config file, or the config file isnβt correct.
Probably not then thoughβ¦ I didnβt realize thereβs two grub.cfgβs in a default build.
Hereβs my directory structure from /boot/.
And I donβt think it matters (but not 100%) that yours is ./EFI vs mineβs with /.efi because that should be a vfat filesystem thatβs case-insensitiveβ¦ but depends on how grub feels about it. Presumably it used to work that way.
That shows me it just loads the other one. Iβd suggest making sure your search lineβs uuid matches the /boot partition with the kernels. In my VMβs case /dev/vda2.
I am so sorry, i just realized that my tree output was done as a non root user,
i just logged into my pc and found this out. those .conf files in loader directory cannot be listed by a non root user. here is a proper tree output as a root-
Maybe this screenshot also helps, I want to clarify that I see few conf files in entries directory(from grub).
Here is Ls of entries directory, cat of one of the conf files(latest kernel version)