Installing GRUB2 on an external HDD without a live CD

8,325

Solution 1

Use grub-install. If your external drive is /dev/sdb and GRUB images are in /boot/grub/ of its first partition, typically you can do as follows:

mount /dev/sdb1 /mnt
grub-install --boot-directory=/mnt/boot /dev/sdb

Solution 2

Make sure you've cloned the original disk's master boot sector and whatever is at the beginning of the disk, by doing something like dd if=/dev/sda of=/dev/sdb bs=512 count=2048 - assuming sda is the original drive and sdb is the mirrored drive, tune that as necessary.

Then try simply unplugging the current disk and plug the mirrored disk in its place. Worst case it won't work and you'll revert right back.

A quick google finds me a guide that shows clonezilla being used in the context of boot loaders - http://clonezilla.org/show-live-doc-content.php?topic=clonezilla-live/doc/03_Disk_to_disk_clone

Share:
8,325

Related videos on Youtube

Eleno
Author by

Eleno

Updated on September 18, 2022

Comments

  • Eleno
    Eleno almost 2 years

    I have cloned my HDD to an external HDD and now I need to install GRUB to make the external HDD bootable.

    The external HDD is meant as a mirror backup for my current HDD (I mean that once the external HDD is bootable, I will place it into my PC and boot it; I am not going to boot from the mirror backup while keeping it into its external enclosure).

    As far as I know, the standard procedure to install GRUB is to place the HDD into your PC and boot with a live CD, but I would rather using a live CD and do everything from my existing Linux installation. Is this is possible?

  • Anthon
    Anthon about 9 years
    @JosipRodin There is a grey area between what is a comment and what is an answer. As you worded your post as a question, it looks more like a comment asking for more information than like an answer. I changed it so it looks more like an answer, you can roll back if you don't like the change
  • Eleno
    Eleno about 9 years
    @Josip Rodin: No, I didn't clone the MBR, because the HDDs are different (manufacturer and size). I only cloned the partitions by using CloneZilla.
  • Josip Rodin
    Josip Rodin about 9 years
    @Elena I'm not sure what CloneZilla does, but just in case included a hint on how to clone the MBR in the answer above, try it.
  • yaegashi
    yaegashi about 9 years
    Just copying the first sector (MBR) is insufficient in most cases. GRUB utilize the gap between MBR and the first parition to store its stage1.5 or core.img. See this image found in Wikipedia.
  • Josip Rodin
    Josip Rodin about 9 years
    Then just expand the amount to cover the first megabyte. Since the point is to make an identical copy, it should be safe enough.
  • yaegashi
    yaegashi about 9 years
    It won't work if the boot partition number / location (the first sector of it) in the new disk is different from original ones. Just run grub-install on the new disk is and much easier and more reliable than calculate params for dd. Clonezilla can apparently run grub-install on behalf of user according to the guide you cite.
  • Josip Rodin
    Josip Rodin about 9 years
    @yaegashi well, the whole point of using the term "cloning" or "mirroring" disk to another one (which is what the original poster used) should preclude the notion that there's a difference between the locations of the first sector :) maybe if it was some complicated MBR to GPT clone, but it doesn't seem to be the case here. Granted, doing another grub-install to make sure seems sensible enough, but then in turn you still have to make sure you don't screw something up with its parameters.