From 7293c739bec9e945019c1a065d1b8e8c08c5ed7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20H=2E=20Louzao=20P?= Date: Sun, 21 Nov 2021 12:43:49 +0100 Subject: [PATCH] Re-organize bootloading, LUKS file System and Root Account Locked fix: #401 #402 --- modules/ROOT/nav.adoc | 1 + ..._restoring-bootloader-using-live-disk.adoc | 114 ++++++++++++++---- modules/ROOT/pages/root-account-locked.adoc | 34 ++++++ 3 files changed, 124 insertions(+), 25 deletions(-) create mode 100644 modules/ROOT/pages/root-account-locked.adoc diff --git a/modules/ROOT/nav.adoc b/modules/ROOT/nav.adoc index d212d0d..d440eaa 100644 --- a/modules/ROOT/nav.adoc +++ b/modules/ROOT/nav.adoc @@ -38,6 +38,7 @@ ** xref:wine.adoc[Running Windows applications with Wine] ** xref:create-gpg-keys.adoc[Creating GPG Keys] ** xref:bootloading-with-grub2.adoc[Bootloading with GRUB2] +** xref:root-account-locked.adoc[Root Account Locked] ** xref:proc_setting-key-shortcut.adoc[Setting a key shortcut to run an application in GNOME] ** xref:disabling-automatic-screenlock.adoc[Disabling the GNOME automatic screen locking] ** xref:viewing-logs.adoc[Viewing logs in Fedora] diff --git a/modules/ROOT/pages/_partials/proc_restoring-bootloader-using-live-disk.adoc b/modules/ROOT/pages/_partials/proc_restoring-bootloader-using-live-disk.adoc index 1ec3e75..65cee20 100644 --- a/modules/ROOT/pages/_partials/proc_restoring-bootloader-using-live-disk.adoc +++ b/modules/ROOT/pages/_partials/proc_restoring-bootloader-using-live-disk.adoc @@ -25,7 +25,7 @@ bootable by *GRUB2*. . Examine the partition layout and identify the `boot` and the `root` partition. ---- -# fdisk -l +sudo fdisk -l ---- == For Default Instalation in LVM. @@ -33,7 +33,7 @@ bootable by *GRUB2*. . Create the mount point for the root partition. + ---- -# mkdir -p /mnt/root +mkdir -p /mnt/root ---- If you are using the default Fedora layout, there will be one `/dev/sda1` @@ -43,62 +43,126 @@ that holds the root file system. . Mount the root partition on the mount point. + ---- -# mount /dev/mapper/fedora-root /mnt/root +mount /dev/mapper/fedora-root /mnt/root ---- . Mount the boot partition in the `boot` directory of the filesystem that you have mounted in the previous step. ---- -# mount /dev/sda1 /mnt/root/boot/ +mount /dev/sda1 /mnt/root/boot/ +---- + +. Mount system processes and devices into the root filesystem in `/mnt/root`. ++ +---- +mount -o bind /dev /mnt/root/dev +mount -o bind /proc /mnt/root/proc +mount -o bind /sys /mnt/root/sys +mount -o bind /run /mnt/root/run +---- + +. Change your filesystem into the one mounted under `/mnt/root`. ++ + +---- +chroot /mnt/root ---- == For default Instalation in BTRF . Create the mount point for the root partition. - ++ ---- -# mkdir -p /mnt/ +mkdir -p /mnt/ ---- If you are using the default Fedora layout, there will be one `/dev/sda1` partition that holds the `/boot` directory and one `/dev/sda2` that holds the root file system. ---- -# mount /dev/sda2 /mnt -# mount /dev/sda1 /mnt/root/boot ----- - -IMPORTANT: Home Partition is mounted automatically under `/mnt/home` - -== Continue with the follow Procedure. - -. Mount system processes and devices into the root filesystem in -`/mnt/root`. -+ ----- -# mount -o bind /dev /mnt/root/dev -# mount -o bind /proc /mnt/root/proc -# mount -o bind /sys /mnt/root/sys -# mount -o bind /run /mnt/root/run +mount /dev/sda2 /mnt +mount /dev/sda1 /mnt/root/boot ---- . Change your filesystem into the one mounted under `/mnt/root`. + ---- -# chroot /mnt/root +chroot /mnt/root ---- +IMPORTANT: Home Partition is mounted automatically under `/mnt/home` + +== For Default Instalation in LUKS. + +. Make sure crypt module in use: ++ +---- +sudo modprobe dm-crypt +---- + +. Find out which drive it was with the following command: ++ +---- +sudo fdisk -l +---- + +You must mount `/dev/sda3 myvolume` + +. Use `cryptsetup`, device is accessible under `/dev/mapper/myvolume`` ++ +---- +sudo cryptsetup luksOpen /dev/sde3 myvolume +---- + +. Scan for LVM volumes and choose the right volume group name that you are looking for: ++ +---- +sudo vgscan +---- + +. If it is eg. Fedora, activate it ++ +---- +sudo vgchange -ay system +---- + +. Find out root volume ++ +---- +sudo lvs +---- + +. Mount it with the following command: ++ +---- +sudo mount /dev/system/root /mnt/ +---- + +. To work in the volume use the following commands ++ +---- +sudo mount --bind /dev /mnt/dev +sudo mount --bind /dev/pts /mnt/dev/pts +sudo mount --bind /proc /mnt/proc +sudo mount --bind /sys /mnt/sys +sudo chroot /mnt +---- + +IMPORTANT: consider mounting `/boot` also. + +== Continue with the follow Procedure. + . Regenerate the *GRUB2* configuration file and reinstall the bootloader into the MBR, as described in xref:adding-other-operating-systems-grub2[Adding other operating systems to the *GRUB2* menu]. . Exit this temporary root filesystem. + ---- -$ exit +exit ---- . Your bootloader should be now restored. Reboot your computer to boot into your normal system. ---- -# systemctl reboot +systemctl reboot ---- diff --git a/modules/ROOT/pages/root-account-locked.adoc b/modules/ROOT/pages/root-account-locked.adoc new file mode 100644 index 0000000..23d4ea0 --- /dev/null +++ b/modules/ROOT/pages/root-account-locked.adoc @@ -0,0 +1,34 @@ += Cannot open access to console, the root account is locked in emergency mode (dracut emergency shell) + +== Reason + +This is a known problem. It happens Fedora releases 28 and newer, which don’t require password for root account during +installation https://fedoraproject.org/wiki/Changes/ReduceInitialSetupRedundancy#Root_Account[Root Account] and use +first user added as `administrator/superuser`. In this case root account is locked, and if `/home` is inaccessible – then +the system can’t use superuser/administrator account either. + +== What to Do? + +If you find yourself in this situation and you can’t resolve problem with `/home` mounting from Live disk/USB, +and you need access to emergency mode, the solution is simple. + +. Boot into Live disk/usb and chroot into your Fedora installations as documented in this https://docs.fedoraproject.org/en-US/quick-docs/bootloading-with-grub2/#restoring-bootloader-using-live-disk[Fedora Quick-docs Article] +- following steps depends of your File System `LVM/BTRF/LUKS`. + +. Unlock root account by supplying password for it: ++ +---- +passwd root +---- + +. Exit chroot environment with [Ctrl-d] or ++ +---- +exit +---- + +. Reboot your computer with GUI or with ++ +---- +systemctl reboot +----