* Add support for NixOS Signed-off-by: Maurice Zhou <jasper@apvc.uk> * updated files for immutable root fs Signed-off-by: Maurice Zhou <jasper@apvc.uk> * update ssh key location Signed-off-by: Maurice Zhou <jasper@apvc.uk> * change initrd host key name Signed-off-by: Maurice Zhou <jasper@apvc.uk> * add missing -p switch Signed-off-by: Maurice Zhou <jasper@apvc.uk> * comments about SSH and encrypted bpool Signed-off-by: Maurice Zhou <jasper@apvc.uk> * backup hardware-configuration.nix file Signed-off-by: Maurice Zhou <jasper@apvc.uk> * clearer wording for backup Signed-off-by: Maurice Zhou <jasper@apvc.uk> * global useDHCP flag is deprecated Signed-off-by: Maurice Zhou <jasper@apvc.uk> * point user to configuration.nix Signed-off-by: Maurice Zhou <jasper@apvc.uk> * fixes for systemd-autofs; network; typo Signed-off-by: Maurice Zhou <jasper@apvc.uk> * force command to return 0 Signed-off-by: Maurice Zhou <jasper@apvc.uk> * fix command to postMount Signed-off-by: Maurice Zhou <jasper@apvc.uk> * fix mount command Signed-off-by: Maurice Zhou <jasper@apvc.uk> * escape $i Signed-off-by: Maurice Zhou <jasper@apvc.uk> * create mountpoints before booting Signed-off-by: Maurice Zhou <jasper@apvc.uk> * replace postDevice,preMount command Signed-off-by: Maurice Zhou <jasper@apvc.uk> * disable zfs-mount Signed-off-by: Maurice Zhou <jasper@apvc.uk> * generate machine-id Signed-off-by: Maurice Zhou <jasper@apvc.uk>
146 lines
4.0 KiB
ReStructuredText
146 lines
4.0 KiB
ReStructuredText
.. highlight:: sh
|
|
|
|
Recovery
|
|
======================
|
|
|
|
.. contents:: Table of Contents
|
|
:local:
|
|
|
|
GRUB Tips
|
|
-------------
|
|
|
|
Boot from GRUB rescue
|
|
~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
If bootloader file is damaged, it's still possible
|
|
to boot computer with GRUB rescue image.
|
|
|
|
This section is also applicable if you are in
|
|
``grub rescue>``.
|
|
|
|
#. On another computer, generate rescue image with::
|
|
|
|
pacman -S --needed mtools libisoburn grub
|
|
grub-install
|
|
grub-mkrescue -o grub-rescue.img
|
|
dd if=grub-rescue.img of=/dev/your-usb-stick
|
|
|
|
Boot computer from the rescue media.
|
|
Both legacy and EFI mode are supported.
|
|
|
|
Or `download generated GRUB rescue image <https://gitlab.com/m_zhou/bieaz/uploads/4a1b7cefb42723de6eb04f9dc485be3b/grub-rescue.img.7z>`__.
|
|
|
|
#. List available disks with ``ls`` command::
|
|
|
|
grub> ls (hd # press tab
|
|
Possible devices are:
|
|
|
|
hd0 hd1 hd2 hd3
|
|
|
|
#. List partitions by pressing tab key:
|
|
|
|
.. code-block:: text
|
|
|
|
grub> ls (hd0 # press tab
|
|
Possible partitions are:
|
|
|
|
Device hd0: No known filesystem detected - Sector size 512B - Total size 20971520KiB
|
|
Partition hd0,gpt1: Filesystem type fat - Label `EFI', UUID 0DF5-3A76 - Partition start at 1024KiB - Total size 1048576KiB
|
|
Partition hd0,gpt2: No known filesystem detected - Partition start at 1049600KiB - Total size 4194304KiB
|
|
|
|
- If boot pool is encrypted:
|
|
|
|
Unlock it with ``cryptomount``::
|
|
|
|
grub> insmod luks
|
|
grub> cryptomount hd0,gpt2
|
|
Attempting to decrypt master key...
|
|
Enter passphrase for hd0,gpt2 (af5a240e13e24483acf02600d61e0f36):
|
|
Slot 1 opened
|
|
|
|
Unlocked LUKS container is ``(crypto0)``:
|
|
|
|
.. code-block:: text
|
|
|
|
grub> ls (crypto0)
|
|
Device crypto0: Filesystem type zfs - Label `bpool_ip3tdb' - Last modification
|
|
time 2021-05-03 12:14:08 Monday, UUID f14d7bdf89fe21fb - Sector size 512B -
|
|
Total size 4192256KiB
|
|
|
|
- If boot pool is not encrypted:
|
|
|
|
.. code-block:: text
|
|
|
|
grub> ls (hd0,gpt2)
|
|
Device hd0,gpt2: Filesystem type zfs - Label `bpool_ip3tdb' - Last modification
|
|
time 2021-05-03 12:14:08 Monday, UUID f14d7bdf89fe21fb - Sector size 512B -
|
|
Total size 4192256KiB
|
|
|
|
#. List boot environments nested inside ``bpool/$INST_ID/BOOT``::
|
|
|
|
grub> ls (crypto0)/sys/BOOT
|
|
@/ default/ be0/
|
|
|
|
#. Instruct GRUB to load configuration from ``be0`` boot environment::
|
|
|
|
grub> prefix=(crypto0)/sys/BOOT/be0/@/grub
|
|
grub> configfile $prefix/grub.cfg
|
|
|
|
#. GRUB menu should now appear.
|
|
|
|
#. After entering system, reinstall GRUB.
|
|
|
|
Switch GRUB prefix when disk fails
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
If you are using LUKS encrypted boot pool with multiple disks,
|
|
the primary disk failed, GRUB will fail to load configuration.
|
|
|
|
If there's still enough redundancy for the boot pool, try fix
|
|
GRUB with the following method:
|
|
|
|
#. Ensure ``Slot 1 opened`` message
|
|
is shown
|
|
|
|
.. code-block:: text
|
|
|
|
Welcome to GRUB!
|
|
|
|
error: no such cryptodisk found.
|
|
Attempting to decrypt master key...
|
|
Enter passphrase for hd0,gpt2 (c0987ea1a51049e9b3056622804de62a):
|
|
Slot 1 opened
|
|
error: disk `cryptouuid/47ed1b7eb0014bc9a70aede3d8714faf' not found.
|
|
Entering rescue mode...
|
|
grub rescue>
|
|
|
|
If ``error: access denied.`` is shown,
|
|
try re-enter password with::
|
|
|
|
grub rescue> cryptomount hd0,gpt2
|
|
|
|
#. Check prefix::
|
|
|
|
grub rescue > set
|
|
# prefix=(cryptouuid/47ed1b7eb0014bc9a70aede3d8714faf)/sys/BOOT/be0@/grub
|
|
# root=cryptouuid/47ed1b7eb0014bc9a70aede3d8714faf
|
|
|
|
#. Set correct ``prefix`` and ``root`` by replacing
|
|
``cryptouuid/UUID`` with ``crypto0``::
|
|
|
|
grub rescue> prefix=(crypto0)/sys/BOOT/default@/grub
|
|
grub rescue> root=crypto0
|
|
|
|
#. Boot GRUB::
|
|
|
|
grub rescue> insmod normal
|
|
grub rescue> normal
|
|
|
|
GRUB should then boot normally.
|
|
|
|
#. After entering system, edit ``/etc/fstab`` to promote
|
|
one backup to ``/boot/efi``.
|
|
|
|
#. Make the change to ``prefix`` and ``root``
|
|
permanent by `reinstalling GRUB <#grub-installation>`__.
|