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

Re: HOWTO->dd an MBR onto a HD



On Sun, Jan 27, 2002 at 01:02:10AM +1300, Cameron Kerr wrote:
> On Fri, 25 Jan 2002, David B Harris wrote:
> >> I assume that since I've copied all the filesystems from another
> >> running HD onto a new HD, that if I copy over the MBR that then I'll
> >> be able to boot and run the new HD as well.
> 
> I doubt it, unless the two hard disks and their partition layouts are
> _identical_. Better to just run lilo, giving it some parameters to
> override the command line.
> 
> >'dd if=/dev/hda of=/dev/hdb bs=512 count=1' should work. I think. :)
> 
> Nooo!!! This I've tried numerous times (and each time it preceeded the
> meltdown of my root filesystem).
> 
> The correct way to do this (I think this in the lilo docs), is
> dd if=wherever of=wherever bs=416 count=1
> 
> The 416 is the important bit, though I don't know why, since I'm no disk
> jockey. You may find reason in the tech.tex document in the lilo
> documentation.

The partition table uses the last 4*16=64 bytes and 2 bytes for the
signature (55AA) and you end up with 512-66 which is 446.  I'm not sure what
those other 30 bytes are, but I'm figuring that is where lilo stores
information about where the root partition is and where on the disk your
kernel resides. (I'm not about to look this up either :)

Anyway, dd'ing is not the way to go.  You should create a lilo.conf for it,
and use the various options to lilo to make sure it writes to the right
drive and knows where that drive will end up being booted at.

Check the man page for lilo, especially the -b -C -r -t and -v options.

If you can't get this to work, boot from a floppy after swapping the disks
and run lilo then.

hth,
Pete

-- 
Pete Ryland <pdr@pdr.cx>                   XMLDB: http://xmldb.sf.net/
Industrial design knows of no article more useful than the milk crate.



Reply to: