Like many others, I am a big fan of live upgrade when it comes to upgrading/patching solaris. This post is for the system admins who still wants to use the traditional method of patching for whatever reason they want to.
The setup
The example system we will be using has SVM based mirrored root.
Preparation
1. Check the health of all metadatabase replicas (metadbs) and SVM metadevices.
# metastat # metastat -c # metadb -i
2. Check the current boot device.
# prtconf -vp | grep -i boot bootpath: '/pci@0,0/pci15ad,1976@10/sd@0,0:a' boot-device: 'pci@0,0/pci15ad,1976@10/sd@0,0:a disk0:a'
3. Confirm the boot disk and mirror disk from the format output.
# 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):
As seen above, here the root disk is c1t0d0 and the mirror rootdisk is c1t1d0.
4. Backup important command outputs.
# df -h # netstat -nrv # ifconfig -a # metastat -c # metastat # swap -l # cat /etc/vfstab # uname -a # showrev -p
5. Install the bootblock in the root mirror disk c1t1d0, to make sure it is bootable.
# installboot /usr/platform/`uname -i`/lib/fs/ufs/bootblk /dev/rdsk/c1t1d0
6. Detach and delete the SVM mirrors.
# metadetach -f d10 d12 ## detach root mirror # metadetach -f d20 d22 ## detach swap mirror # metaclear d12 # metaclear d22
7. Clear the metadatabase replicas from the root mirror disk.
# metadb -d /dev/dsk/c1t1d0sX ## X is the slice on which metadb was created on root mirror disk
8. Mount the mirror root disk and replace the SVM related entries in the /etc/vfstab and /etc/system to prevent SVM to start on boot from the root mirror disk.
# mount /dev/dsk/c1t1d0 /mnt # vi /etc/fstab #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/c1t1d0s1 - - swap - no - /dev/dsk/c1t1d0s0 /dev/rdsk/c1t1d0s0 / ufs 1 no - /devices - /devices devfs - no - sharefs - /etc/dfs/sharetab sharefs - no - ctfs - /system/contract ctfs - no - objfs - /system/object objfs - no - swap - /tmp tmpfs - yes -
Remove the entries related to SVM from the /etc/system file.
# vi /etc/system * Begin MDD root info (do not edit) rootdev:/pseudo/md@0:0,10,blk * End MDD root info (do not edit) set md:mirrored_root_flag = 1
9. Confirm if the server boots from the un-encapsulated SVM root mirror disk.
# init 0 ok> boot rootmirror (root mirror is a devalias at OBP)
Patch installation
1. Boot the server into single user mode.
# init 0 ok> boot -s
2. Unzip the patchset bundle and look for the passcode.
# unzip -q sol10_Recommended.zip # grep PASSCODE sol10_Recommended/sol10_Recommended.README
3. Install the patch cluster.
# cd sol10_Recommended # ./installcluster --[passcode]
4. Check for any errors or warnings during the installation. In no error found reboot the server in multi-user mode.
# init 6
Reattaching the mirror disk
Once we successfully install the patchset bundle and are sure to go ahead with it, we can re-mirror the root disk with the mirror.
1. Create the metadatabase replicas on the root mirror disk.
# metadb -a -c 3 c1t1d0s7
2. re-create and attach the root and swap mirrors.
# metainit d12 1 1 c1t1d0s0 # metainit d22 1 1 c1t1d0s1 # metattach d10 d12 # metattach d20 d22 # metastat | grep -i sync (check sync status)
Rollback
In case the patching gave you an error or if there is some issue with applications not working properly after patching, you can always roll back the patching and boot from the old patch level. The way to do this is, we re-encapsulate the un-encapsulated rootmirror disk under SVM and mirror it with the original root disk. This should look the figure below, once it is completed.
1. Boot from the un-encapsulated SVM root mirror disk.
# init 0 ok> boot rootmirror
2. Copy the partition table from rootmirror disk to root disk.
# prtvtoc /dev/rdsk/c1t1d0s2 | fmthard -s - /dev/rdsk/c1t0d0s2
3. Create the state database replicas(metadbs).
# metadb -afc 3 c1t1d0s7 c1t0d0s7
4. Create the sub-mirror metadevices.
# metainit -f d11 1 1 c1t1d0s0 # metainit -f d12 1 1 c1t0d0s0
5. Create the mirror d10 for root.
# metainit d10 -m d11 # metaroot d10
6. Add the below entry in the /etc/system file which allows the system to boot with less than or equal to half the total metadbs.
vi /etc/system set md:mirrored_root_flag = 1
7. Reboot the system
# init 6
8. Attach the sub-mirror d12 to mirror d10 to sync the data.
# metattach d10 d12
9. Re-create swap under root partition.
# swap -l swapfile dev swaplo blocks free /dev/dsk/c1t1d0s1 30,1 8 1548280 1548280 # swap -d /dev/dsk/c1t1d0s1 # metainit d22 1 1 c1t0d0s1 # metainit d21 1 1 c1t1d0s1 # metainit d20 -m d21 # metattach d20 d22 Change the /etc/vfstab entry for the new swap. /dev/dsk/c1t1d0s1 - - swap - no - to: /dev/md/dsk/d20 - - swap - no -
Add the swap again and set as dump device.
# swap -a /dev/md/dsk/d20 # dumpadm -d swap
10. Set the OBP variables to reflect the new aliases
# ls -l /dev/dsk/c1t0d0s0 lrwxrwxrwx 1 root root 46 Nov 16 12:35 /dev/dsk/c1t0d0s0 -> ../../devices/pci@0,0/pci15ad,1976@10/sd@0,0:a # ls -l /dev/dsk/c1t1d0s0 lrwxrwxrwx 1 root root 46 Nov 16 12:35 /dev/dsk/c1t1d0s0 -> ../../devices/pci@0,0/pci15ad,1976@10/sd@1,0:a
# eeprom "nvramrc=devalias rootmirror /devices/pci@0,0/pci15ad,1976@10/sd@0,0:a rootdisk /devices/pci@0,0/pci15ad,1976@10/sd@1,0:a"
11. Install the bootblock on the new mirror disk.
# installboot /usr/platform/`uname -i`/lib/fs/ufs/bootblk /dev/rdsk/c1t0d0s0