September 26, 2006, 2:54 PM —
![]()
Send in your Unix questions today! |
See additional Unix tips and tricks
Solaris Volume Manager can make easy work of mirroring your root file system, but you have to use the right commands in the right sequence to make easy work of this task. In this week's column, we'll run through each of the commands required to mirror root and show how you can check on what is happening in each step.
First, let's set the stage for our example system. We have a new Solaris 10 installation on a system with two internal disks and a disk array that we'll set up later. Each of the internal disks has been partitioned identically.
Part Tag Flag Cylinders Size Blocks 0 root wm 1452 - 23167 29.92GB (21716/0/0) 62737524 1 var wm 23168 - 24567 1.93GB (1400/0/0) 4044600 2 backup wm 0 - 24619 33.92GB (24620/0/0) 71127180 3 swap wu 0 - 1451 2.00GB (1452/0/0) 4194828 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 reserved wm 24568 - 24619 73.35MB (52/0/0) 150228
The first thing we need to do is create the state database replicas. These are the data structures that store information about your volume configuration. We'll create multiple copies to ensure that we can recover if one copy becomes corrupt. You'll notice that we left a small partition for the state database replicas. We will now use the metadb -a -f command to create the replicas even if no database copies already exist. That -f option stands for "force".
# metadb -a -f c0t0d0s7 c0t1d0s7
In this example, we've only created two replicas, but you might want to create four or more to give you even better protection against potential problems. Database replicas can be created on dedicated slices or on slices that will become part of a concatenation or stripe.
To examine what we've done so far, we can use the metadb command without arguments:
# metadb
flags first blk block count
a u 16 8192 /dev/dsk/c0t0d0s7
a u 16 8192 /dev/dsk/c0t1d0s7
Now, we're going to use the metainit command to create a RAID 0 volume. Your choice of labels is flexible, but the convention we'll be using in this example is to name mirror components (or "submirrors") dx1 and dx2 and the mirrored device dx0 where "x" is a digit of 1 or more. Our root mirror will be d10, so our submirrors will be d11 and d12.
# metainit -f d11 1 1 c0t0d0s0 d11: Concat/Stripe is setup
The -f option is another "force" command. It tells metainit to create the submirror even if the slice contains a mounted file system.














