SUMMARY: Cloning disk with dd

From: sunmanagers freehome.ch <sunmanagers_at_freehome.ch>
Date: Tue Mar 11 2003 - 18:07:55 EST
Hi Sunmanagers

OK firstable I would like to thank to the following person which has given
me the right direction or information:

Zaigui Wang
Rene Occelli
Benoit Marechal
SANTHAKUMAR Siva
Sridhara
Hichael Morton
Hoff, Dustin-BLS CTR


Special thanks to Darren Dunham because he has not also given me the right
direction no he has taken time to explain each step and has also given me
importante backround information. This information is importante to
understand the way it must be done. Again many thanks.

Now below I try to explain and to summary all information (sorry about my
english is not my preffered language). I hope in the future people could use
the whole document to follow up and to understand how it works and how it
must be done:

First:
******

To clone a disk there are several possibility to do this. A possibility is
to use ufsdump and ufsrestore but it is based on filesystem and not on
blocksystem. If a whole disk must be cloned on my opinion it is better to
use the command dd (blocksystem). This command dd is easy to use and if the
information how it works is available also easy to understand what dd makes
and what will or must be done.

Second:
*******

On my system I have 3 Disks:

	c1t0d0	(Sourc Disk)
	c1t0d1	(Destination Disk)
	c1t2d0	(Working Disk)

To clone a Disk it is not absolutly neccesary that the Source Disk is not
active. Some people mentioned that they where logged in to a Sourc-Disk and
has given the dd command on this disk to clone this disk to another -not
active- disk. I tested this also and had no problems but on my system at the
moment there are absolutly minimun processes running. Anyway i worked not in
this way because I have a third disk which is allready setup up with solaris
8. I booted this disk (Working Disk) and all following commands explained
where given from this disk. It is also possible to boot the original install
CD from Solaris 8 with/in single user mode and set all commands in this
single user mode on the cdrom:

On "ok" prompt > boot cdrom -s

THIRD:
******

Ok we are going forward now. I'm logged in to the Working Diks and first I
controlled if the Source Disk or the Destination Disk are not active or
mounted. If it is so it is all prepared to use dd command but first any
notes to dd.

The dd command transfers all blocks from the Source Disk to the Destination
Disk and it means really all blocks (raw) information. It also included the
information like labels, layout of disk and defect table of the Source Disk.
As an example if the Source Disk has in the defect table of the disk the
information that block xy sector xy are not useable because of defect and
you transfer with dd the information to the Destination Disk this
information will be also transfered althought the block/sector on the
Destination Disk are "not" defect. If you would not use this and you think
this is not the way you would do it you should use ufsdump/ufsrestore!

All information from a disk like descriped above is stored in the slice 2
and is also known as backup. It means if you clone a disk it must be only
tranfered the information from slice 2 or from slice known as backup. To do
this use the following command from the Working Disk based on the above
information on our example it would be:

	# /usr/bin/dd if=/dev/rdsk/c1t0d0s2 of=/dev/rdsk/c1t0d1s2 bs=64k
	32454+1 records in
	32454+1 records out

The dd command has not a lot of output it means if it finished it will show
the in and our records which must be exactly the same number. The "if" means
= Source Disk and the "of" means the = Destination Disk. The "bs" means the
blocksize which will be used to transfer the blocks from Source to
Destination. On a 4 GB disk with bs=64 on a Ultra 1 it takes about 10 to 13
Minutes to transfer the whol slice 2. If you need to make the process faster
use a higher value like 128, ,256, 512, 1024 etc.

After the dd command has done his work you should check the Destination Disk
with the command fsck. On your example it would be:

	# /usr/sbin/fsck /dev/rdsk/c1t0d1s2

	** /dev/rdsk/c1t0d1s2
	** Last Mounted on /
	** Phase 1 - Check Blocks and Sizes
	** Phase 2 - Check Pathnames
	** Phase 3 - Check Connectivity
	** Phase 4 - Check Reference Counts
	** Phase 5 - Check Cyl groups
	8545 files, 196492 used, 256971 free (811 frags, 32020 blocks,  0.1%
fragmentation)

Now I thougth in the beginning " nice all done now booting the new disk and
all is OK " ! Now way, if you boot the Destination Disk you will receive a
lot of errors like "mount /tmp readonly", "mount point not found" etc. The
system will not boot correct and you will not be able to login.

What is not correct? It is easy....remeber with dd the whole and it means
really the whole information of the Source Disk will be transfered to the
Destination Disk. If a system boots the file "/etc/vfstab" has the
information about disk mountpoints etc. Yes correct this is the reason the
Destination Disk will not boot because the Destination Disk has the
information in "/etc/vfstab" from the Source Disk. Remeber Source Disk
c1t0d0 and Destination Disk c1t0d1. What must be done? Easy.....one solution
would be to put the Destination Disk out of the slot and put it in the slot
of the Source Disk and now the information in the "/etc/vfstab" are without
any changes correct. Another solution wourld be to mount the slice 0 = root
partition of Destination Disk, go with vi in the file "/etc/vfstab" and
correct the information. Below explained how it works. It mans first make a
mount point like disk1, mount the Destination Disk slice 0 to the mount
point, use vi to open /disk1/etc/vfstab and correct the information to the
right values in our example from c1t0d0 to c1t0d1.

	# mkdir /disk1
	# mount -F ufs -o rw /dev/dsk/c1t0d1s0 /disk1
	# vi /disk1/etc/vfstab

	--------- ------/disk1/etc/vfstab ---------------

	#device         device          mount           FS      fsck
mount   mount
	#to mount       to fsck         point           type    pass    at
boot options
	#
	#/dev/dsk/c1d0s2 /dev/rdsk/c1d0s2 /usr          ufs     1       yes
-
	fd      -       /dev/fd fd      -       no      -
	/proc   -       /proc   proc    -       no      -
	/dev/dsk/c1t0d1s3       -       -       swap    -       no      -
	/dev/dsk/c1t0d1s0       /dev/rdsk/c1t0d1s0      /       ufs     1
no
	-
	/dev/dsk/c1t0d1s1       /dev/rdsk/c1t0d1s1      /var    ufs     1
no
	-
	swap    -       /tmp    tmpfs   -       yes     -

	--------- ------/disk1/etc/vfstab ---------------

Now umount the mount point /disk1:

	# umount /disk1


Yipii jaije all is done now you could normal boot the Destination Disk.
Remeber that as standard there is no alias in ok prompt to boot the
destination disk. It could be done with the command:

nvalias "a_alias_name" "the_full_device_path"

Be carefull with the device path. If you don't know the exaclty device path
you could use the command devalias to find the device path like:

/sbus@1f,0/SUNW,soc@0,0/SUNW,pln@b0000000,753a58/ssd@0,0:a

This device path means c1t0d0 and if you would like to set an alias for
c1t0d1 it is:

/sbus@1f,0/SUNW,soc@0,0/SUNW,pln@b0000000,753a58/ssd@0,1:a

OK I hope I could help anybody which searchs about dd with this
documentation. I hope the documentation is clear and sorry if my english is
not so mmmhhhh you know is not my preffered language... :-)

Andrea
_______________________________________________
sunmanagers mailing list
sunmanagers@sunmanagers.org
http://www.sunmanagers.org/mailman/listinfo/sunmanagers
Received on Tue Mar 11 18:13:44 2003

This archive was generated by hypermail 2.1.8 : Thu Mar 03 2016 - 06:43:05 EST