the system mangler

OS or root disk mirroring in Solaris 8

Yes, a blast from the past, but as I have to do this, and patch upgrades, for a client soon, I felt like refresh­ing my mem­ory. In the fol­low­ing exam­ple, I will be trun­cat­ing out­put to refer only to the disks that I am inter­ested in.

First, what are we work­ing with:

So we are work­ing with a Solaris 8 sys­tem, a Sun-Fire V440, end of life was 2007!

# uname -a
SunOS syd71 5.8 Generic_108528-27 sun4u sparc SUNW,Sun-Fire-V440

Any mir­ror­ing in place?

Use the unix df com­mand to list mounted filesys­tems; if the filesys­tem path con­tains either “md” or “vx” then some form of vol­ume man­age­ment is in use. In this case, there doesn’t appear to be any.

syd71# df -k
Filesystem            kbytes    used   avail capacity  Mounted on
/dev/dsk/c1t0d0s0 4034088 1695730 2298018 43% /
/proc                      0       0       0     0%    /proc
fd                         0       0       0     0%    /dev/fd
mnttab                     0       0       0     0%    /etc/mnttabc
/dev/dsk/c1t0d0s3    3008649 1498560 1449917    51%    /var
swap                 9056952      24 9056928     1%    /var/run
swap                 9057000      72 9056928     1%    /tmp
/dev/dsk/c6t600C0FF0000000000048CB0F02547800d0s0
                     70310728 53873312 15031204    79%    /data2
/dev/dsk/c6t600C0FF0000000000048CB4F7554FE00d0s0
                     70310728 2584548 66319968     4%    /data1

Best also check the swap file configuration:

syd71# swap -l
swapfile dev swaplo blocks free
/dev/dsk/c1t0d0s1 32,9 16 12289776 12289776

As you can see from the high­lighted line above, the swap par­ti­tion is only on the root disk, slice 1.

Is Sol­stice Disksuite installed?

We are going to use Solaris Vol­ume Man­ager (SVM; for­merly known as Online: DiskSuite, and later Sol­stice DiskSuite). This is a soft­ware pack­age for cre­at­ing, mod­i­fy­ing and con­trol­ling RAID-0 (con­cate­na­tion and stripe) vol­umes, RAID-1 (mir­ror) vol­umes, RAID 0+1 vol­umes, RAID 1+0 vol­umes, RAID-5 vol­umes, and soft par­ti­tions. It has been super­seded by ZFS in Solaris 10 onwards, and many users employ Ver­i­tas Vol­ume Man­ager (VxVM) as an alter­na­tive. It’s free, and was always a good option for root disk mir­ror­ing. From this point onwards I will refer to it as SVM as every­thing else is just too long to type!

syd71# pkginfo -i | grep SUNWmd
system      SUNWmdb        Modular Debugger
system      SUNWmdbdm      Modular Debugger Demo Source
system      SUNWmdbx       Modular Debugger (64-bit)
system      SUNWmdg        Solstice DiskSuite Tool
system      SUNWmdi        Sun Multipath I/O Drivers
system      SUNWmdiu       Sun Multipath I/O Drivers (usr)
system      SUNWmdix       Sun Multipath I/O Drivers (64-bit)
system      SUNWmdnr       Solstice DiskSuite Log Daemon Configuration Files
system      SUNWmdnu       Solstice DiskSuite Log Daemon
system      SUNWmdr        Solstice DiskSuite Drivers
system      SUNWmdu        Solstice DiskSuite Commands
system      SUNWmdx        Solstice DiskSuite Drivers(64-bit)

What ver­sion of SVM is it?

syd71# pkginfo SUNWmdr
system      SUNWmdr        Solstice DiskSuite Drivers
syd71# pkginfo -l SUNWmdr
   PKGINST:  SUNWmdr
      NAME:  Solstice DiskSuite Drivers
  CATEGORY:  system
      ARCH:  sparc
   VERSION:  4.2.1,REV=1999.12.03.10.00
   BASEDIR:  /
    VENDOR:  Sun Microsystems, Inc.
      DESC:  Solstice DiskSuite Drivers
    PSTAMP:  12/03/99-10:06:11
  INSTDATE:  Jun 27 2005 16:50
    VSTOCK:  258-6252-11
   HOTLINE:  Please contact your local service provider
    STATUS:  completely installed
     FILES:       28 installed pathnames
                   8 shared pathnames
                   8 directories
                  11 executables
                1027 blocks used (approx)

Ver­sion 4.2.1, which is prob­a­bly the lat­est avail­able for Solaris 8.

Do we have some free disks in order to set up mirroring?

Use the for­mat com­mand to list disks con­fig­ured on the system

# format
AVAILABLE DISK SELECTIONS:
       0. c1t0d0 <SUN36G cyl 24620 alt 2 hd 27 sec 107>
          /pci@1f,700000/scsi@2/sd@0,0
       1. c1t2d0 <SUN36G cyl 24620 alt 2 hd 27 sec 107>
          /pci@1f,700000/scsi@2/sd@2,0
       2. c1t3d0 <SUN36G cyl 24620 alt 2 hd 27 sec 107>
          /pci@1f,700000/scsi@2/sd@3,0
       3. c6t600C0FF0000000000048CB0F02547800d0 <SUN-StorEdge3510-327P cyl 34873 alt 2 hd 64 sec 64>
          /scsi_vhci/ssd@g600c0ff0000000000048cb0f02547800
       4. c6t600C0FF0000000000048CB4F7554FE00d0 <SUN-StorEdge3510-327P cyl 34873 alt 2 hd 64 sec 64>
          /scsi_vhci/ssd@g600c0ff0000000000048cb4f7554fe00
       5. c6t600C0FF0000000000048CB594EB54200d0 <SUN-StorEdge3510-327P cyl 35424 alt 2 hd 127 sec 127>
          /scsi_vhci/ssd@g600c0ff0000000000048cb594eb54200
Specify disk (enter its number):

The first disk, high­lighted on line 3, is the exist­ing root disk. The disks high­lighted on lines 5 and 7 are pos­si­ble mir­ror can­di­dates as their size and geom­e­try are iden­ti­cal to the exist­ing root disk.

Ver­ify that noth­ing is using the selected mir­ror disks by ini­tially exam­in­ing the par­ti­tion tables. On the root disk we see a selec­tion of specif­i­cally sized and labeled par­ti­tions (highlighted):

format> verify

Primary label contents:

Volume name = <        >
ascii name  = <SUN36G cyl 24620 alt 2 hd 27 sec 107>
pcyl        = 24622
ncyl        = 24620
acyl        =    2
nhead       =   27
nsect       =  107
Part      Tag    Flag     Cylinders         Size            Blocks
  0       root    wm       0 -  2835        3.91GB    (2836/0/0)   8193204
  1       swap    wu    2836 -  7089        5.86GB    (4254/0/0)  12289806
  2     backup    wm       0 - 24619       33.92GB    (24620/0/0) 71127180
  3        var    wm    7090 -  9216        2.93GB    (2127/0/0)   6144903
  4 unassigned    wm    9217 - 12052        3.91GB    (2836/0/0)   8193204
  5       home    wm   12053 - 24104       16.60GB    (12052/0/0) 34818228
  6 unassigned    wm       0                0         (0/0/0)            0
  7 unassigned    wm       0                0         (0/0/0)            0

Note the fol­low­ing about the root disk:

  1. Par­ti­tion 2 (line 15) rep­re­sents the entire disk and is rarely used, except for Ora­cle ASM
  2. Par­ti­tion 6 and 7 haven’t been used, and are avail­able for SVM meta databases
  3. The disk has 24619 usable cylin­ders, of which 24104 are used. The remain­der will be used for par­ti­tion 7 meta databases

And on the selected mir­ror disk, we see what appears to be a stan­dard “empty” partition:

Specify disk (enter its number)[0]: 1
selecting c1t2d0
[disk formatted]
format> verify

Primary label contents:

Volume name = <>
ascii name  =
pcyl        = 24622
ncyl        = 24620
acyl        =    2
nhead       =   27
nsect       =  107
Part      Tag    Flag     Cylinders         Size            Blocks
  0       root    wm       0 -    90      128.37MB    (91/0/0)      262899
  1       swap    wu      91 -   181      128.37MB    (91/0/0)      262899
  2     backup    wu       0 - 24619       33.92GB    (24620/0/0) 71127180
  3 unassigned    wm       0                0         (0/0/0)            0
  4 unassigned    wm       0                0         (0/0/0)            0
  5 unassigned    wm       0                0         (0/0/0)            0
  6        usr    wm     182 - 24619       33.67GB    (24438/0/0) 70601382
  7 unassigned    wm       0                0         (0/0/0)            0

And there is noth­ing unusual in the vfstab (i.e. no men­tions of the selected mir­ror disk being used in any way):

syd71# cat vfstab
#device         device          mount           FS      fsck    mount   mount
#to mount       to fsck         point           type    pass    at boot options
#
#/dev/dsk/c1d0s2 /dev/rdsk/c1d0s2 /usr          ufs     1       yes     -
fd      -       /dev/fd fd      -       no      -
/proc   -       /proc   proc    -       no      -
/dev/dsk/c1t0d0s1       -       -       swap    -       no      -
/dev/dsk/c1t0d0s0       /dev/rdsk/c1t0d0s0      /       ufs     1       no      logging
/dev/dsk/c1t0d0s3       /dev/rdsk/c1t0d0s3      /var    ufs     1       no      logging
/dev/dsk/c1t0d0s5       /dev/rdsk/c1t0d0s5      /apps   ufs     2       yes     logging
/dev/dsk/c1t0d0s4       /dev/rdsk/c1t0d0s4      /opt    ufs     2       yes     logging
/dev/dsk/c6t600C0FF0000000000048CB0F02547800d0s0        /dev/rdsk/c6t600C0FF0000000000048CB0F02547800d0s0       /data2  ufs     2       yes     logging,forcedir
ectio
/dev/dsk/c6t600C0FF0000000000048CB4F7554FE00d0s0        /dev/rdsk/c6t600C0FF0000000000048CB4F7554FE00d0s0       /data1  ufs     2       yes     logging,forcedir
ectio
/dev/dsk/c6t600C0FF0000000000048CB594EB54200d0s0        /dev/rdsk/c6t600C0FF0000000000048CB594EB54200d0s0       /data   ufs     2       yes     logging,forcedir
ectio
swap    -       /tmp    tmpfs   -       yes     -

Copy the par­ti­tion setup to the cho­sen mir­ror disk:

SVM is not a “whole disk” mir­ror­ing solu­tion, rather it works on a par­ti­tion by par­ti­tion basis. The tar­get par­ti­tion needs to exist before you set it up as a mir­ror. When attempt­ing to mir­ror a com­plete disk, the easy way to do this is to use the prtv­toc com­mand to print out the “vol­ume table of con­tents” and then write it to the tar­get disk:

prtvtoc /dev/rdsk/c1t0d0s2 | fmthard -s - /dev/rdsk/c1t2d0s2

Note 1: Be sure you get the drive names absolutely cor­rect, or you WILL destroy data! This will NOT ask you if you are sure, and there is NO WAY to undo this if you get it wrong!

Note 2: It’s a good idea to add the par­ti­tion for your SVM state data­bases before opt­ing the par­ti­tion table to the sec­ond disk. You will need this par­ti­tion in the next step.

Estab­lish the state databases:

These small data­bases con­tain all of the infor­ma­tion SVM needs to oper­ate, and the con­fig­u­ra­tion infor­ma­tion of the RAID vol­umes we create.

metadb -af -c 3 /dev/dsk/c1t0d0s7
metadb -af -c 3 /dev/dsk/c1t2d0s7

The para­me­ters above are:

  • –a: add databases
  • –f: force, basi­cally cre­ate the ini­tial databases
  • –c: the num­ber of copies in case of data­base cor­rup­tion. Addi­tion­ally SVM requires a major­ity of data­bases to be avail­able for cor­rect oper­a­tion; in an ideal world you would place addi­tional copies on a third drive. In real­ity most peo­ple con­fig­ure a para­me­ter to over­ride this requirement.

Cre­ate the RAID devices:

Next we ini­tialise the par­ti­tions which we want to mir­ror. From the root disk par­ti­tion table listed above, they are:

  • 0 — root
  • 1 — swap
  • 3 — var
  • 4 — opt
  • 5 — apps
When ini­tial­is­ing the par­ti­tions we assign them new SVM names, nor­mally in the for­mat dXX where XX are inte­gers. I have always used names like d11, d12 to rep­re­sent the disk par­ti­tions and then d10 to rep­re­sent the mir­ror itself. Firstly, the root disk side:
metainit -f d01 1  1 c1t0d0s0
metainit -f d11 1  1 c1t0d0s1
metainit -f d31 1  1 c1t0d0s3
metainit -f d41 1  1 c1t0d0s4
metainit -f d51 1  1 c1t0d0s5
Then the tar­get disk:
metainit -f d02 1  1 c1t2d0s0
metainit -f d12 1  1 c1t2d0s1
metainit -f d32 1  1 c1t2d0s3
metainit -f d42 1  1 c1t2d0s4
metainit -f d52 1  1 c1t2d0s5

The “1 1″ para­me­ter tells metainit to cre­ate 1 stripe with 1 partition.

Cre­ate the Mirrors:

Next we cre­ate the par­ent mir­ror devices, and attach the first side, the exist­ing root disk:

metainit d00 -m d01
metainit d10 -m d11
metainit d30 -m d31
metainit d40 -m d41
metainit d50 -m d51

We won’t add the sec­ond side of the mir­rors until we con­fig­ure the sys­tem to boot from mir­ror device, and per­form a reboot.

Con­fig­ure the root device:

Now that we have SVM mir­ror devices cre­ated, we need to con­fig­ure Solaris to access them cor­rectly. SVM cre­ates new device files under /dev/md/dsk and /dev/md/rdsk and unless the vfstab file is updated to point to these new device files, it will not be tak­ing advan­tage of the RAID con­fig­u­ra­tion. For the root par­ti­tion, the meta­root com­mand will per­form this task for you. If it only did that, it would be a pretty use­less com­mand, as you need to edit the vfstab file to update the other par­ti­tion entries as well. Luck­ily, it also updates the /etc/system ker­nel con­fig­u­ra­tion file with the nec­es­sary entries for SVM.

metaroot d00

Mod­ify vfstab for any other root disk mounts:

Now we need to update the vfstab entries for swap, var, opt, apps:

#device         device          mount           FS      fsck    mount   mount
#to mount       to fsck         point           type    pass    at boot options
#
#/dev/dsk/c1d0s2 /dev/rdsk/c1d0s2 /usr          ufs     1       yes     -
fd      -       /dev/fd fd      -       no      -
/proc   -       /proc   proc    -       no      -
/dev/md/dsk/d10       -       -       swap    -       no      -
/dev/md/dsk/d00       /dev/md/rdsk/d10      /       ufs     1       no      logging
/dev/md/dsk/d30       /dev/md/rdsk/d30      /var    ufs     1       no      logging
/dev/md/dsk/d50       /dev/md/rdsk/d50      /apps   ufs     2       yes     logging
/dev/md/dsk/d40       /dev/md/rdsk/d40      /opt    ufs     2       yes     logging
/dev/dsk/c6t600C0FF0000000000048CB0F02547800d0s0        /dev/rdsk/c6t600C0FF0000000000048CB0F02547800d0s0       /data2  ufs     2       yes     logging,forcedir
ectio
/dev/dsk/c6t600C0FF0000000000048CB4F7554FE00d0s0        /dev/rdsk/c6t600C0FF0000000000048CB4F7554FE00d0s0       /data1  ufs     2       yes     logging,forcedir
ectio
/dev/dsk/c6t600C0FF0000000000048CB594EB54200d0s0        /dev/rdsk/c6t600C0FF0000000000048CB594EB54200d0s0       /data   ufs     2       yes     logging,forcedir
ectio
swap    -       /tmp    tmpfs   -       yes     -

Lock the filesys­tem and shut­down the server:

To ensure that no fur­ther changes are made to the filesys­tems prior to boot­ing onto the new vol­umes, run the locks com­mand and reboot immediately.

# lockfs -fa
# /usr/sbin/shutdown -y -g0 -i0

While at the OBP prompt, con­fig­ure device aliases and the boot-device para­me­ter to auto­mat­i­cally boot from either drive in the event of a failure:

% show-disks

Pick your mir­rored disk from the list and then setup an alias:

% nvalias mirror ^y (that is a <control>-y to paste the device path)

Change your boot-device to first try the nor­mal disk alias, then use your mir­ror disk:

% setenv boot-device disk mirror
% reset-all

When the sys­tem is boot­ing, you will see errors relat­ing to SVM dri­vers as follows:

forceload of misc/md_trans failed
forceload of misc/md_raid failed
forceload of misc/md_hotspares failed

You can safely ignore these mes­sages, as they relate to SVM ele­ments which we haven’t cre­ated. If you wish, you can cre­ate a vol­ume for trans­ac­tion logs, a RAID 5 vol­ume, and define a disk as a hots­pare in order to remove these errors :-) Alter­na­tively, you could edit out those dri­ver ref­er­ences in the /etc/system file.

Attach the sec­ond mirrors:

metattach d00 d02
metattach d10 d12
metattach d30 d32
metattach d40 d42
metattach d50 d52

After doing the met attach, there will be lots of disk I/O while the mir­rors sync. You can use the meta­s­tat com­mand to view sta­tus of operation:

metastat | grep State | egrep -v Okay

Other things to fix, the Solaris boot block and the State Data­base Qurom:

In the event of a pri­mary disk fail­ure, the sys­tem should keep run­ning from the sec­ond drive. If you reboot though, the sys­tem may not start up as there is no “boot­block” on the sec­ond disk. Let’s fix that:

# installboot /usr/platform/`uname -i`/lib/fs/ufs/bootblk /dev/rdsk/c1t2d0s0

If you only have two mir­rored root disks (DiskSuite 4.2.1, Solaris 8), put this set­ting in your /etc/system:

set md:mirrored_root_flag=1

And you’re done.

 

0 comments
Submit comment