open.itworld.com
  Search  
Security Home Page Security Webcasts Security White Papers Security Newsletters Security News Open Topics Careers ITworld Voices ITwhirled The Security site of ITworld.com

Unix Tip: Mirroring your root partition with Solaris Volume Manager

ITworld.com 09/26/2006

Sandra Henry-Stocker, ITworld.com

Digg!

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.

Next, we need to create a RAID 0 volume on the second drive. We do this with a very similar metainit command, but we don't need the "force" option this time:
# metainit d12 1 1 c0t1d0s0
d12: Concat/Stripe is setup
If we check with metastat at this point, we'll see that our two submirrors have now been created.
# metastat
d12: Concat/Stripe
    Size: 62737524 blocks (29 GB)
    Stripe 0:
        Device     Start Block  Dbase   Reloc
        c0t1d0s0          0     No      Yes

d11: Concat/Stripe
    Size: 62737524 blocks (29 GB)
    Stripe 0:
        Device     Start Block  Dbase   Reloc
        c0t0d0s0          0     No      Yes

Device Relocation Information:
Device   Reloc  Device ID
c0t1d0   Yes    id1,ssd@n20000004cfb583e8
c0t0d0   Yes    id1,ssd@n20000004cfb57cd7
The next thing we need to do is configure the first of these two mirror components as a "one-way" mirror. This d11 submirror will then be the primary submirror.
# metainit d10 -m d11
d10: Mirror is setup
Looking at metastat output again, we see that d11 is now listed as a submirror of d10:
# metastat
d10: Mirror
    Submirror 0: d11
      State: Okay
    Pass: 1
    Read option: roundrobin (default)
    Write option: parallel (default)
    Size: 62737524 blocks (29 GB)

d11: Submirror of d10
    State: Okay
    Size: 62737524 blocks (29 GB)
    Stripe 0:
        Device     Start Block  Dbase        State Reloc Hot Spare
        c0t0d0s0          0     No            Okay   Yes

d12: Concat/Stripe
    Size: 62737524 blocks (29 GB)
    Stripe 0:
        Device     Start Block  Dbase   Reloc
        c0t1d0s0          0     No      Yes

Device Relocation Information:
Device   Reloc  Device ID
c0t1d0   Yes    id1,ssd@n20000004cfb583e8
c0t0d0   Yes    id1,ssd@n20000004cfb57cd7
The metaroot command makes needed changes to your /etc/vfstab and /etc/system file. These changes will ensure that your system will mount the metadevices, not the underlying file systems, when it boots.
# metaroot d10
On Solaris 10, the changes required to the /etc/system files are minimal. See the line embedded between the two comments in the output below:
# tail /etc/system
*               set nautopush=32
*               set maxusers=40
*
*       To set a variable named 'debug' in the module named 'test_module'
*
*               set test_module:debug = 0x13

* Begin MDD root info (do not edit)
rootdev:/pseudo/md@0:0,10,blk
* End MDD root info (do not edit)
Changes to the vfstab file involve changing a line that looks like this:
/dev/dsk/c0t0d0s0    /dev/rdsk/c0t0d0s0    /     ufs    1     no    -
to look like this instead:
/dev/md/dsk/d10      /dev/md/rdsk/d10      /     ufs    1     no     -

Once you have gotten this far, it's time to reboot the system.

# init 6

When the system is back up, it is time to attach the second submirror to 
the mirror.  We do this with a metattach command.  Notice that this isn't 
spelled "metaattach".

# metattach d10 d12
d10: submirror d12 is attached

With the second submirrored attached, the system builds the mirror of the root
partition on the second submirror.  Since, in this example, our root partition 
contains /usr, this part of the process will seem to be moving very slowly.  We can,
however, check on our progress from time to time using this command: # metastat | grep -i sync State: Resyncing Resync in progress: 0 % done State: Resyncing Notice that, in this first check, we're 0% done. After a while, we will start
to see some progress: # metastat | grep -i sync State: Resyncing Resync in progress: 11 % done State: Resyncing It's going to take a while before significant progress has been made. Consider that a duplicate of the original slice is being created and that the status of our mirror is being updated as you monitor the slow progress. # metastat | grep -i sync State: Resyncing Resync in progress: 57 % done State: Resyncing At some point, we will try the metastat and grep command and notice that we're no longer getting output. At this point, the setup of the mirror is complete. # metastat | grep -i sync Next week, we will look at adding an alternate boot path so that we can boot off our mirrored drive as needed.

On this topic

 

Sandra Henry-Stocker has been administering Unix systems for more than 18 years. She describes herself as "USL" (Unix as a second language) but remembers enough English to write books and buy groceries. She currently works for TeleCommunication Systems, a wireless communications company, in Annapolis, Maryland, where no one else necessarily shares any of her opinions. She lives with her second family on a small farm on Maryland's Eastern Shore. Send comments and suggestions to bugfarm@gmail.com.




Sponsored Links

Sign up for a Microsoft Dynamics® CRM WEBCAST
Hear globally recognized leaders in customer strategy discuss the importance and evolution of CRM.
TRY NEW SUN SERVERS FREE for 60 Days!
Test The Latest Sun Servers In Your Environment BEFORE YOU BUY. Pay Nothing, Not Even Shipping.
Workflow Enabled Help Desk & IT Service Management
Automate service desk activities and integrate processes across IT. Learn more here.
Sign up for a FREE NETWORK RISK ASSESSMENT!
MORE THAN 70% OF NETWORKS ARE INFECTED by hidden Malware. Find out if your network is infected now!
Enterprise IP Goes Mobile
To maximize full productivity, companies must integrate their mobile applications with the IP network.
» Buy a link now

Advertisements
Sponsored links
Top 5 Reasons to Combine App Performance and Security
Locate Hidden Software on business PCs with this free tool
KODAK i1400 Series Scanners stand up to the challenge
Bring harmony to your mix of UNIX-Linux-Windows computing environments
 Home   Open source  Operating systems  Unix
www.itworld.com    open.itworld.com     security.itworld.com     smallbusiness.itworld.com
storage.itworld.com     utilitycomputing.itworld.com     wireless.itworld.com

 
Contact Us   About Us   Privacy Policy    Terms of Service   Reprints  

CIO   Computerworld   CSO   GamePro   Games.net   IDG Connect   IDG World Expo   Infoworld   ITworld   JavaWorld   LinuxWorld  MacUser   Macworld   Network World   PC World   Playlist  

Copyright © Computerworld, Inc. All rights reserved

Reproduction in whole or in part in any form or medium without express written permission of Computerworld Inc. is prohibited. Computerworld and Computerworld.com and the respective logos are trademarks of International Data Group Inc.