[Top][All Lists]

[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: jmh6
Subject: Re: How to boot a memory stick image of a hard drive?
Date: Sat, 15 Jul 2017 06:40:39 -0400 (EDT)
User-agent: Alpine 2.00 (DEB 1167 2008-08-23)

Hi Pascal,

Did this go to the list and the right thread?? I am not really sure how to make sure that is done correctly.

The whole image method worked as you predicted :) :). Thank you so much. Now I can really backup that system. That system is the one I am typing on now and which does DNS, email, serves webpages, static IP, etc. I ssh into it which is what I am doing now.

That system uses Grub 0.97. Swap starts at block 1 [512 byte blocks]. So I guess that what is in the MBR must find /dev/sda2 /boot/stage1? An older version of grub I assume. While the MBR hex is very similar to /boot/grub/Stage1 it is not identical which I would expect.

Next I am planning to try your grub 2.02 method. But what about swap starting at block 1. How big a space does there need to be at the beginning of the hard drive to accomodate grub?

So I will have Linux running with the to be activated hard drive also attached as /dev/sdb and the /dev/sda2 image on a memory stick.

I am assuming grub will not move disk partitions to make room for itself? So I guess I have to do that first?

I will mount /dev/sda2 somewhere convenient and follow what you have written below.

   After that, grub will be upgraded to 2.02 and the disk should boot.

For what it is worth. The ethernet port is different, but the kernel found it OK and I changed my script. I have a static IP for this box.

In some future brave moment I will attach this box to my internet feed and try to send it e-mail.

   Thanks so much !!

On Sat, 15 Jul 2017, Pascal Hambourg wrote:

[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.

Help-grub mailing list

reply via email to

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