Thursday, August 23, 2007



Solaris 10 Raid 1 mirror

Prerquisites:
packages SUNWmdr SUNWmdx SUNWmdu

The Goal

Create a 2-way mirror made up of two submirror metadevices. A metadevice can be made out of an existing slice.

The idea is to create metadevices out of the existing slices, create the metadevices out of the spare slices, and join
the disks together to form the 2-way mirror that will be mounted instead of the raw disk slices.
The 2-way mirror metadevices are created as 1-way, with the second disk attached afterward.

Disk layout for both system disks

server1~# prtvtoc /dev/rdsk/c1t0d0s0 | tail -8
* Partition Tag Flags Sector Count Sector Mount Directory
0 2 00 0 20484288 20484287
1 7 00 20484288 20484288 40968575 /var
2 5 00 0 143349312 143349311
3 0 00 40968576 30528 40999103 {metadevice}
4 3 01 40999104 16393536 57392639
5 0 00 57392640 30528 57423167 {metadevice}
6 0 00 57423168 83911296 141334463 /opt
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.

Naming convention

Number the metadevices.Makes sure it makes sense, as opposed to arbitrary numbers.
Example

For root /
d0 - mirror metadevice to be mounted instead of c1t0d0s0
d10 - submirror metadevice on first disk, c1t0d0s0
d20 - submirror metadevice on second disk, c1t1d0s0

For /var
d1 - mirror metadevice to be mounted instead of c1t0d0s1
d11 - submirror metadevice on first disk, c1t0d0s1
d21 - submirror metadevice on second disk, c1t1d0s1

Make sure both disks are partitioned identically, and that partitions on the second disk have cr4eated with newfs.

Slices 3 and 5 will hold the meta databases. Create those as follows:
server1~ metadb -a -f c1t0d0s3 c1t0d0s5 c1t1d0s3 c1t1d0s5
Mirroring the root disk

Create a metadevice out of root on Disk 1:

server1~ metainit -f d10 1 1 c1t0d0s0

Create a metadevice for the root on Disk 2:

server1~ metainit d20 1 1 c1t1d0s0

Set up a one-way mirror of the root metadevice:

server1~ 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:

server1~ metaroot d0

Flush any UFS logging of the master filesystem:

server1~ lockfs -fa

Reboot:

server1~ shutdown -y -g0 -i6

Attach the second metadevice to the root metadevice to make it a 2-way mirror:

server1~ metattach d0 d20

Get the name of what is now the raw root disk, in case we need it later:

server1~ ls -l /dev/rdsk/c1t1d0s0

Mirroring the remaining system slices.

Create a metadevice from the original /var partition:

server1~ metainit -f d11 1 1 c0t0d0s1

Create a metadevice from the mirror /var partition:

server1~ metainit -f d21 1 1 c0t1d0s1

Create the /var mirror metadevice as a one-way mirror of the /var metadevice:

server1~ metainit d1 -m d11

/dev/md/dsk/d1 /dev/md/rdsk/d1 /var ufs 1 no logging

Reboot:

server1~ shutdown -y -g0 -i6

Attach the second submirrors to the mirrors to make 2-way mirrors:


server1~ metattach d1 d21

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.

References