The following describes a procedure for using the DiskSuite component of the Solaris Easy Access Server to set up mirroring of the main system disk of a Solaris 8 machine. It presumes that both drives are of identical geometry, that the operating system is already installed on c0t0d0, and that the spare disk is c0t1d0, a common setup for a 2-disk Sun machine.
Conventions
Code or configuration data: Colored
Root shell prompt: acadie#
Installing the software
The DiskSuite product is found on the Solaris 8 "2-of-2" CD. Minimally, the drivers (SUNWmdr and SUNWmdx) and command line tools (SUNWmdu) need to be installed. The "metatool" GUI is in the optional SUNWmdg package. Reboot after installing the packages.
acadie# pkgadd -d /cdrom/cdrom0/Solaris_8/EA/products/DiskSuite_4.2.1/sparc/Packages \ SUNWmdr SUNWmdx SUNWmdu SUNWmdg acadie# shutdown -y -g0 -i6
Example disk layout for both system disks
Part Tag Flag Cylinders Size Blocks 0 root wm 0 - 344 256.05MB (345/0/0) 524400 1 swap wu 345 - 1034 512.11MB (690/0/0) 1048800 2 backup wm 0 - 11696 8.48GB (11697/0/0) 17779440 3 unassigned wm 1035 - 1036 1.48MB (2/0/0) 3040 4 var wm 1037 - 2416 1.00GB (1380/0/0) 2097600 5 unassigned wm 2417 - 2418 1.48MB (2/0/0) 3040 6 usr wm 2419 - 10316 5.72GB (7898/0/0) 12004960 7 home wm 10317 - 11696 1.00GB (1380/0/0) 2097600
A minimum of two metadatabases must be on each system disk, preferably spread over more than one disk slice. They only need to be 1MB or so - the minimum allocation of 1 cylinder should do.
The concept
In Disksuite, a 2-way mirror is a metadevice, itself made up of two submirror metadevices. A metadevice can be made out of an existing slice -- non-destructively, unlike some other software-RAID tools out there. The technique is to create metadevices out of the existing slices, create the companion metadevices out of the spare slices, and join these together to form the 2-way mirrors that will be mounted instead of the raw disk slices. The 2-way mirror metadevices are actually first created as 1-way, with the second disk attached afterward.
Naming convention
You can number your metadevices however you wish. Personally, I like something that makes a little bit of sense, as opposed to arbitrary numbers. I use the following convention:
d0 - mirror metadevice to be mounted instead of c0t0d0s0 d10 - submirror metadevice on first disk, c0t0d0s0 d20 - submirror metadevice on second disk, c0t1d0s0 d4 - mirror metadevice to be mounted instead of c0t0d0s4 d14 - submirror metadevice on first disk, c0t0d0s4 d24 - submirror metadevice on second disk, c0t1d0s4 Etc.
Make sure both disks are partitioned identically, and that partitions on the mirror disk have been newfs'ed.
Slices 3 and 5 will hold the meta databases. Create those as follows:
acadie# metadb -a -f c0t0d0s3 c0t0d0s5 c0t1d0s3 c0t1d0s5
Mirroring the root disk
Create a metadevice out of the original root:
acadie# metainit -f d10 1 1 c0t0d0s0
Create a metadevice for the root mirror:
acadie# metainit d20 1 1 c0t1d0s0
Set up a one-way mirror of the root metadevice:
acadie# metainit d0 -m d10
Configure the system to boot the root filesystem from the metadevice, using the "metaroot" command. This will make the necessary changes to /etc/vfstab and /etc/system:
acadie# metaroot d0
Flush any UFS logging of the master filesystem:
acadie# lockfs -fa
Reboot:
acadie# shutdown -y -g0 -i6
Attach the second metadevice to the root metadevice to make it a 2-way mirror:
acadie# metattach d0 d20
Get the name of what is now the raw root disk, in case we need it later:
acadie# ls -l /dev/rdsk/c0t1d0s0
Mirroring the remaining system slices
Create a metadevice from the original /var partition:
acadie# metainit -f d14 1 1 c0t0d0s4
Create a metadevice from the mirror /var/partition:
acadie# metainit -f d24 1 1 c0t1d0s4
Create the /var mirror metadevice as a one-way mirror of the /var metadevice:
acadie# metainit d4 -m d14
Create metadevices for the /usr mirror:
acadie# metainit -f d16 1 1 c0t0d0s6 acadie# metainit -f d26 1 1 c0t1d0s6
Create a mirror metadevice for /usr:
acadie# metainit d6 -m d16
Create metadevices for the /home mirror:
acadie# metainit -f d17 1 1 c0t0d0s7 acadie# metainit -f d27 1 1 c0t1d0s7
Create a mirror metadevice for /home:
acadie# metainit d7 -m d17
Edit /etc/vfstab so that the new metadevices will be mounted:
/dev/md/dsk/d4 /dev/md/rdsk/d4 /var ufs 1 no logging /dev/md/dsk/d6 /dev/md/rdsk/d6 /usr ufs 1 no logging /dev/md/dsk/d7 /dev/md/rdsk/d7 /home ufs 1 no logging
Reboot:
acadie# shutdown -y -g0 -i6
Attach the second submirrors to the mirrors to make 2-way mirrors:
acadie# metattach d4 d24 acadie# metattach d6 d26 acadie# metattach d7 d27
Wait until disk activity stops before doing much else. DiskSuite's progress of syncing the second drive to the first can be monitored using the "metastat" command. Though it is not strictly necessary, it is a good idea to reboot after this, if only to make sure there are no problems and that the box will indeed come back up.
For what it's worth, I learned everything I needed to know about using DiskSuite from Sun's documentation, in particular, Chapter 2 "Creating DiskSuite Objects" of the User's Guide. I highly recommend reading it to understand the principles behind the above steps.