Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save slmingol/a8290c64af664746b14be948e9d7e45a to your computer and use it in GitHub Desktop.

Select an option

Save slmingol/a8290c64af664746b14be948e9d7e45a to your computer and use it in GitHub Desktop.

Revisions

  1. @tobikris tobikris revised this gist Feb 18, 2022. 1 changed file with 6 additions and 3 deletions.
    9 changes: 6 additions & 3 deletions repair-dualboot-bootloader.sh
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,8 @@
    $ # Use Live CD to boot
    $ sudo su # Switch to root
    $ fdisk -l # Get names of root, boot & EFI partition names. you can also use blkid

    $ # http://dadadom.de/2020/04/11/fix-fedora-uefi-boot-with-encrypted-partitions/
    $ udiskctl unlock -b /dev/nvme0n1p6 # unlock root luks partition
    $ mount /dev/mapper/fedora_fedora-root /mnt # mount root partition
    $ mount /dev/mapper/fedora_fedora-var /mnt/var
    @@ -20,9 +22,10 @@ $ for dir in /dev /proc /sys /run /var/run; do mount --bind $dir /mnt/$dir ; don
    $ # enter chroot
    $ chroot /mnt

    $ # Now you can do all the work e.g. fix grub
    $ dnf reinstall grub2-efi shim -y
    $ grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg # Regenerate grub2
    $ # https://fedoraproject.org/wiki/GRUB_2#Instructions_for_UEFI-based_systems
    $ rm /boot/efi/EFI/fedora/grub.cfg
    $ rm /boot/grub2/grub.cfg
    $ dnf reinstall shim-* grub2-efi-* grub2-common

    $ # All things done; now exit from chroot
    $ exit
  2. @tobikris tobikris renamed this gist Feb 18, 2022. 1 changed file with 7 additions and 7 deletions.
    14 changes: 7 additions & 7 deletions set-chroot.sh → repair-dualboot-bootloader.sh
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,11 @@
    $ # Use Live CD to boot
    $ sudo su # Switch to root
    $ fdisk -l # Get names of root, boot & EFI partition names. you can also use blkid
    $ mount /dev/mapper/fedora_localhost--live-root /mnt # mount root partition
    $ cat /mnt/etc/fedora-release
    Fedora release 31 (Thirty One)
    $ mount /dev/nvme0n1p2 /mnt/boot # mount boot partition
    $ udiskctl unlock -b /dev/nvme0n1p6 # unlock root luks partition
    $ mount /dev/mapper/fedora_fedora-root /mnt # mount root partition
    $ mount /dev/mapper/fedora_fedora-var /mnt/var

    $ mount /dev/nvme0n1p5 /mnt/boot # mount boot partition
    $ mount /dev/nvme0n1p1 /mnt/boot/efi # mount EFI partition
    # Note: If you are not able to mount EFI partition ('Input/Output error'),
    # You may have to repair ESP file system or format ESP.
    @@ -14,7 +15,7 @@ $ mount /dev/nvme0n1p1 /mnt/boot/efi # mount EFI partition
    $ ls /mnt/boot/efi # should show all OS names under EFI

    $ # mount the virtual filesystems that the system uses to communicate with processes and devices
    $ for dir in /dev /proc /sys /run; do mount --bind $dir /mnt/$dir ; done
    $ for dir in /dev /proc /sys /run /var/run; do mount --bind $dir /mnt/$dir ; done

    $ # enter chroot
    $ chroot /mnt
    @@ -23,6 +24,7 @@ $ # Now you can do all the work e.g. fix grub
    $ dnf reinstall grub2-efi shim -y
    $ grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg # Regenerate grub2

    $ # All things done; now exit from chroot
    $ exit

    $ # Check BIOS boot details
    @@ -34,6 +36,4 @@ $ cp -p /boot/efi/EFI/grubx64.efi /mnt/boot/efi/EFI/fedora

    # Check /etc/fstab UUID, update if necessary

    $ # All things done; now exit from chroot
    $ exit
    $ # Now you can reboot
  3. @Tamal Tamal revised this gist Apr 15, 2021. 1 changed file with 14 additions and 1 deletion.
    15 changes: 14 additions & 1 deletion set-chroot.sh
    Original file line number Diff line number Diff line change
    @@ -6,6 +6,11 @@ $ cat /mnt/etc/fedora-release
    Fedora release 31 (Thirty One)
    $ mount /dev/nvme0n1p2 /mnt/boot # mount boot partition
    $ mount /dev/nvme0n1p1 /mnt/boot/efi # mount EFI partition
    # Note: If you are not able to mount EFI partition ('Input/Output error'),
    # You may have to repair ESP file system or format ESP.
    # fsck.vfat /dev/nvme0n1p1
    # mkfs.vfat /dev/nvme0n1p1
    # If formatted then we may have to update UUID at /etc/fstab
    $ ls /mnt/boot/efi # should show all OS names under EFI

    $ # mount the virtual filesystems that the system uses to communicate with processes and devices
    @@ -18,8 +23,16 @@ $ # Now you can do all the work e.g. fix grub
    $ dnf reinstall grub2-efi shim -y
    $ grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg # Regenerate grub2

    $ exit

    $ # Check BIOS boot details
    $ efibootmgr -v
    $ # In case you need to create new entry in BIOS
    $ efibootmgr -c -d /dev/nvme0n1p1 -p 1 -L Fedora -l '\EFI\fedora\grubx64.efi'
    $ efibootmgr -c -d /dev/nvme0n1p1 -p 1 -L Fedora -l '\EFI\fedora\grubx64.efi' # or, shimx64.efi
    $ # Copy grubx64.efi from Live USB, if required
    $ cp -p /boot/efi/EFI/grubx64.efi /mnt/boot/efi/EFI/fedora

    # Check /etc/fstab UUID, update if necessary

    $ # All things done; now exit from chroot
    $ exit
  4. @Tamal Tamal revised this gist Apr 29, 2020. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions set-chroot.sh
    Original file line number Diff line number Diff line change
    @@ -18,6 +18,9 @@ $ # Now you can do all the work e.g. fix grub
    $ dnf reinstall grub2-efi shim -y
    $ grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg # Regenerate grub2

    $ # In case you need to create new entry in BIOS
    $ efibootmgr -c -d /dev/nvme0n1p1 -p 1 -L Fedora -l '\EFI\fedora\grubx64.efi'

    $ # All things done; now exit from chroot
    $ exit
    $ # Now you can reboot
  5. @Tamal Tamal created this gist Apr 29, 2020.
    23 changes: 23 additions & 0 deletions set-chroot.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    $ # Use Live CD to boot
    $ sudo su # Switch to root
    $ fdisk -l # Get names of root, boot & EFI partition names. you can also use blkid
    $ mount /dev/mapper/fedora_localhost--live-root /mnt # mount root partition
    $ cat /mnt/etc/fedora-release
    Fedora release 31 (Thirty One)
    $ mount /dev/nvme0n1p2 /mnt/boot # mount boot partition
    $ mount /dev/nvme0n1p1 /mnt/boot/efi # mount EFI partition
    $ ls /mnt/boot/efi # should show all OS names under EFI

    $ # mount the virtual filesystems that the system uses to communicate with processes and devices
    $ for dir in /dev /proc /sys /run; do mount --bind $dir /mnt/$dir ; done

    $ # enter chroot
    $ chroot /mnt

    $ # Now you can do all the work e.g. fix grub
    $ dnf reinstall grub2-efi shim -y
    $ grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg # Regenerate grub2

    $ # All things done; now exit from chroot
    $ exit
    $ # Now you can reboot