GRUB/Restore the GRUB Bootloader

Revision as of 23:40, 3 March 2013 by imported>Verityproductions

Overview

As with any Linux operating system, the GRUB (GRand Unified Bootloader) is responsible for booting up Manjaro. If for any reason your GRUB is not working - perhaps due to being corrupted, mis-configured, or even deleted - then it may not be necessary to reinstall Manjaro as a consequence. The GRUB can instead be fully repaired and restored, retaining your installed Manjaro system. To undertake this task, you will need to use your Manjaro installation media (e.g. CD/DVD or USB Flashdrive).


Boot the Manjaro Installation Media

1. Insert and boot your Manjaro installation media.

2. Select your preferred language (F2) and keyboard layout (F3).



Tip
Setting the language and keyboard layout are undertaken by pressing the Function (F) keys. As many computers have multiple functions assigned to each function key, it may be necessary to hold down another key first to use them. For example, on a HP G62 laptop, to use the function keys, the 'fn' key must first be pressed and held.


3. Boot Manjaro Linux. It does not matter which boot option you choose, as the installation media is being used solely to repair/reinstate the GRUB, and not to install a fresh system.

4. Open the terminal or access the command line of the live CD.

  • From the desktop environment: open the terminal from your desktop menu, or
  • From the command line (e.g. NET-Edition or having used the Boot in Text mode option): enter the default username (manjaro) and password (manjaro) to log in.


Identify and Prepare the Installed Partition(s)

Tip
If you had installed Manjaro using the assisted preparation method - whereby the installer automatically prepared and partitioned your computer's hard disk for you - then you will have the same four partitions as those listed by the author, below. This will include a separate Boot partition, named /dev/sda1.


1. Ensure that you are using the Root account, which is identified by a hash ('#') at the beginning of the command line, rather than a dollar ('$'). To switch to Root, enter the command:

sudo su


2. List your partitions. This is necessary in order to identify the partition your Manjaro system is installed on. If you have used a separate boot partition, it will be necessary to identify this as well. For a list of your paritions, enter the command:

sudo blkid


In this particular instance, having used the assisted preparation method to install Manjaro earlier, the partitions for the author's Manjaro system are as follows:

  • /dev/sda1: Boot partition
  • /dev/sda2: Swap partition
  • /dev/sda3: Manjaro system
  • /dev/sda4: Space for personal files.


If you are still unsure, then you can also use an application called gparted, which should be selectable from your desktop menu. This will provide a simple visual illustration of the partitions on your hard drive(s). If a seperate partition for the GRUB exists, it will be marked as 'bootable', and should only be about 100MB in size.


3. Mount your Manjaro system partition. The syntax to mount the Manjaro system partition is:

mount /dev/[partition used for Manjaro system] /mnt


In this instance, as the Manjaro system partition is /dev/sda3, this will be mounted using the following command:

mount /dev/sda3 /mnt


IF you have used a seperate partition for your GRUB bootloader, then this must also be mounted. The syntax to mount a separate partition used to boot is:

mount /dev/[partition used for GRUB] /mnt/boot


In this instance, a seperate partition - /dev/sda1 - has been used for the GRUB, and will be mounted using the following command:

mount /dev/sda1 /mnt/boot


Note
Again, if you have not used a seperate boot partition, then it (obviously) does not need to be mounted!


3. Change to the root directory of your mounted partitions. This is undertaken so that you are working from - and with - your installed system, rather than the installation media. To do so, it will be necessary to enter a series of commands in the following order:

mount -t proc proc /mnt/proc
mount -t sysfs sys /mnt/sys
mount -o bind /dev /mnt/dev
mount -t devpts pts /mnt/dev/pts/
chroot /mnt


4. Install the software applications mtools and os-prober. mtools is a collection of tools to access Microsoft Operating Systems (i.e. MS-DOS). os-prober is a utility that detects if there are any other operating systems present. Install them with the following command:

pacman -S mtools os-prober


Restore the GRUB

1. Install a new GRUB bootloader with the following command:

grub-install /dev/sda


2. Recheck to ensure the that installation has completed without any errors:

grub-install --recheck /dev/sda


3. Finally, configure the freshly installed GRUB bootloader:

update-grub


All done! Now close the terminal and reboot your system to use your freshly re-installed GRUB.


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.