Is there a way to move the grub to a new partition, or drive in linux in the grub rescue, or the live mode?
-
1Not 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?– oldfredAug 5, 2015 at 4:35
2 Answers
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
-
As you're a reputation 10 user: If this answer helped you, don't forget to click the grey ☑ at the left of this text, which means Yes, this answer is valid! ;-)– FabbyAug 9, 2015 at 20:00
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:
update-grub
- reboot, and select the partition you want to boot from (say /dev/sdb2).
- when booted, do
update-grub
again. this will make the current booted partition the primary boot partition. - 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!