FAQ: 
How to setup Disk Suite(SDS) Mirrors 
for Root, Swap, and data via the command line.


By Colin A. Bitterfield
SUN Microsystems, Inc.
Contact Me


Step 1: Setup proper slices

Suggestions for a 36GB drive, use the same partition table for both drives.
0 [root] 4GB
1 [swap] 4GB
2 [backup] -
3 /export/home 4GB
4 /data (Remainer)
5 open
6 open
7 [meta devices] (last 10MB of disl space)
Assumptions:
 Drive 0: c0t0d0
 Drive 1: c0t1d0

Step 2: Load OS w/SDS 4.2.1 & reboot.

Step 3: Initialize the Metadb database (w/2 replicas per drive) * See notes on database at end.

> metadb -a -f -c 2 c0t0d0s7 c0t1d0s7
> metadb

Step 4: Create Metadevices for one side of the mirror

[root]
> metainit -f d10 1 1 c0t0d0s0
> metainit d20 1 1 c0t1d0s0
> metainit d0 -m d10
> metaroot d0
[swap]
> metainit -f d11 1 1 c0t0d0s1
> metainit d21 1 1 c0t1d0s1
> metainit d1 -m d11
[export/home]
> metainit -f d12 1 1 c0t0d0s3
> metainit d22 1 1 c0t1d0s3
> metainit d2 -m d12
[data]
> metainit -f d13 1 1 c0t0d0s4
> metainit d23 1 1 c0t1d0s4
> metainit d3 -m d13
> lockfs -fa

Step 5: (Reboot the system)

Step 6: Attach the second half of the mirror

[root]
> metattach d0 d20
[swap]
> metattach d1 d21
[export/home]
> metattach d2 d22
[data]
> metattach d3 d23

Step 7. (Make sure that VFSTAB points to meta devices)

edit the file and make sure that the devices are something like:
Look for [Root], Swap, Home & Data. Pay attention to swap.
/dev/md/dsk/d0 /dev/md/rdsk/d0
Check for all slices.
#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      -
/dev/md/dsk/d2  /dev/md/rdsk/d2 /export/home    ufs     1       yes     -
/dev/md/dsk/d3  /dev/md/rdsk/d3 /data   ufs     1       yes     -
swap    -       /tmp    tmpfs   -       yes     -

Step 8. (Make sure that disk1 is bootable)

 example# installboot /usr/platform/`uname -i`/lib/fs/ufs/bootblk  /dev/rdsk/c0t1d0s0
 

Step 9. (NVRAM)

Make sure that boot-device = disk0,disk1
sentenv boot-device = disk0 disk1

All Done.

Q & A:

Q. How many replica's do I need ? What happens if I only have 2 disks
A. There is an issue with having only 2 disks. The system will remain operational until reboot. The system tries to get a quorum on the database replicas > 50%. This is not possible with only two disks. The system will reboot into single user mode and you will have to use metadb -d  /dev/dsk/c0t0d0s0 (or whatever the replica that is bad). Then reboot one more time. When you bring the mirror back on line you will need to re-create the  metadb.
 

Q. I have two disks that are different sizes. (i.e. (1) 18GB and (1) 36GB) what do I do ?
A. Make the partition sizes larger on disk 1. The following configuration was tested using this FAQ.
 

Disk 0 (4GB)
Current partition table (original):
Total disk cylinders available: 3880 + 2 (reserved cylinders)

Part      Tag    Flag     Cylinders        Size            Blocks
  0       root    wm     486 - 3377        2.98GB    (2892/0/0) 6246720
  1       swap    wu       0 -  485      512.58MB    (486/0/0)  1049760
  2     backup    wm       0 - 3879        4.00GB    (3880/0/0) 8380800
  3       home    wm    3378 - 3852      500.98MB    (475/0/0)  1026000
  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 alternates    wm    3870 - 3879       10.55MB    (10/0/0)     21600
 

Disk 1 (9GB)
Current partition table (unnamed):
Total disk cylinders available: 4924 + 2 (reserved cylinders)

Part      Tag    Flag     Cylinders        Size            Blocks
  0       root    wm     293 - 2045        3.00GB    (1753/0/0)  6295023
  1       swap    wu       0 -  292      513.75MB    (293/0/0)   1052163
  2     backup    wm       0 - 4923        8.43GB    (4924/0/0) 17682084
  3       home    wm    2046 - 2332      503.23MB    (287/0/0)   1030617
  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 alternates    wm    4913 - 4923       19.29MB    (11/0/0)      39501

Q. How do I know if a slice/mirror has failed?
A. metastat

Q. How "safe" is this procedure ? How well does it protect my system ?
A.

Q. I only have one controller in the system. What are the risks ?
A. If the controller fails, then none of the mirroring will help keep the system up. The controller becomes the "weakest link"

Q. How do I automate checking for slice errors?
A. This is directly from the manual. Create this script and activate it nightly from cron.

 #
 #ident "@(#)metacheck.sh   1.3     96/06/21 SMI"
 #
 # Copyright (c) 1992, 1993, 1994, 1995, 1996 by Sun Microsystems, Inc.
 #
  #
 # DiskSuite Commands
 #
 MDBIN=/usr/sbin
 METADB=${MDBIN}/metadb
 METAHS=${MDBIN}/metahs
 METASTAT=${MDBIN}/metastat
  #
 # System Commands
 #
 AWK=/usr/bin/awk
 DATE=/usr/bin/date
 MAILX=/usr/bin/mailx
 RM=/usr/bin/rm
  #
 # Initialization
 #
 eval=0
 date=`${DATE} '+%a %b %e %Y'`
 SDSTMP=/tmp/sdscheck.${$}
 ${RM} -f ${SDSTMP}
  MAILTO=${*:-"root"}   # default to root, or use arg list
  #
 # Check replicas for problems, capital letters in the flags indicate an error.
 #
 dbtrouble=`${METADB} | tail +2 | \
     ${AWK} '{ fl = substr($0,1,20); if (fl ~ /[A-Z]/) print $0 }'`
 if [ "${dbtrouble}" ]; then
         echo ""   >>${SDSTMP}
         echo "SDS replica problem report for ${date}" >>${SDSTMP}
         echo ""   >>${SDSTMP}
         echo "Database replicas are not active:"     >>${SDSTMP}
         echo ""   >>${SDSTMP}
         ${METADB} -i >>${SDSTMP}
         eval=1
 fi
  #
 # Check the metadevice state, if the state is not Okay, something is up.
 #
 mdtrouble=`${METASTAT} | \
     ${AWK} '/State:/ { if ( $2 != "Okay" ) print $0 }'`
 if [ "${mdtrouble}" ]; then
         echo ""  >>${SDSTMP}
         echo "SDS metadevice problem report for ${date}"  >>${SDSTMP}
         echo ""  >>${SDSTMP}
         echo "Metadevices are not Okay:"  >>${SDSTMP}
         echo ""  >>${SDSTMP}
         ${METASTAT} >>${SDSTMP}
         eval=1
 fi
  #
 # Check the hotspares to see if any have been used.
 #
 hstrouble=`${METAHS} -i | \
     ${AWK} ' /blocks/ { if ( $2 != "Available" ) print $0 }'`
 if [ "${hstrouble}" ]; then
         echo ""  >>${SDSTMP}
         echo "SDS Hot spares in use  ${date}"  >>${SDSTMP}
         echo ""  >>${SDSTMP}
         echo "Hot spares in usage:"  >>${SDSTMP}
         echo ""  >>${SDSTMP}
         ${METAHS} -i >>${SDSTMP}
         eval=1
 fi
 #
 # If any errors occurred, then mail the report to root, or whoever was called
 # out in the command line.
 #
 if [ ${eval} -ne 0 ]; then
         ${MAILX} -s "SDS problems ${date}" ${MAILTO} <${SDSTMP}
         ${RM} -f ${SDSTMP}
 fi
  exit ${eval}
1