Tuesday, 13 August 2013

One of the greatest feature in Solaris is that really handy disk management software which is inbuilt and it’s called Solaris Volume Manager (SVM). All the devices which are under SVM called as "Metadevices". In earlier versions of Solaris, it was called as Disksuite or Solstice Disksuite. I’m sure every system admin would gone through SVM from their beginning of UNIX. In this article, we are going to discussing about root mirroring steps in detailed manner. 

Reason for Root Mirroring : - Mainly we are using for redundancy purpose, If anyone of the root disk is failed, we can retrieve the server with other mirrored disk.

Prerequisites :- 2 disks (Root disk, Mirror disk) and required State Database Replicas

State Database (Replicas):
  • It stores information on disk about the state of SVM. 
  • Replica is a multiple copies of the database which provides redundancy and must be distributed across multiple disks. 
  • SVM uses algorithm to determine that majority of the state database replicas are available before any of them are considered valid. Algorithm is n/2+1 (*n – no of disks). For example, assume you have 2 disks, then 2/2+1=2 replicas, Atleast we required 2 replicas for valid information.
  • Normally we used to create a meta replicas on 7th slice of the disks, its doesn't matter of slice, but atleast we required minimum size of slice. 
Let we can start the Root mirroring with below mentioned disks.
  •  c1t0d0 Consider as Root Disk which is currently mounted on the system.
  •  c1t1d0 Consider as Mirrored Disk which we are going to mirror with root disk.
  • bash-3.00# df -h |grep -i /dev/dsk/
    /dev/dsk/c1t0d0s0 6.9G 3.6G 3.2G 53% /
    /dev/dsk/c1t0d0s3 492M 1.0M 442M 1% /export/home
    bash-3.00#
    bash-3.00#
    bash-3.00# echo|format
    Searching for disks...done
    
    AVAILABLE DISK SELECTIONS:
           0. c1t0d0 
              /pci@0,0/pci15ad,1976@10/sd@0,0
           1. c1t1d0 
              /pci@0,0/pci15ad,1976@10/sd@1,0
    Specify disk (enter its number): Specify disk (enter its number):
    bash-3.00#
Checking the Volume table of Contents to confirm whether we have free slices for meta replicas.
    bash-3.00# prtvtoc /dev/rdsk/c1t0d0s2
    * /dev/rdsk/c1t0d0s2 partition map
    *
    * Dimensions:
    *     512 bytes/sector
    *      32 sectors/track
    *     128 tracks/cylinder
    *    4096 sectors/cylinder
    *    4094 cylinders
    *    4092 accessible cylinders
    *
    * Flags:
    *   1: unmountable
    *  10: read-only
    *
    * Unallocated space:
    *       First     Sector    Last
    *       Sector     Count    Sector
    *           0   2125824   2125823
    *
    *                          First     Sector    Last
    * Partition  Tag  Flags    Sector     Count    Sector  Mount Directory
           0      2    00    2125824  14635008  16760831   /
           1      3    01       4096   1048576   1052671
           2      5    00          0  16760832  16760831
           3      8    00    1052672    819200   1871871   /export/home
           7      0    00    1871872    253952   2125823
           8      1    01          0      4096      4095
    bash-3.00#
above output shows all our root disk slices, here we can confirm whether we have slices for replicas. we can use the 7th slice for State database replicas. If not, you have to allocate a new slice for replicas.Now we have to do the same slices structure for mirror disk as well. for this we can use prtvtoc and fmthard command to copy the VTOC table to other disks.
    bash-3.00# prtvtoc /dev/rdsk/c1t0d0s2|fmthard -s - /dev/rdsk/c1t1d0s2
    fmthard: Partition 2 specifies the full disk and is not equal
    full size of disk.  The full disk capacity is 16764928 sectors.
    fmthard:  New volume table of contents now in place.
    bash-3.00#
Here we can execute "prtvtoc /dev/rdsk/c1t1d0s2" command to see both the disks (root disk and mirror disk) are having same slice structure. Creating a Meta replicas on 7th slice of root disk and mirror disk (c1t0d0s7, c1t1d0s7)
    bash-3.00# metadb -afc3 c1t0d0s7 c1t1d0s7
    bash-3.00#
    bash-3.00# metadb
            flags           first blk       block count
         a        u         16              8192            /dev/dsk/c1t0d0s7
         a        u         8208            8192            /dev/dsk/c1t0d0s7
         a        u         16400           8192            /dev/dsk/c1t0d0s7
         a        u         16              8192            /dev/dsk/c1t1d0s7
         a        u         8208            8192            /dev/dsk/c1t1d0s7
         a        u         16400           8192            /dev/dsk/c1t1d0s7
    bash-3.00#
          -a  Attach a new database device.
          -f   Create a fresh copy of state database.
          -c  Specifies the number of replicas to be placed on each device.

Create a Metadevice as d10 with using disk c1t0d0s0 and create d20 with using disk c1t1d0s0 and do the oneway mirror d0 and activate the root metadevice. Before that we have to take the copy of /etc/vfstab and /etc/system file, since metaroot will make changes on those files as shown below.
bash-3.00# metainit d10 1 1 c1t0d0s0
metainit: unixrock: c1t0d0s0: is mounted on /

bash-3.00# metainit -f d10 1 1 c1t0d0s0
d10: Concat/Stripe is setup
bash-3.00# metainit d20 1 1 c1t1d0s0
d20: Concat/Stripe is setup
bash-3.00# metainit d0 -m d10
d0: Mirror is setup
bash-3.00#
bash-3.00# cp /etc/vfstab /etc/vfstab_backup
bash-3.00# cp /etc/system /etc/system_backup
bash-3.00#
bash-3.00# metaroot d0
bash-3.00#
bash-3.00# cat /etc/vfstab|grep -i md
/dev/md/dsk/d0  /dev/md/rdsk/d0 /       ufs     1       no      -
bash-3.00#
bash-3.00# cat /etc/system|grep -v "*"
rootdev:/pseudo/md@0:0,0,blk
bash-3.00#
bash-3.00# lockfs -f
bash-3.00#
bash-3.00# init 6
updating /platform/i86pc/boot_archive
  • Since c1t0d0s0 is currently mounted on /, so we have to use -f option to create a metadevice. 
  • "lockfs" indicates that change or report file system locks, -f option is superfluous when specifying a lock.
After the server reboot, we have to attach the mirrored disk d20 metadevice.
bash-3.00# uname -a
SunOS unixrock 5.10 Generic_142910-17 i86pc i386 i86pc
bash-3.00# df -h /
Filesystem             size   used  avail capacity  Mounted on
/dev/md/dsk/d0         6.9G   3.6G   3.2G    53%    /
bash-3.00#
bash-3.00# metastat -c
d0               m  7.0GB d10
    d10          s  7.0GB c1t0d0s0
d20              s  7.0GB c1t1d0s0
bash-3.00#
bash-3.00# metattach d0 d20
d0: submirror d20 is attached
bash-3.00# metastat |grep state:
bash-3.00# metastat -c
d0               m  7.0GB d10 d20 (resync-3%)
    d10          s  7.0GB c1t0d0s0
    d20          s  7.0GB c1t1d0s0
bash-3.00# 
After Synchronization is completed, we should have a valid root mirroring. Now we can create a metadevice on other mounts (/export/home and swap) other then root FS as shown below.
bash-3.00# df -h |grep -i export
/dev/dsk/c1t0d0s3      492M   1.0M   442M     1%    /export/home
bash-3.00#
bash-3.00# metainit -f d13 1 1 c1t0d0s3
d13: Concat/Stripe is setup
bash-3.00# metainit d23 1 1 c1t1d0s3
d23: Concat/Stripe is setup
bash-3.00# metainit d3 -m d13
d3: Mirror is setup
bash-3.00# metattach d3 d23
d3: submirror d23 is attached
bash-3.00#
bash-3.00# metastat -c
d3               m  400MB d13 d23
    d13          s  400MB c1t0d0s3
    d23          s  400MB c1t1d0s3
d0               m  7.0GB d10 d20
    d10          s  7.0GB c1t0d0s0
    d20          s  7.0GB c1t1d0s0
bash-3.00#
bash-3.00# swap -l
swapfile             dev  swaplo blocks   free
/dev/dsk/c1t0d0s1   30,1       8 1048568 1048568
bash-3.00#
bash-3.00# metainit -f d11 1 1 c1t0d0s1
d11: Concat/Stripe is setup
bash-3.00# metainit d21 1 1 c1t1d0s1
d21: Concat/Stripe is setup
bash-3.00#
bash-3.00# metainit d1 -m d11
d1: Mirror is setup
bash-3.00# metattach d1 d21
d1: submirror d21 is attached
bash-3.00#
bash-3.00# metastat -c
d1               m  512MB d11 d21
    d11          s  512MB c1t0d0s1
    d21          s  512MB c1t1d0s1
d3               m  400MB d13 d23
    d13          s  400MB c1t0d0s3
    d23          s  400MB c1t1d0s3
d0               m  7.0GB d10 d20
    d10          s  7.0GB c1t0d0s0
    d20          s  7.0GB c1t1d0s0
bash-3.00#
Now we are successfully created metadevices for /, /export/home, swap. we have to manually update the details in /etc/vfstab and reboot the server to take effect.
bash-3.00# grep -i md /etc/vfstab
/dev/md/dsk/d1  -       -       swap    -       no      -
/dev/md/dsk/d0  /dev/md/rdsk/d0 /       ufs     1       no      -
/dev/md/dsk/d3  /dev/md/rdsk/d3 /export/home    ufs     2       yes     -
bash-3.00#
bash-3.00#
bash-3.00# df -h |grep -i md
/dev/md/dsk/d0         6.9G   3.6G   3.2G    53%    /
/dev/md/dsk/d3         492M   1.0M   442M     1%    /export/home
bash-3.00# swap -l
swapfile             dev  swaplo blocks   free
/dev/md/dsk/d1      85,1       8 1048568 1048568
bash-3.00#
Thanks for reading this post. Please provide your feedback and suggestions are highly recommended to improve the excellence of my articles