[Techtalk] dd confusion
Travis Casey
efindel at earthlink.net
Wed Nov 5 19:24:25 EST 2003
On Wednesday 05 November 2003 14:28, Carla Schroder wrote:
> Two dd questions:
>
> I want to copy all the contents of hda to hdb. Does hdb have to be the
> exact same disk geometry?
Well... maybe. :-)
Using dd to copy all of one disk to another, as with
dd if=/dev/hda of=/dev/hdb
copies *everything* on the disk... including, for some disk types and some
operating systems, data which tells what the disk geometry is. That's
where the traditional warning to "only do this when the disk geometry is
the same" comes from.
Now, since you're talking about hdX, I'm assuming you're using IDE drives...
and unfortunately, I don't know if IDE drives store information about
geometry in an area Linux can write to. They might keep it on the disk in
a writable area, or it might be in firmware, or it might be on the disk in
a reserved area the drive electronics won't let the OS write to. Honestly,
I don't know. I don't think Linux itself stores information about the disk
geometry on the disk -- some other Unix variants do, though.
If you have a "sacrificial disk" you could use, you could try it and see
what happens... but I'll assume you don't. (If you do, though, try it and
let us know! :-)
Instead of copying the whole disk, you can do things a bit more slowly by
copying a partition at a time. Create the partitions you need on the new
drive, making sure that they're as big as or bigger than the partitions on
the old drive, and then do:
dd if=/dev/hda1 of=/dev/hdb1
dd if=/dev/hda2 of=/dev/hdb2
... and so on, until you've done all the partitions. This way, you won't
overwrite the partition table, the boot sector, or anything else vital to
the operation of the disk itself.
The disadvantage here is that you'll likely lose some space... if a
partition is bigger on hdb than it was on hda, the dd'ed file system won't
know that. You may be able to use utilities to grow the filesystem(s),
though.
Personally, rather than doing that sort of raw copying, I usually like to
copy things on a filesystem level. Partition hdb as desired, create the
filesystems on it, then use "cp -ax" to copy the partitions. This has the
advantages that you can rearrange things if you wish, and since it's
operating on the filesystem level, if you have a filesystem that isn't very
full, you're not copying a lot of "empty space".
> If hda is a bootable disk, will hdb also be bootable?
For a whole disk "dd if=/dev/hda of=/dev/hdb" copy, yes, if you it (a) works
and (b) you then rearrange things so hdb is now hda.
For a partition-by-partition dd, maybe, but probably not. This won't copy
the "bootable" flag in the partition table, and files may not be at the
same exact disk offsets on the new disk. Rerunning the lilo or grub or
silo or whatever setup will likely be needed. Same for copying things on a
filesystem level, as I describe above.
--
--
|\ _,,,---,,_ Travis S. Casey <efindel at earthlink.net>
ZZzz /,`.-'`' -. ;-;;,_ No one agrees with me. Not even me.
|,4- ) )-,_..;\ ( `'-'
'---''(_/--' `-'\_)
More information about the Techtalk
mailing list