How to install Grub2 under several common scenarios

Posted by Huckle on Ask Ubuntu See other posts from Ask Ubuntu or by Huckle
Published on 2012-10-07T23:13:45Z Indexed on 2012/10/08 3:48 UTC
Read the original article Hit count: 417

Filed under:
|
|

I feel the community has long needed a clean guide on how to install Grub2 under a a few extremely common scenarios. I will accept answer as solved when it has one section per scenario and assumes nothing other than what is specified. Please add to the existing answer, wiki style, keeping to the original assumptions.

Rules:
1. You cannot, at any point in the answer, invoke Ubiquity (the Ubuntu installer).
2. I strongly recommend not using any automatic boor-repair tools as they're not very educational

Scenario 1: Non-booting Linux OS, No boot partition, Fix from Live CD

Setup:

  • /dev/sda1 is formatted ext*
  • /dev/sda2 is formatted linux_swap
  • /dev/sda1 doesn't boot because MBR is scrambled and /boot/* was erased

Explain:

  • How to boot to a Live CD / USB and restore Grub2 to the MBR and /boot of /dev/sda1

Scenario 2: Non-booting Linux OS, Boot partition, Fix from Live CD

Setup:

  • /dev/sda1 is formatted fat
  • /dev/sda2 is formatted ext*
  • /dev/sda3 is formatted linux_swap
  • /dev/sda2 doesn't boot because the MBR is scrambled and /dev/sda1 was formatted

Explain:

  • How to boot to a Live CD / USB and restore Grub2 to the MBR and /dev/sda1 and then update the fstab on /dev/sda2

Scenario 3: Install on to thumb drive, Booting various OSes, From Linux OS

Setup:

  • /dev/sdb is removable media
  • /dev/sdb1 is formatted fat
  • /dev/sdb2 is formatted ext*
  • /dev/sdb3 is formatted fat
  • The MBR of /dev/sdb is otherwise not initialized
  • You are executing from a Linux based OS installed on /dev/sda

Explain:

  • How to install Grub2 on to /dev/sdb1, mark /dev/sdb1 active, be able to chose between /dev/sdb2 and /dev/sdb3 on boot.

Scenario 4: (Bonus) Install on to thumb drive, Booting ISO, From Linux OS

Setup:

  • /dev/sdb is removable media
  • /dev/sdb1 is formatted fat
  • /dev/sdb1 contains /iso/live.iso
  • /dev/sdb2 is formatted ext*
  • /dev/sdb3 is formatted fat
  • The MBR of /dev/sdb is otherwise not initialized
  • You are executing from a Linux based OS installed on /dev/sda

Explain:

  • How to install Grub2 on to /dev/sdb1, mark /dev/sdb1 active, be able to chose between /dev/sdb2, /dev/sdb3, and /iso/live.iso on boot.

© Ask Ubuntu or respective owner

Related posts about grub2

Related posts about dual-boot