help-grub
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to boot a memory stick image of a hard drive?


From: Pascal Hambourg
Subject: Re: How to boot a memory stick image of a hard drive?
Date: Sat, 15 Jul 2017 09:34:59 +0200
User-agent: Mozilla/5.0 (X11; Linux i686; rv:52.0) Gecko/20100101 Thunderbird/52.2.1

[You replied to the wrong thread, so I attached this reply to your original thread instead of your last mail.]

On 14/07/2017, address@hidden wrote :
Further experiments to try to clone my working Knoppix 6.4.3 hard drive.

     The layout is /dev/sda1 - swap /dev/sda2 - OS.

I used fdisk to get hard disk layout more or less the same using another Linux to mount the 'new' harddrive and the working OS image as a USB memory stick.

I dd copied the working image /dev/sda2 to what is eventually to be /dev/sda2. It is /dev/sdb2 on the cloning system. It seems to have copied OK. I can mount it, etc.

I tried to use grub-install. I was expecting it to ask me a bunch of questions and finally install a good grub including MBR on /dev/sdb. Grub would not do that. Or at least I could not figure out how to do it. There were no known good grub examples that I found.

You must provide all arguments and options to the command line when runnning grub-install. For instance :

grub-install --target=i386-pc --boot-directory=/mnt/boot /dev/sdb

meaning to install GRUB for PC BIOS in the MBR of /dev/sdb and using /mnt/boot (assuming that /sdb2 is mounted on /mnt) as the boot/ directory where to write the grub/ directory and its contents.

So I took the known good MBR from the running system and dd copied it to the 'new' hard drive.

This is not enough. You also need to copy the core image, which is usually located in the unallocated sectors next to the MBR before the first partition.

On boot I see 'GRUB ' on the CRT and then dead. So I assume grub 'must' be loading some absolute block number from the hard drive of assembly code , but doesn't load the right block(s). It would be MOST helpful to know exactly what grub was trying to do at this point?? I probably could then have just patched the MBR assembly code and have been up and running?

At this point, the BIOS loaded the MBR in memory and ran its boot code, which is GRUB's boot image. GRUB's boot image seeks for an hardcoded block list which should contain GRUB's core image. But you did not copy it on the USB stick. GRUB's core image is what displays the "grub rescue>" prompt if the next step fails. It searches for the grub directory in an hardcoded path location contained in its $prefix environment variable. Then it loads different files from this location in order to display the boot menu or boot an OS.

Next attempt. Use CD to install a new version of Knoppix 6.4.3 on the 'new' hard drive. Worked all OK. Boots OK. So somehow it told Grub and friends what to do?? It would be VERY nice to have whatever was done really documented.

As I write this I am using dd to replace the recently install /dev/sda2 with the known working /dev/sda2. Maybe grub will 'know' what to do. Or maybe things will just happen to be in the right place for grub to work??

If this fails. And I expect it may. The next step is to image copy the whole known working /dev/sda image. MBR, swap space, and working image as one large image and see if that works? Later I can probably use fdisk to make the unused hard disk available as some sort of partition?

It would be VERY nice to have an easy way to clone a working Linux to a new hard drive or memory stick.

With the MBR/DOS partition scheme, the easy way it to clone the whole drive, not just each partition. With GPT partition scheme, it may be a bit more complicated to adjust the partition table to the new size.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]