Wednesday, January 21, 2009

Mirroring disks with DiskSuite

The following example shows how to mirror two disks--c0t0d0 with c0t1d0--using Solstice DiskSuite 4.2.1 on Solaris 8. Please read the excellent Admin's Guide to Solstice Disk Suite for more information.

The current partition table of c0t0d0:

Part Tag Flag Cylinders Size Blocks
0 root wm 0 - 812 400.15MB (813/0/0) 819504
1 swap wu 813 - 1333 256.43MB (521/0/0) 525168
2 backup wm 0 - 17659 8.49GB (17660/0/0) 17801280
3 unassigned wm 1334 - 1354 10.34MB (21/0/0) 21168
4 var wm 1355 - 8522 3.45GB (7168/0/0) 7225344
5 usr wm 8523 - 14764 3.00GB (6242/0/0) 6291936
6 unassigned wm 14765 - 16845 1.00GB (2081/0/0) 2097648
7 home wm 16846 - 17658 400.15MB (813/0/0) 819504

1. Copy the partition table of the first disk to its mirror.
# prtvtoc /dev/rdsk/c0t0d0s2 | fmthard -s - /dev/rdsk/c0t1d0s2

2. Create at least 2 DiskSuite state database replicas on each disk. A state database replica contains DiskSuite configuration and state information.
# metadb -a -f -c2 /dev/dsk/c0t0d0s3 /dev/dsk/c0t1d0s3

Description of metadb flags:
-a -- adding
-f -- force (needed the first time creating databases)
-c2 -- create 2 databases in each slice

3. Mirror the root slice.
# metainit -f d10 1 1 c0t0d0s0
# metainit -f d20 1 1 c0t1d0s0
# metainit d0 -m d10
# metaroot d0
(Use this command only on the root slice!)

4. Mirror the swap slice.
# metainit -f d11 1 1 c0t0d0s1
# metainit -f d21 1 1 c0t1d0s1
# metainit d1 -m d11

5. Mirror the var slice.
# metainit -f d14 1 1 c0t0d0s4
# metainit -f d24 1 1 c0t1d0s4
# metainit d4 -m d14


6. Mirror the usr slice.
# metainit -f d15 1 1 c0t0d0s5
# metainit -f d25 1 1 c0t1d0s5
# metainit d5 -m d15


7. Mirror the opt slice.
# metainit -f d16 1 1 c0t0d0s6
# metainit -f d26 1 1 c0t1d0s6
# metainit d6 -m d16


8. Mirror the home slice.
# metainit -f d17 1 1 c0t0d0s7
# metainit -f d27 1 1 c0t1d0s7
# metainit d7 -m d17


Run metastat metadevice for information on a metadevice. If you wish to delete a metadevice, run metaclear metadevice.

9. Update /etc/vfstab to mount the mirrors after boot.

/etc/vfstab before changes:

#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/c0t0d0s1 - - swap - no -
/dev/md/dsk/d30 /dev/md/rdsk/d30 / ufs 1 no logging
/dev/dsk/c0t0d0s5 /dev/rdsk/c0t0d0s5 /usr ufs 1 no ro,logging
/dev/dsk/c0t0d0s4 /dev/rdsk/c0t0d0s4 /var ufs 1 no nosuid,logging
/dev/dsk/c0t0d0s7 /dev/rdsk/c0t0d0s7 /home ufs 2 yes nosuid,logging
/dev/dsk/c0t0d0s6 /dev/rdsk/c0t0d0s6 /opt ufs 2 yes nosuid,logging
swap - /tmp tmpfs - yes -


/etc/vfstab after changes:

#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/md/dsk/d1 - - swap - no -
/dev/md/dsk/d0 /dev/md/rdsk/d0 / ufs 1 no logging
/dev/md/dsk/d5 /dev/md/rdsk/d5 /usr ufs 1 no ro,logging
/dev/md/dsk/d4 /dev/md/rdsk/d4 /var ufs 1 no nosuid,logging
/dev/md/dsk/d7 /dev/md/rdsk/d7 /home ufs 2 yes nosuid,logging
/dev/md/dsk/d6 /dev/md/rdsk/d6 /opt ufs 2 yes nosuid,logging
swap - /tmp tmpfs - yes -


10. Reboot the system.
# lockfs -fa
# init 6


11. Attach the second submirror to the mirror. This will cause the data from the boot disk to be synchronized with the mirrored drive.

# metattach d0 d20
# metattach d1 d21
# metattach d4 d24
# metattach d5 d25
# metattach d6 d26
# metattach d7 d27

You can run metastat to track the mirroring progress.

12. Change the crash dump device to the DiskSuite swap metadevice (Solaris 7 and later).
# dumpadm -d `swap -l | tail -1 | awk '{print $1}'`

13. Determine the physical device path of the mirror disk.
$ ls -l /dev/dsk/c0t1d0s0
lrwxrwxrwx 1 root root 50 Jan 16 10:20 /dev/rdsk/c0t1d0s0 -> ../../devices/pci@1f,0/pci@1,1/ide@3/dad@1,0:a

Replace the major name (e.g. dad) in the physical device path with disk when creating the device alias below.

14. Create a mirror device alias for the mirror disk:
# eeprom "nvramrc=devalias mirror /pci@1f,0/pci@1,1/ide@3/disk@1,0:a"
# eeprom "use-nvramrc?=true"

You can also configure the device alias from the Open Boot (ok) prompt:
nvalias mirror /pci@1f,0/pci@1,1/ide@3/disk@1,0:a

You may want to add the mirror device alias to the boot-device Open Boot parameter in case of a problem with the standard boot device.

Example:

# eeprom boot-device
boot-device=disk net

In case of a problem with the disk device alias, the system will attempt to boot from the mirror device alias and then the network with the following change.
# eeprom "boot-device=disk mirror net"

From the Open Boot prompt, type boot mirror to boot from the mirror disk.

15. If you only have two internal disks (i.e. the boot disk and mirror disk), consider adding the following parameter to /etc/system to bypass the SVM/DiskSuite "quorum" rule.

set md:mirrored_root_flag = 1

Without this parameter, the system will not boot in multiuser mode if half or fewer of its state database replicas are available.

More information:
http://www.sun.com/blueprints/0402/solstice.pdf

DiskSuite mirror shell script

The following shell script performs all steps of the boot disk mirroring process above, except for rebooting the system.

I do not recommend using the shell script unless you understand the above procedure and shell script logic. If you do use the shell script, it is essential that you correctly configure the first six variables.

Download the script.

DiskSuite mirror shell script (deprecated)

I use the following shell script to mirror the $BOOT_DISK and $MIRROR_DISK after manually creating the DiskSuite state database replicas. If slice 0 is not your root slice, make sure to modify the script so that the $METAROOT command is executed on the root slice. Be sure to comment out slices that you would not like mirrored. The script assumes that DiskSuite database replicas are located on slice 3, so this slice is initally commented out.

#!/bin/sh

BOOT_DISK=c1t2d0
MIRROR_DISK=c1t1d0
METAINIT=/usr/sbin/metainit
METAROOT=/usr/sbin/metaroot

# Slice 0 (root slice)
$METAINIT -f d10 1 1 ${BOOT_DISK}s0
$METAINIT -f d20 1 1 ${MIRROR_DISK}s0
$METAINIT d30 -m d10
$METAROOT d30

# Slice 1
$METAINIT -f d11 1 1 ${BOOT_DISK}s1
$METAINIT -f d21 1 1 ${MIRROR_DISK}s1
$METAINIT d31 -m d11

# Slice 2 will not be mirrored (represents entire disk)

# Slice 3 is initially commented out; slice containing DiskSuite
# database replicas in our environment
#$METAINIT -f d13 1 1 ${BOOT_DISK}s3
#$METAINIT -f d23 1 1 ${MIRROR_DISK}s3
#$METAINIT d33 -m d13

# Slice 4
$METAINIT -f d14 1 1 ${BOOT_DISK}s4
$METAINIT -f d24 1 1 ${MIRROR_DISK}s4
$METAINIT d34 -m d14

# Slice 5
$METAINIT -f d15 1 1 ${BOOT_DISK}s5
$METAINIT -f d25 1 1 ${MIRROR_DISK}s5
$METAINIT d35 -m d15

# Slice 6
$METAINIT -f d16 1 1 ${BOOT_DISK}s6
$METAINIT -f d26 1 1 ${MIRROR_DISK}s6
$METAINIT d36 -m d16

# Slice 7
$METAINIT -f d17 1 1 ${BOOT_DISK}s7
$METAINIT -f d27 1 1 ${MIRROR_DISK}s7
$METAINIT d37 -m d17

Readers who read this page, also read:




Bookmark and Share My Zimbio http://www.wikio.com

0 comments: