Manjaro Difference between revisions of "User:Megavolt/bootloaders"

Difference between revisions of "User:Megavolt/bootloaders"

From Manjaro
(Created page with "<languages/> __TOC__ <translate> ==Overview== <!--T:1--> In order to load the operating system, a Linux-capable boot loader such as GRUB, rEFInd or Syslinux needs to be instal...")
 
m (some rework)
Line 1: Line 1:
<languages/>
 
__TOC__
__TOC__
<translate>
==Overview== <!--T:1-->
In order to load the operating system, a Linux-capable boot loader such as GRUB, rEFInd or Syslinux needs to be installed to the Master Boot Record (MBR) or the GUID Partition Table (GPT) of the media containing the Operating System. Installations created using Manjaro ISO defaults to GRUB.


<!--T:2-->
==Overview==
In order to load the operating system a boot loader is needed. There is not only one boot loader, but many of them which have its benefits and disadvantages.
 
Common boot loaders are:
* GRUB
* systemd-boot
* rEFInd
* Syslinux
 
It depends on the computer which boot loader can or should be used. In general there are 2 system: UEFI/EFI and BIOS, while UEFI/EFI has commonly also a legacy mode which is fully compatible with a pure BIOS.
 
<!--
 
For various reasons - it happens the bootloader get's corrupted, erased or misconfigured resulting to a black screen with a failure message during boot, like '''No boot loaders found in /dev/...'''. To restore system operation without re-installing your OS or losing your data you will need to use your Manjaro installation media, such as, a CD/DVD or USB Flashdrive.
For various reasons - it happens the bootloader get's corrupted, erased or misconfigured resulting to a black screen with a failure message during boot, like '''No boot loaders found in /dev/...'''. To restore system operation without re-installing your OS or losing your data you will need to use your Manjaro installation media, such as, a CD/DVD or USB Flashdrive.
{{BoxSecondary|Archlinux Boot Process|More information about the boot process on Archlinux based distributions is available at [https://wiki.archlinux.org/index.php/Arch_boot_process Archwiki]}}
{{BoxSecondary|Archlinux Boot Process|More information about the boot process on Archlinux based distributions is available at [https://wiki.archlinux.org/index.php/Arch_boot_process Archwiki]}}
 
-->
==Preparation== <!--T:3-->
==Preparation==  
Identify the type of system you are attempted to rescue as the commands involved are slightly different. There are 2 types of systems which are not compatible to each other.
Identify the type of system you are attempted to rescue as the commands involved are slightly different. There are 2 types of systems which are not compatible to each other.


=== Identify the system ===
=== Identify the system ===
Indicators for EFI:
Indicators for EFI:
* When you start the computer and you commonly type F8 (or any other key combination) to choose a boot media, you will see 2 different entries of the same media, flagged with either [UEFI] or [legacy].
* When you start the computer and you commonly type F8 (or any other key combination) to choose a boot media, you will see 2 different entries of the same media, flagged with either [UEFI] or [legacy].
* Your local Disk has a small vfat (fat16/32) partition (100-300MB).
* Your local Disk has a small vfat (fat16/32) partition (100-300MB).
* Your local Disk has a GPT partition table.
* Your local Disk has a GPT partition table.


If all of these indicators are not valid to your computer, then it must be a pure BIOS.
If all of these indicators are not valid to your computer, then it is most likely be a pure BIOS.


==== BIOS ====
==== BIOS ====
Line 40: Line 50:
Go to [[Restore_the_GRUB_Bootloader#Identify_the_system|Identify the system]] for indicators of which system you use.
Go to [[Restore_the_GRUB_Bootloader#Identify_the_system|Identify the system]] for indicators of which system you use.


=== Load Manjaro Installation Media === <!--T:4-->
=== Load Manjaro Installation Media ===  
{{BoxSecondary|System Boot Override|To override system boot order the vendor has a dedicated key. Most laptop keyboard has multiple use for the function keys and the primary function may be reversed. In such case a <kbd>Fn</kbd> key must be used with the function key. If you don't know consult your system documentation. Manjaro ISO default usernames and passwords
 
<table>
In order to boot with a Manjaro Installation Media  [[Burn_an_ISO_File|you need to create it]], if not done yet.
<tr><th>Default Username</th><th>Default Password</th></tr>
{{BoxSecondary|System Boot Override|To override system boot order the vendor has a dedicated key. Most laptop keyboard has multiple use for the function keys and the primary function may be reversed. In such case a key must be used with the function key. If you don't know consult your system documentation. Manjaro ISO default usernames and passwords
<tr><td>manjaro</td><td>manjaro</td></tr>
 
<tr><td>root</td><td>manjaro</td></tr>
 
</table>
 
 
 
}}
}}


==== Identify partitions ==== <!--T:5-->
==== Identify partitions ====  
To identify your partitions and their designated use you need to run a partition manager. Depending on environment there is various tools. GTK based ISO offers GpartEd, QT based ISO offers KParted and common to all is the CLI tools.
To identify your partitions and their designated use you need to run a partition manager. Depending on environment there is various tools. GTK based ISO offers GpartEd, QT based ISO offers KParted and common to all is the CLI tools.
{{UserCmd|command=lsblk -o PATH,PTTYPE,PARTTYPE,FSTYPE,PARTTYPENAME}}
{{UserCmd|command=lsblk -o PATH,PTTYPE,PARTTYPE,FSTYPE,PARTTYPENAME}}
Line 56: Line 68:
The clues to look for is ''mbr'' vs. ''gpt'' and the presence of a small partition - usually the first - formatted with the ''vfat'' filesystem followed by a larger partition formatted as ''ext4''.
The clues to look for is ''mbr'' vs. ''gpt'' and the presence of a small partition - usually the first - formatted with the ''vfat'' filesystem followed by a larger partition formatted as ''ext4''.


<!--T:6-->
 
{{Important|This document and the content should '''never''' be used as a copy/paste resource. The remainder of this document will use pseudo names and partition numbering. Devices will be referred as '''/dev/sdy''' and partitions referred as '''/dev/sdyA''' and you will have to subtitute those with the real values from your system.}}
{{Important|This document and the content should '''never''' be used as a copy/paste resource. The remainder of this document will use pseudo names and partition numbering. Devices will be referred as '''/dev/sdy''' and partitions referred as '''/dev/sdyA''' and you will have to subtitute those with the real values from your system.}}


==Use root context== <!--T:7-->
==Use root context==  
When you have loaded the live ISO - depending on environment - open a terminal and switch to ''root'' context. Use above mentioned root:password combination.
When you have loaded the live ISO - depending on environment - open a terminal and switch to ''root'' context. Use above mentioned root:password combination.
{{UserCmd|command=su}}
{{UserCmd|command=su}}


==Chroot environment== <!--T:8-->
==Chroot environment==  
Chroot is a method to restrict various tasks to a restricted area e.g. package installation and other system maintenance tasks. Follow the [https://wiki.archlinux.org/index.php/Change_Root link] to read more about chroot on the Arch wiki.
Chroot is a method to restrict various tasks to a restricted area e.g. package installation and other system maintenance tasks. Follow the [https://wiki.archlinux.org/index.php/Change_Root link] to read more about chroot on the Arch wiki.
===Identify system partitions===
===Identify system partitions===
Line 79: Line 91:
{{Important|If your system is a BIOS/MBR system there is no efi partition. If your system is a BIOS/GPT system you will find an unformatted partion size 1-32MB of the bios boot partition type.}}
{{Important|If your system is a BIOS/MBR system there is no efi partition. If your system is a BIOS/GPT system you will find an unformatted partion size 1-32MB of the bios boot partition type.}}


===Use manjaro-chroot=== <!--T:10-->
===Use manjaro-chroot===  
Manjaro deploys a script called {{ic|manjaro-chroot}} takes an optional argument which will search the visible devices - scan the partitions for signs of an operating system. If more than one Linux operating system is found you will get a choice of which system to chroot otherwise the file ''/etc/fstab'' from the system is used to mount the partitions and chroot into this system.This script is only available in live iso by default but you can get it in an installed system by installing {{Ic|manjaro-tools-base}} package.
Manjaro deploys a script called {{ic|manjaro-chroot}} takes an optional argument which will search the visible devices - scan the partitions for signs of an operating system. If more than one Linux operating system is found you will get a choice of which system to chroot otherwise the file ''/etc/fstab'' from the system is used to mount the partitions and chroot into this system.This script is only available in live iso by default but you can get it in an installed system by installing {{Ic|manjaro-tools-base}} package.
{{RootCmd|command=pamac install manjaro-tools-base}}
{{RootCmd|command=pamac install manjaro-tools-base}}
{{RootCmd|command=manjaro-chroot -a}}
{{RootCmd|command=manjaro-chroot -a}}


===Manual chroot=== <!--T:9-->
===Manual chroot===  
(Unnecessary if you have used {{ic|manjaro-chroot}})
(Unnecessary if you have used {{ic|manjaro-chroot}})
Mount the partitions using the designated temporary mountpoint and '''always''' start with ''root''
Mount the partitions using the designated temporary mountpoint and '''always''' start with ''root''


<!--T:17-->
 
{{RootCmd|command=mount /dev/sdyC /mnt}}
{{RootCmd|command=mount /dev/sdyC /mnt}}
{{Important|With a [[Btrfs|BTRFS filesystem]], you should note that the subvolumes must be mounted. That would be in such a case:{{RootCmd|command=mount -o subvol=@ /dev/sdyC /mnt}}}}
{{Important|With a [[Btrfs|BTRFS filesystem]], you should note that the subvolumes must be mounted. That would be in such a case:{{RootCmd|command=mount -o subvol=@ /dev/sdyC /mnt}}}}
Line 99: Line 111:




==Reinstall GRUB== <!--T:11-->
==Reinstall GRUB==  
One possible cause why you are reading this document - is an unfinished update - which in turn can be caused by several situations - situation we will not dive into. To fix what ever caused this you should run a full system update including grub to ensure everything is in place.
One possible cause why you are reading this document - is an unfinished update - which in turn can be caused by several situations - situation we will not dive into. To fix what ever caused this you should run a full system update including grub to ensure everything is in place.
{{RootCmd|command=pacman -Syu grub}}
{{RootCmd|command=pacman -Syu grub}}
Line 106: Line 118:
On a BIOS/GPT system there is no MBR and therefore no place to store the loader. The GPT partition specification allows for an unformatted partition of the BIOS boot partition type (0xEF02). The size of this partition can be as small as 1 mebibyte. The Calamares installer uses a fixed size of 32 mebibyte. On a BIOS/MBR system a part of the bootloader is written to the Master Boot Record for the primary disk.
On a BIOS/GPT system there is no MBR and therefore no place to store the loader. The GPT partition specification allows for an unformatted partition of the BIOS boot partition type (0xEF02). The size of this partition can be as small as 1 mebibyte. The Calamares installer uses a fixed size of 32 mebibyte. On a BIOS/MBR system a part of the bootloader is written to the Master Boot Record for the primary disk.


<!--T:12-->
 
The device is the '''disk''' ('''not a partition''')
The device is the '''disk''' ('''not a partition''')
{{RootCmd|command=grub-install --force --target=i386-pc --recheck --boot-directory=/boot /dev/sdy}}
{{RootCmd|command=grub-install --force --target=i386-pc --recheck --boot-directory=/boot /dev/sdy}}
Line 112: Line 124:
{{RootCmd|command=grub-mkconfig -o /boot/grub/grub.cfg}}
{{RootCmd|command=grub-mkconfig -o /boot/grub/grub.cfg}}


===EFI System=== <!--T:13-->
===EFI System===  
{{Important|You need to be in chroot for this procedure.}}
{{Important|You need to be in chroot for this procedure.}}
Reinstall grub
Reinstall grub
Line 119: Line 131:
{{RootCmd|command=grub-mkconfig -o /boot/grub/grub.cfg}}
{{RootCmd|command=grub-mkconfig -o /boot/grub/grub.cfg}}


<!--T:14-->
 
{{BoxWarning|EFI grub install messages|EFI variables are not supported on this system.}}
{{BoxWarning|EFI grub install messages|EFI variables are not supported on this system.}}
Verify the existance of an EFI system partition
Verify the existance of an EFI system partition
Line 137: Line 149:
If successfull re-run above installation commands
If successfull re-run above installation commands


==Troubleshooting== <!--T:15-->
==Troubleshooting==  
=== Arch Linux is not recognized ===
=== Arch Linux is not recognized ===
If Arch Linux wasn't recognized after an update-grub then probably your Arch installation is missing the package lsb-release.
If Arch Linux wasn't recognized after an update-grub then probably your Arch installation is missing the package lsb-release.


==See also== <!--T:16-->
==See also==  
* [http://wiki.manjaro.org/index.php?title=UEFI_-_Install_Guide UEFI Install Guide]
* [http://wiki.manjaro.org/index.php?title=UEFI_-_Install_Guide UEFI Install Guide]
* [https://wiki.archlinux.org/index.php/GRUB GRUB on Arch wiki]
* [https://wiki.archlinux.org/index.php/GRUB GRUB on Arch wiki]
</translate>
 
[[Category:Contents Page{{#translation:}}]]
[[Category:Contents Page{{#translation:}}]]

Revision as of 02:05, 12 September 2022

Overview

In order to load the operating system a boot loader is needed. There is not only one boot loader, but many of them which have its benefits and disadvantages.

Common boot loaders are:

  • GRUB
  • systemd-boot
  • rEFInd
  • Syslinux

It depends on the computer which boot loader can or should be used. In general there are 2 system: UEFI/EFI and BIOS, while UEFI/EFI has commonly also a legacy mode which is fully compatible with a pure BIOS.

Preparation

Identify the type of system you are attempted to rescue as the commands involved are slightly different. There are 2 types of systems which are not compatible to each other.

Identify the system

Indicators for EFI:

  • When you start the computer and you commonly type F8 (or any other key combination) to choose a boot media, you will see 2 different entries of the same media, flagged with either [UEFI] or [legacy].
  • Your local Disk has a small vfat (fat16/32) partition (100-300MB).
  • Your local Disk has a GPT partition table.

If all of these indicators are not valid to your computer, then it is most likely be a pure BIOS.

BIOS

Old computers have commonly only a pure BIOS.

  • Your disk has commonly a MBR/MS-DOS partition table.
  • There is only one Master Boot Record for each disk. Which means only one BootLoader can be targeted.
  • If you have installed Manjaro along with Windows or another Linux Distribution on the same Disk, then the last installed OS will commonly overwrite the MBR and take itself as the boot target.
  • If you have installed 2 Operating-Systems on 2 separate Disks, then you are able to set the boot priority at the BIOS settings, so that it boots the first disk first, if it fails, it boots the second one etc.

EFI

Newer computers have commonly an UEFI. It has also a legacy mode, which is fully compatible with a pure BIOS.

  • You disk has commonly a GPT partition table, but it also support MBR/MS-DOS in legacy mode.
  • The UEFI has a builtin Bootloader which boots efi files.
  • efi files are stored on a partition formatted with vfat (fat16/32) and flagged with "boot" or "esp" or "boot,esp"
  • efi files contain at bare minimum, just like MBR, information about which partition should be booted, but there is no limitation of one MBR per Disk, so you create as many efi partitions and efi files as you like
  • In your UEFI settings you can set the boot priority just like on a pure BIOS.
  • It is possible to use/add a MBR-like behavior in legacy mode on a GPT partition table to be able to boot on both modes. Normally you will see here a 8-10MB non-formatted partition flagged with bios_grub.

Go to Identify the system for indicators of which system you use.

Load Manjaro Installation Media

In order to boot with a Manjaro Installation Media you need to create it, if not done yet.

System Boot Override
To override system boot order the vendor has a dedicated key. Most laptop keyboard has multiple use for the function keys and the primary function may be reversed. In such case a key must be used with the function key. If you don't know consult your system documentation. Manjaro ISO default usernames and passwords



Identify partitions

To identify your partitions and their designated use you need to run a partition manager. Depending on environment there is various tools. GTK based ISO offers GpartEd, QT based ISO offers KParted and common to all is the CLI tools.

user $ lsblk -o PATH,PTTYPE,PARTTYPE,FSTYPE,PARTTYPENAME COPY TO CLIPBOARD


More comprehensive information can be found using fdisk (requires superuser) and you can limit the probed device e.g. /dev/sda or /dev/nvme0n1

user $ sudo fdisk -l /dev/sda COPY TO CLIPBOARD


The clues to look for is mbr vs. gpt and the presence of a small partition - usually the first - formatted with the vfat filesystem followed by a larger partition formatted as ext4.


Info
This document and the content should never be used as a copy/paste resource. The remainder of this document will use pseudo names and partition numbering. Devices will be referred as /dev/sdy and partitions referred as /dev/sdyA and you will have to subtitute those with the real values from your system.


Use root context

When you have loaded the live ISO - depending on environment - open a terminal and switch to root context. Use above mentioned root:password combination.

user $ su COPY TO CLIPBOARD


Chroot environment

Chroot is a method to restrict various tasks to a restricted area e.g. package installation and other system maintenance tasks. Follow the link to read more about chroot on the Arch wiki.

Identify system partitions

From the above we assume you have identified the relevant partitions on your system and this document will refer the partitions as follows. Partitions not needed for this kind of maintenance has intentionally been left out (e.g. home, swap).

Partition Usage / Comment
/dev/sdyA EFI system Required for EFI system and mounted on /boot/efi
/dev/sdyB boot Optional but mounted on /boot The primary use is when GRUB cannot write to / (eg. f2fs)
/dev/sdyC root Required and for the root filesystem and mounted on / - usually formatted using ext4
Info
If your system is a BIOS/MBR system there is no efi partition. If your system is a BIOS/GPT system you will find an unformatted partion size 1-32MB of the bios boot partition type.


Use manjaro-chroot

Manjaro deploys a script called manjaro-chroot takes an optional argument which will search the visible devices - scan the partitions for signs of an operating system. If more than one Linux operating system is found you will get a choice of which system to chroot otherwise the file /etc/fstab from the system is used to mount the partitions and chroot into this system.This script is only available in live iso by default but you can get it in an installed system by installing manjaro-tools-base package.

root # pamac install manjaro-tools-base COPY TO CLIPBOARD


root # manjaro-chroot -a COPY TO CLIPBOARD


Manual chroot

(Unnecessary if you have used manjaro-chroot) Mount the partitions using the designated temporary mountpoint and always start with root


root # mount /dev/sdyC /mnt COPY TO CLIPBOARD


Info
With a BTRFS filesystem, you should note that the subvolumes must be mounted. That would be in such a case:
root # mount -o subvol=@ /dev/sdyC /mnt COPY TO CLIPBOARD


Then - if applicable - mount boot

root # mount /dev/sdyB /mnt/boot COPY TO CLIPBOARD


Then - if applicable - mount efi

root # mount /dev/sdyA /mnt/boot/efi COPY TO CLIPBOARD


Create the chroot environment and use bash as shell

root # manjaro-chroot /mnt /bin/bash COPY TO CLIPBOARD



Reinstall GRUB

One possible cause why you are reading this document - is an unfinished update - which in turn can be caused by several situations - situation we will not dive into. To fix what ever caused this you should run a full system update including grub to ensure everything is in place.

root # pacman -Syu grub COPY TO CLIPBOARD


When the transaction as completed continue below using the section matching your system

BIOS System

On a BIOS/GPT system there is no MBR and therefore no place to store the loader. The GPT partition specification allows for an unformatted partition of the BIOS boot partition type (0xEF02). The size of this partition can be as small as 1 mebibyte. The Calamares installer uses a fixed size of 32 mebibyte. On a BIOS/MBR system a part of the bootloader is written to the Master Boot Record for the primary disk.


The device is the disk (not a partition)

root # grub-install --force --target=i386-pc --recheck --boot-directory=/boot /dev/sdy COPY TO CLIPBOARD


Make sure the grub configuration is up-to-date

root # grub-mkconfig -o /boot/grub/grub.cfg COPY TO CLIPBOARD


EFI System

Info
You need to be in chroot for this procedure.


Reinstall grub

root # grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=manjaro --recheck COPY TO CLIPBOARD


Update the grub configuration

root # grub-mkconfig -o /boot/grub/grub.cfg COPY TO CLIPBOARD



EFI grub install messages
EFI variables are not supported on this system.

Verify the existance of an EFI system partition

root # lsblk -o PATH,PTTYPE,PARTTYPE,FSTYPE,PARTTYPENAME COPY TO CLIPBOARD


Verify the efi filesystem is loaded

root # ls /sys/firmware/efi COPY TO CLIPBOARD


Exit chroot

root # exit COPY TO CLIPBOARD


Try loading the efi filesystem

root # modprobe efivarfs COPY TO CLIPBOARD


Re-enter chroot

root # manjaro-chroot /mnt /bin/bash COPY TO CLIPBOARD


Then mount the efi filesystem

root # mount -t efivarfs efivarfs /sys/firmware/efi/efivars COPY TO CLIPBOARD


Verify the efi filesystem is loaded

root # ls /sys/firmware/efi COPY TO CLIPBOARD


If successfull re-run above installation commands

Troubleshooting

Arch Linux is not recognized

If Arch Linux wasn't recognized after an update-grub then probably your Arch installation is missing the package lsb-release.

See also

Cookies help us deliver our services. By using our services, you agree to our use of cookies.