[How To] 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 equipments is 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:

[email protected]# 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.

[email protected]# 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

[email protected]# metainit -f d10 1 1 c0t0d0s0
[email protected]# metainit -f d11 1 1 c0t0d0s1
[email protected]# metainit -f d13 1 1 c0t0d0s3
[email protected]# metainit -f d14 1 1 c0t0d0s4

HDD1

[email protected]# metainit -f d20 1 1 c0t1d0s0
[email protected]# metainit -f d21 1 1 c0t1d0s1
[email protected]# metainit -f d23 1 1 c0t1d0s3
[email protected]# metainit -f d24 1 1 c0t1d0s4

Initialize the mirrors.

[email protected]# metainit d0 -m d10
[email protected]# metainit d1 -m d11
[email protected]# metainit d3 -m d13
[email protected]# metainit d4 -m d14

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

[email protected]# 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 -

[email protected]# metaroot d0 (only use this for the root slice)

[email protected]# 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 -

[email protected]# 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

[email protected]# lockfs -fa
[email protected]# shutdown -y -g0 -i6

Attach the sub-mirrors to the mirror.

[email protected]# metattach d0 d20
[email protected]# metattach d1 d21
[email protected]# metattach d3 d23
[email protected]# metattach d4 d24

Monitor the progress of the syncing process

[email protected]# while true; do metastat | grep %; sleep 3; clear; done

Change the core dump directory

[email protected]# dumpadm (before changing)
Dump content: kernel pages
Dump device: /dev/dsk/c0t0d0s1 (swap)
Savecore directory: /var/crash/e3500
Savecore enabled: yes

[email protected]# 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

[email protected]# ls -l /dev/dsk/c0t?d0s0
lrwxrwxrwx 1 root root 41 Jun 5 16:49 /dev/dsk/c0t0d0s0 -> 
../..[email protected],[email protected][email protected],0:a
lrwxrwxrwx 1 root root 41 Jun 5 16:49 /dev/dsk/c0t1d0s0 -> 
../..[email protected],[email protected][email protected],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

[email protected]# eeprom "nvramrc=devalias rootdisk0 [email protected],[email protected][email protected],0:a
devalias rootdisk1 [email protected],[email protected][email protected],0:a"
[email protected]# eeprom "use-nvramrc?=true"
[email protected]# eeprom boot-device
boot-device=disk net
[email protected]# eeprom "boot-device=rootdisk0 rootdisk1 net"

Open Boot (ok) prompt

ok nvalias rootdisk0 [email protected],[email protected][email protected],0:a
ok nvalias rootdisk1 [email protected],[email protected][email protected],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

[email protected]# echo "set md:mirrored_root_flag=1" >> /etc/system

Readers who found this post were searching for:

  • svm mirror root disk
  • solaris mirror root disk
  • root mirroring in svm
  • svm root mirroring
  • svm cheat sheet
  • root mirroring in solaris 10
  • solaris 10 mirror root disk
  • root disk mirroring in solaris 10
  • solaris volume manager cheat sheet
  • solaris svm mirror root


Comments