Disk images

Gary W. Swearingen garys at opusnet.com
Thu Apr 13 23:49:43 UTC 2006


Daniel Carrera <daniel.carrera at zmsl.com> writes:

> Gary W. Swearingen wrote:
>>>* Use 'dd' to copy the bootloader.
>> Remember that the bootloader(s) are not all in the MBR.
>
> I didn't know that. But surely this should work:
>
> dd if=/dev/hda of=/dev/hdb count=1 bs=446 # copy boot loader in MBR
> mount /dev/hda /mnt/source && mount /dev/hdb /mnt/dest
> cp --archive /mnt/source/* /mnt/dest/
>
> What am I missing?

Well, first off, your "cp" will miss top-level ".*" files.

If I assume that your new disk's partition tables are good for that
disk, then that sequence won't copy the parts of the grub bootloader
in the second sector, etc.  I've forgotten if lilo does that too or
restricts itself to the MBR and /boot/, in which case your sequence
should work OK, if my assumption is right.

A case, which you should be aware of, but I doubt if you have, is that
an IBM/MSFT DOS-style MBR tries to boot from a bootloader in a primary
partition's boot code (partition boot record and more).

>> Anyway, maybe try this:
>> Boot the "new" PC off some CD and run a script which does this:
>>    1) zero first hd track, at least (probably unnecessary)
>>       dd if=/dev/zero of=/dev/hda bs=16k count=1
>
> The first *track*? Why that much? That would include much more than the MBR. Plus, it would include the partition
> table. What am I missing?

Probably nothing, here.  It just feels good to wipe the first track
where grub and viruses tend to hide, but I guess it's unneeded.  Some
even feel better getting the first partition's first track in the same
command.  Of course, wiping the MBR record tells fdisk/parted to
initialize things.  I've assumed that you want to create a new
partition table; I don't know if any old one is correct.

> I'm willing to try anything you suggest. I'd just like to understand the solution.
>
>>    2) partition the hd (with "parted")
>>    3) make filesystem(s) (with "parted", "mkfs", or whatever)
>>    4) connect to OEM server and "untar" files into filesystem(s).
>
> Ok. I'm sure this part can work.
>
>>    5) Run bootloader creation software like grub or lilo.
>
> Could you expand on this bit? I thought grub didn't need an additional step (unlike lilo). With grub you just edit the
> .conf file and you're set.

I don't care to expand much; it's got a decent "info" file.  But the
grub bootloader code must be installed some time, and, unless maybe
copying the whole first track will do the job (seems like it might),
you have to run "grub" to install the bootloader to the MBR, second
sector, and wherever.  Both grub and lilo allow you to make _some_
changes to the bootloader behavior by editing files in the /boot
filesystem.

>> On a BSD OS, you'd avoid the historically problematical (and I suspect
>> slower) "tar" and use "dump" and "restore", which probably have Linux
>> versions, but tar should do the job.
>
> I didn't know that dump was better than tar. I've always used tar.

Note the "BSD".  I only know it to be true on FreeBSD and only while
the GNU tar didn't support some BSD stuff. (I'm unsure if that's been
fixed, but FreeBSD now uses a different tar that works.)  "dump" uses
a "raw"er format, something like filesystem disk blocks instead of
whole files.

>> You might be able to fit a copy of the tarball on the CD and avoid
>> the network bit.  And make the script run at boot.  Or use a second
>> CD.
>
> I could burn it onto a DVD and then it'd definitely fit.

The CD can as small as 2.88 MB (and maybe 1.44) before addition of
the stuff to be installed.  (Some?) Bootable CDs are basically a
copy of a big floppy plus other stuff.


BTW, neither your MUA or mine is wrapping your long lines, despite
your "format=flowed" header.  Maybe we need to set a "flow_width"
setting somewhere.





More information about the ubuntu-users mailing list