4

Is there a way to move the grub to a new partition, or drive in linux in the grub rescue, or the live mode?

cnx223
  • 55
  • 1
    Not sure what you mean. The grub installed to a MBR for BIOS boot uses many files inside the LInux install. Or if UEFI the grub in the ESP uses those same files in the Linux install. If UEFI you can move the /EFI/ubuntu folder to another drive. If in Ubuntu and BIOS you can easily install grub to the MBR of another drive. What is it that you want in detail? – oldfred Aug 05 '15 at 04:35

2 Answers2

7

Yes, this can be done. The command is grub-install and its syntax is like so:

grub-install [OPTION...] [OPTION] [INSTALL_DEVICE]

Since you asked for a live media recovery, here's a procedure from this tutorial:

Boot the Ubuntu Live CD.

Press Ctrl-Alt-F1

sudo mount /dev/sda1 /mnt

sudo mount --bind /dev /mnt/dev

sudo mount --bind /proc /mnt/proc

sudo mount --bind /sys /mnt/sys

sudo chroot /mnt

Now the fun stuff. Lets say I want grub to be on /dev/sda2, I'd run sudo grub-install /dev/sda2 or alternatively sudo grub-install /dev/sda to be partition/OS independent

Sergiy Kolodyazhnyy
  • 105,154
  • 20
  • 279
  • 497
0

My answer to move the default boot to another disk, which is hard to find on the web:

Assume you boot from /dev/sda2 and you want to boot by default from /dev/sdb2. This without bothering/counting menuentries in /boot/grub.cfg, then:

  1. update-grub
  2. reboot, and select the partition you want to boot from (say /dev/sdb2).
  3. when booted, do update-grub again. this will make the current booted partition the primary boot partition.
  4. for added luck, do

a) install-grub /dev/sda

b) install-grub /dev/sdb

Now , if you ever pull drive /dev/sda , some bootable grub remains.

Happy booting!

vkersten
  • 21
  • 3