Mirroring Internal disks with SVM

SVM is the Solaris Volume Manager, also once called solstice disksuite. SVM started out as a paid application to install on Solaris. It then moved to being the built in Solaris volume manager and finally it is now the “old” Solaris Volume Manager.

SVM uses the md driver to build a layer between the OS and the physical layout of the disks. When Solaris sends IOs to a disk under SVM control it will talk to the md driver, the md driver knows how to translate this into the appropriate IOs depending on the RAID configuration and the physical disk  layout.

For a disk or slice to be managed by SVM, it has to become a metadevice. Information about metadevices is kept in a metadb. You can create a metadevice from an entire disk, or from a slice (partition) of the disk. metadevice names begin with the letter “d” and then a number, e.g. d0, d100, d21, etc…

Once a disk/slice has been “initialized” using the metainit command, it then becomes a metadevice. What really happens is that SVM creates a new device under /dev/md for the new slice/disk, now SVM can use this metadevice to create a volume.

For example, if we want to create a mirrored volume using slice 0 on two disks, we need to create a metadevice for slice 0 on disk 1, create a metadevice for slice 0 on disk 2 and then create the mirrored volume (also called a metadevice) which contains two the metadevices from disk1 and disk2. In this case the metadevices referring to the slices are called submirrors.

Mirroring Two Internal Disks

Let’s explain how to mirror two internal disks on Solaris, using SVM ofcourse.

  • We have two disks c0t0d0 & c0t1d0
  • Each disk is configured with 4 slices
  • Slice 0 is root
  • Slice 1 is swap
  • Slice 3 is /u01
  • Slice 7 will be the metadb slice

First, we need the disk VTOCs to be identical, we can easily copy the partition table from the first disk to the second disk as follows;

prtvtoc /dev/rdsk/c0t0d0s2 | fmthard -s - /dev/dsk/c0t1d0s2

To create metadevices, we must have a metadb which keeps all the metadevice information. To create the metadb’s run the following commands;

metadb -f -a -c 3 c0t0d0s7
metadb -a -c 3 c0t1d0s7

Now to create the metadevices that will be used as sub-mirrors;

metainit -f d10 1 1 c0t0d0s0
metainit -f d11 1 1 c0t0d0s1
metainit -f d13 1 1 c0t0d0s3
metainit d20 1 1 c0t1d0s0
metainit d21 1 1 c0t1d0s1
metainit d23 1 1 c0t1d0s3

Create the mirror metadevices;

When running the metainit command to create the mirror metadevice, you must specify at least one sub-mirror. When you specify just one sub-mirror, this is called a half-way mirror, and generally this the proper way to do it. Let’s go ahead and do that. The syntax is;

metainit -m <mirror> <submirror>

So in our example;

metainit -m d0 d10
metainit -m d1 d11
metainit -m d3 d13

This will create the half-way mirror d0,d1, and d3, with the first submirror being d10, d11, and d13 respectively.

We now need to add the second sub-mirror with the metattach command; this will start a synchronization job which copies data from the first sub-mirror to the second one.

But, there is a little catch, the system is still using the slices using their ctd names, if we create the mirror device now, we will have SVM start sycing data and at the same time Solaris writing/reading the slice, bypassing the md driver. This is quite unstable and will definitely corrupt our data or cause a system panic. So we need Solaris to stop “talking “to the slice and start “talking” to the mirror metadeivces d0, d1 and d3.

Now to do this for the root slice is different than for other slices.

For non-root slices the easy way is to edit the  /etc/vfstab line that refers to the slice so that;

/dev/dsk becomes /dev/md/dsk
/dev/rdsk becomes /dev/md/rdsk
c0t0d0sx becomes dx; where x is the slice number if you are following the naming convention.

DO NOT EDIT THE ROOT SLICE ENTRY IN /etc/vfstab

For the root slice, we need to run the metaroot command, this command will perform the required edits in vfstab and will additionally edit /etc/system to allow for proper booting from the d0 device. To do this just run the following command;

metaroot d0

Finally, reboot the system to get Solaris to start using the metedevices instead of the slices.

Once the system has rebooted, we attach the sub-mirrors use the metattach command. The syntax is as follows;

metattach <mirror> <sub-mirror>

So in our example, we run the following commands;

metattach d0 d10
metattach d1 d12
metattach d3 d13

With the above three commands, you have now succesfully mirrored the internal disks. You may use the metastat command to view the results of your actions 🙂

 


Notes

Mirroring empty slices

What happens if you specify both submirrors when creating mirror metadevice?

Well in this case SVM will still create the mirror, but will warn you that the data may not be identical. This should ONLY be used when the sub-mirrors have no data, I use this to save time on synchronizing empty metedevices. But I also immediately follow it with a newfs to the the mirror device, this assures that both have identical data.

Taking /u01 from our example above, if this slice is empty I would run the following command when creating the mirror device, this way I will save the time SVM will take to mirror the empty slices.

metainit -m d3 d13 d23

Leave a comment