Coder Social home page Coder Social logo

dotfiles's Introduction

Accessing GRUB in an emergency situation

A guide for my future self

Update: Insyde BIOS and the Linux kernel

The issue described below is caused by a bug in how the Linux kernel interacted with EFI firmware authored by Insyde prior to kernel version 4.14.9.

To restore the BIOS to a working state, boot a copy of Ubuntu using kernel 4.14.9 or higher.

See this bug report for further information.

Corey Rowe, January 2018

The problem

The NVRAM in this system (Lenovo Y50-70 Touch 80DT, August 2015) has entered a read-only state.

See this writeup on another Lenovo user's virtually identical situation.

This system cannot boot from USB, the boot order cannot be changed, and the existing path to grub2 cannot be modified.

  • The EFI entry that is attempting to load is ubuntu.
  • This entry is searching for /EFI/ubuntu/shimx64.efi.
  • The file /EFI/ubuntu/grubx64.efi must also be present to enter rescue mode.

Emergency copies of these files are available under emergency-bootloader in the Windows home folder. They were downloaded from this Stack Exchange response, but can also be obtained from an Ubuntu ISO with a little work.

Steps to fix

Open an elevated command prompt and run the following:

diskpart
select disk 0
select partition 2
assign letter=z
^C
z:
cd EFI
cd ubuntu
copy "c:\Users\corey\emergency-bootloader\shimx64.efi" .
copy "c:\Users\corey\emergency-bootloader\grubx64.efi"

If you need to repair your Linux installation, prepare an Ubuntu Live USB now. This must be Ubuntu or a distro built upon Ubuntu.

Upon reboot, you will enter a rescue prompt with limited functionality. Run the following to boot from your USB, replacing (hd0,1) with the root of the USB device:

set root=(hd0,1)
linux /casper/vmlinuz.efi boot=casper quiet splash
initrd /casper/initrd.lz
boot

Ubuntu should then boot successfully. Upon install, Ubuntu will reconstruct the Grub bootloader, at which point you can add custom entries to access Linux distributions on separate partitions. These must be accessed through the Ubuntu bootloader due to the NVRAM failure.

Extras

Booting a Windows installation USB

This requires a full GRUB install; the rescue prompt is not sufficient.

insmod ntfs
set root=(hd0,msdos1)
chainloader (${root})/EFI/Microsoft/Boot/bootmgfw.efi
boot

Booting GParted Live from disk partition

set root=(hd0,8)
linux /live-hd/vmlinuz boot=live config union=overlay username=user components noswap noeject vga=788 ip= net.ifnames=0 live-media-path=/live-hd bootfrom=/dev/sda8 toram=filesystem.squashfs
initrd /live-hd/initrd.img
boot

Notes

NEVER move, resize, reformat or delete Partition 2 (EFI) on this hard drive.

The boot partition must always be Partition 2.

The UUID of Partition 2 must be: 99e8c7d7-50eb-485b-bba1-5f969009fb78

If the UUID needs to be reset, run the following:

sudo tune2fs /dev/sda2 -U 99e8c7d7-50eb-485b-bba1-5f969009fb78

If the firmware cannot recognize the EFI partition, a PXE boot will be required to access files on the disk. If the ethernet card were to then fail, the system would require motherboard replacement.

Emergency EFI netboot using Ubuntu

Follow this guide with a few modifications.

  1. Set the contents of of /etc/dnsmasq.conf to the following:
interface=enp9s0
bind-interfaces
dhcp-range=192.168.0.55,192.168.0.55
dhcp-boot=grubnetx64.efi.signed
dhcp-option-force=66,192.168.0.1
enable-tftp
tftp-root=/srv/tftp/
  1. Run these commands before starting the dnsmasq service:
ip link set enp9s0 up
ip addr add 192.168.0.1/24 dev enp9s0

Corey Rowe, November 2017

dotfiles's People

Contributors

cr96 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.