How do you clone a disk?

Jack F. Vogel jackv at turnkey.gryphon.COM
Sun Oct 15 03:24:10 AEST 1989


In article <363 at cs.columbia.edu> ji at cs.columbia.edu (John Ioannidis) writes:
>I have a bunch of PS/2-80's (and a lot more soon to arrive) with 330MB
>ESDI drives and I want to be able to have a master disk and clone every
>machine off that `master' disk.
 
>Here's what I tried:
 
[ minidisks attempt deleted....]

>Then I tried to figure out what the minor device numbers for the
>second disk should be. It turned out that they start at 32, with the
>32 being the entire disk, 33 being what was hd1 when the disk was the
>first disk of another machine etc. I guessed that if I were to 
>
>	# mknod /dev/hd32 b 3 32
>	# dd if=/dev/hd00 of=/dev/hd32 
>
>it would copy the entire first disk onto the second. Ha! It copied
>about 700 blocks and then gave me an I/O error.
 
You had the right idea, but there is a trick to getting this to work.
You see, there is a flag that must be set to allow one to write to
the zero partition or whole device. I suppose the rational is that
only programs like minidisks and maint should need to diddle with the
whole device. However, the superuser can override this normal restriction
using a suitable ioctl first.

What you need to do is write a little program that includes <sys/mdisk.h>
and then have it do the following:

		ioctl(1,HDIOWRT)

Wrap this in the usual error handling code, naturally. Then run this program
as root and redirect stdout to /dev/hd32. You will now be able to write the
whole device and your dd scheme above should work.

One comment on cloning systems this way, by doing so you are going to have
all the clones with the same site name, not really desireable in real
world situations. Perhaps in a lab or some such situation it wouldn't matter.
Also if you were comtemplating just using the bootstrap option to change
the name afterwards, I don't believe this will work, you will have a
conflict between the site name in nvram and the vtocs. But if this is what
you want to do, now you know how.

Good luck!

Disclaimer: This is in no way an official statement of Locus or IBM.


-- 
Jack F. Vogel			jackv at seas.ucla.edu
AIX Technical Support	              - or -
Locus Computing Corp.		jackv at ifs.umich.edu



More information about the Comp.unix.aix mailing list