Duping a Solaris Disk “Disk-to-Disk Copy”

SUMMARY

We need to make a complete and accurate copy of all data and binaries on one system to another system so that we can test without messing up the original. So we will mount a second drive in the original system… build the second drive to match block-for-block the original… and then mount these and use ufsdump to copy data to the secondary.

Finally, we will remount the new drive in the new system.. run ’sys-unconfig’ and rebuild the physical interfaces completely. :P

There is a command dd (disk duplicate) but that only works if you are 100% successful in getting the partitions correctly build. And if you are doing that… which this document covers, you may as well go ahead and run ufsdump/ufsrecover. ufsdump and recover is more reliable

ADDING THE NEW DISK

# Drop to the ok> prompt
 init 0
# Turn off auto-boot
 setenv auto-boot? false
# reset the NVRAM - or the scsi probe freaks
 reset-all
# Probe the SCSI and make a note
{1} ok probe-scsi
 Target 0
 Unit 0 Disk SEAGATE ST373307LSUN72G 0507
# Add the new disk and probe the scsi again
{1} ok probe-scsi
 Target 0
 Unit 0 Disk SEAGATE ST373307LSUN72G 0507
 Target 1
 Unit 0 Disk FUJITSU MAP3735N SUN72G 0401

EXAMINE THE ORIGINAL
Our original disk c1t0d0 will not be altered, but we need to take a look the partition table because in the next section we will be building an exact duplicate.

# Note - if your drives do not appear in format then
 drvconfig
 disks
servername:/root $format
 Searching for disks...done
AVAILABLE DISK SELECTIONS:
 0. c1t0d0 SUN72G cyl 14087 alt 2 hd 24 sec 424
 /pci@1c,600000/scsi@2/sd@0,0
 Specify disk (enter its number): 0
 selecting c1t0d0
format> part
 [SNIP]
partition> print
 [SNIP]
Current partition table (original):
 Total disk cylinders available: 14087 + 2 (reserved cylinders)
Part Tag Flag Cylinders Size Blocks
 0 root wm 413 - 901 2.37GB (489/0/0) 4976064
 1 swap wu 0 - 412 2.00GB (413/0/0) 4202688
 2 backup wm 0 - 14086 68.35GB (14087/0/0) 143349312
 3 unassigned wm 0 0 (0/0/0) 0
 4 unassigned wm 0 0 (0/0/0) 0
 5 unassigned wm 0 0 (0/0/0) 0
 6 unassigned wm 0 0 (0/0/0) 0
 7 home wm 902 - 14085 63.97GB (13184/0/0) 134160384

FORMATTING THE NEW DISK
In the last section you found the partition table (directly above) in the next section you need to format the new drive to be exactly the same…. I have some tips embedded in the text of the screen output… read carefully and for all that is holy make sure you are operating on the proper disk.

Servername:/root $format
 Searching for disks...done
AVAILABLE DISK SELECTIONS:
 0. c1t0d0 SUN72G cyl 14087 alt 2 hd 24 sec 424
 /pci@1c,600000/scsi@2/sd@0,0
 1. c1t1d0 SUN72G cyl 14087 alt 2 hd 24 sec 424
 /pci@1c,600000/scsi@2/sd@1,0
 Specify disk (enter its number): 1
 selecting c1t1d0
 [SNIP]
format> part
 [SNIP]
partition> print
 Current partition table (original):
 Total disk cylinders available: 14087 + 2 (reserved cylinders)
Part Tag Flag Cylinders Size Blocks
 0 root wm 104 - 197 467.00MB (94/0/0) 956544
 1 swap wu 0 - 103 516.50MB (104/0/0) 1058304
 2 backup wm 0 - 14086 68.35GB (14087/0/0) 143349312
 3 unassigned wm 0 0 (0/0/0) 0
 4 unassigned wm 0 0 (0/0/0) 0
 5 unassigned wm 198 - 405 1.01GB (208/0/0) 2116608
 6 usr wm 406 - 1818 6.86GB (1413/0/0) 14378688
 7 home wm 1819 - 14086 59.53GB (12268/0/0) 124839168

CAUTION – Do not mess with #2 Backup… it represents a total disk space from block 1 until the end…. leave it alone…

Now let’s go after partition #0. When you examine it on the new system it is way too small… we can to address this by altering the start and stop block… and also by letting the tag role back to unassigned. So Starting = 413 and there are 489 blocks (489c) found in the original’s block column.

partition> 0
 Part Tag Flag Cylinders Size Blocks
 0 root wm 104 - 197 467.00MB (94/0/0) 956544
Enter partition id tag[root]: unassigned
 Enter partition permission flags[wm]:
 Enter new starting cyl[104]: 413
 Enter partition size[956544b, 94c, 506e, 467.00mb, 0.00gb]: 489c
 partition> pr
 Current partition table (unnamed):
 Total disk cylinders available: 14087 + 2 (reserved cylinders)
Part Tag Flag Cylinders Size Blocks
 0 unassigned wm 413 - 901 2.37GB (489/0/0) 4976064
 1 swap wu 0 - 103 516.50MB (104/0/0) 1058304
 2 backup wm 0 - 14086 68.35GB (14087/0/0) 143349312
 3 unassigned wm 0 0 (0/0/0) 0
 4 unassigned wm 0 0 (0/0/0) 0
 5 unassigned wm 198 - 405 1.01GB (208/0/0) 2116608
 6 usr wm 406 - 1818 6.86GB (1413/0/0) 14378688
 7 home wm 1819 - 14086 59.53GB (12268/0/0) 124839168

Keep altering (except for backup) until you they are the same…. except with unassigned tag for everything (except for backup). Like this:

Part Tag Flag Cylinders Size Blocks
 0 unassigned wm 413 - 901 2.37GB (489/0/0) 4976064
 1 unassigned wu 0 - 412 2.00GB (413/0/0) 4202688
 2 backup wm 0 - 14086 68.35GB (14087/0/0) 143349312
 3 unassigned wm 0 0 (0/0/0) 0
 4 unassigned wm 0 0 (0/0/0) 0
 5 unassigned wm 0 0 (0/0/0) 0
 6 unassigned wm 0 0 (0/0/0) 0
 7 unassigned wm 902 - 14085 63.97GB (13184/0/0) 134160384

Now label the disk. This is important as this is what saves the partition table in your VTOC (Virtual Table Of Contents). It’s also always recommended to do the labeling part twice to be certain that the VTOC gets saved.

partition> label
 Ready to label disk, continue? y
 partition> q
 format> q

BUILD THE FILE SYSTEM
Swap does not need a file system, so in our case only /home and / need newfs, fsck and a mount.

newfs -v /dev/rdsk/c1t1d0s0
newfs -v /dev/rdsk/c1t1d0s7
fsck -y /dev/rdsk/c1t1d0s0
fsck -y /dev/rdsk/c1t1d0s7
mkdir /root2 /home2
mount /dev/dsk/c1t1d0s0 /root2
mount /dev/dsk/c1t1d0s7 /home2

COPY THE DISKS
It’s not that easy to get dd to make copies, especially if the disks are physically different. We just went through an exercise to ensure that the drives are the same size, but this process should also allow us to move data to another ‘differently’ sized drive… but I haven’t tested this.

cd /
ufsdump 0f - /dev/rdsk/c1t0d0s0 | (cd /root2; ufsrestore xf -)
ufsdump 0f - /dev/rdsk/c1t0d0s7 | (cd /home2; ufsrestore xf -)

You’ll probably notice that you have to specify the source as a block device (rdsk) and not the directory. Go with it… that’s how this works. Anyway, give this some time to run…. we are almost done

# Not 100% necessary, but an FSCK is a good idea now

fsck -y /dev/rdsk/c1t1d0s0
 fsck -y /dev/rdsk/c1t1d0s7

MAKING IT BOOTABLE

installboot /usr/platform/`uname -i`/lib/fs/ufs/bootblk /dev/rdsk/c1t1d0s0
# Transfer it to the new system and boot to the ok> the boot -rv
ok> probe-scsi
 ok> devalias
 ok> setenv boot-device disk0
 ok> boot -rv

# Run sys-unconfig and when it reboots configure it with a unique system name and IP.

sys-unconfig

The rest is just following the screen on reboot.

About Jay Farschman - Jay currently works as a Senior Systems Administrator for an asset management company in Colorado where he works with companies that produce hardware, telecommunications software and financial services.  Jay previously owned a consulting company and provided training and consulting services for three Fortune 500 companies and numerous small businesses where he leveraged Linux to provided exceptional value.

One thought on “Duping a Solaris Disk “Disk-to-Disk Copy”

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>