Mirror Root Disk with Solaris Volume Manager (SVM)

As UNIX Systems Administrators, we want our systems up and running – 24 hours a day, 7 days a week. Though this could be achievable with the UNIX Operating Systems, we cannot set aside the fact that our hardware equipment are prone to wear and tear. One notable point of failure if our root or boot disks. Once it dies out – our only way is thru our backup and restore it. But there is another way that we could prevent this – if we have a spare identical disk as our root disk. We can have a redundant machine by having our root disks mirrored and make our system much reliable and omit this point of failure. Here are the step-by-step how to guide in mirroring our root/boot disk using the Solaris Volume Manager (SVM).

Assumptions:

HDD0 - c0t0d0 (Primary disk)
HDD1 - c0t1d0

Partitions of HDD0:

/ - c0t0d0s0
swap - c0t0d0s1
backup - c0t0d0s2 (this represents the whole disk)
/var - c0t0d0s3
/opt - c0t0d0s4
unassigned - c0t0d0s7 (this would be used to store our metadbs)

Make HDD1’s partition table the same as HDD0:

root@solaris# prtvtoc /dev/rdsk/c0t0d0s2 | fmthard -s - /dev/rdsk/c0t1d0s2

Create at least 2 (tough i prefer 3 which i will be using) state databases on each disk.

root@solaris# metadb -afc 3 c0t0d0s7 c0t1d0s7

whereas:

-a = add state database
-f = force (this is needed for HDD0 which is mounted)
-c # = number of state databases in each slice

Initialize each disk.

HDD0

root@solaris# metainit -f d10 1 1 c0t0d0s0
root@solaris# metainit -f d11 1 1 c0t0d0s1
root@solaris# metainit -f d13 1 1 c0t0d0s3
root@solaris# metainit -f d14 1 1 c0t0d0s4

HDD1

root@solaris# metainit -f d20 1 1 c0t1d0s0
root@solaris# metainit -f d21 1 1 c0t1d0s1
root@solaris# metainit -f d23 1 1 c0t1d0s3
root@solaris# metainit -f d24 1 1 c0t1d0s4

Initialize the mirrors.

root@solaris# metainit d0 -m d10
root@solaris# metainit d1 -m d11
root@solaris# metainit d3 -m d13
root@solaris# metainit d4 -m d14

Metaroot and editing of /etc/vfstab to boot to our mirror.

root@solaris# cat /etc/vfstab (to check vfstab before metaroot)

#device device mount FS fsck mount mount
#to mount to fsck point type pass at boot options
#
fd - /dev/fd fd - no -
/proc - /proc proc - no -
/dev/dsk/c0t0d0s1 - - swap - no -
/dev/dsk/c0t0d0s0 /dev/rdsk/c0t0d0s0 / ufs 1 no -
/dev/dsk/c0t0d0s3 /dev/rdsk/c0t0d0s3 /var ufs 1 no -
/dev/dsk/c0t0d0s4 /dev/rdsk/c0t0d0s4 /opt ufs 1 no -
/devices - /devices devfs - no -
ctfs - /system/contract ctfs - no -
objfs - /system/object objfs - no -
swap - /tmp tmpfs - yes -

root@solaris# metaroot d0 (only use this for the root slice)

root@solaris# cat /etc/vfstab (to check vfstab after metaroot)
#device device mount FS fsck mount mount
#to mount to fsck point type pass at boot options
#
fd - /dev/fd fd - no -
/proc - /proc proc - no -
/dev/dsk/c0t0d0s1 - - swap - no -
/dev/md/dsk/d0 /dev/md/rdsk/d0 / ufs 1 no -
/dev/dsk/c0t0d0s3 /dev/rdsk/c0t0d0s3 /var ufs 1 no -
/dev/dsk/c0t0d0s4 /dev/rdsk/c0t0d0s4 /opt ufs 1 no -
/devices - /devices devfs - no -
ctfs - /system/contract ctfs - no -
objfs - /system/object objfs - no -
swap - /tmp tmpfs - yes -

root@solaris# vi /etc/vfstab (to edit the vfstab to boot to our mirror)
#device device mount FS fsck mount mount
#to mount to fsck point type pass at boot options
#
fd - /dev/fd fd - no -
/proc - /proc proc - no -
/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 /var ufs 1 no -
/dev/md/dsk/d4 /dev/md/rdsk/d4 /opt ufs 1 no -
/devices - /devices devfs - no -
ctfs - /system/contract ctfs - no -
objfs - /system/object objfs - no -
swap - /tmp tmpfs - yes -

Reboot the system

root@solaris# lockfs -fa
root@solaris# shutdown -y -g0 -i6

Attach the sub-mirrors to the mirror.

root@solaris# metattach d0 d20
root@solaris# metattach d1 d21
root@solaris# metattach d3 d23
root@solaris# metattach d4 d24

Monitor the progress of the syncing process

root@solaris# while true; do metastat | grep %; sleep 3; clear; done

Change the core dump directory

root@solaris# dumpadm (before changing)
Dump content: kernel pages
Dump device: /dev/dsk/c0t0d0s1 (swap)
Savecore directory: /var/crash/e3500
Savecore enabled: yes

root@solaris# dumpadm -d swap
Dump content: kernel pages
Dump device: /dev/md/dsk/d1 (swap)
Savecore directory: /var/crash/e250
Savecore enabled: yes

Update the boot-device parameter to boot to either HDD0 or HDD1

Check the physical device path of both disk

root@solaris# ls -l /dev/dsk/c0t?d0s0
lrwxrwxrwx 1 root root 41 Jun 5 16:49 /dev/dsk/c0t0d0s0 -> 
../../devices/pci@1f,4000/scsi@3/sd@0,0:a
lrwxrwxrwx 1 root root 41 Jun 5 16:49 /dev/dsk/c0t1d0s0 -> 
../../devices/pci@1f,4000/scsi@3/sd@1,0:a

Change the major name (in this case “sd”) to disk for the boot-device. Setting the boot-device can be done on the Solaris or the Open Boot (ok) prompt.

Solaris

root@solaris# eeprom "nvramrc=devalias rootdisk0 /pci@1f,4000/scsi@3/disk@0,0:a
devalias rootdisk1 /pci@1f,4000/scsi@3/disk@1,0:a"
root@solaris# eeprom "use-nvramrc?=true"
root@solaris# eeprom boot-device
boot-device=disk net
root@solaris# eeprom "boot-device=rootdisk0 rootdisk1 net"

Open Boot (ok) prompt

ok nvalias rootdisk0 /pci@1f,4000/scsi@3/disk@0,0:a
ok nvalias rootdisk1 /pci@1f,4000/scsi@3/disk@1,0:a
ok printenv boot-device
boot-device disk net
ok setenv boot-device rootdisk0 rootdisk1 net

Lastly, because of the behavior of SVM (the rule half +1 state database, so we could boot into the OS) we need to add a parameter on /etc/system

root@solaris# echo "set md:mirrored_root_flag=1" >> /etc/system