How to Patch a Live System Mirrored with SVM
By Julien Gabel on Monday 1 May 2006, 19:34 - Solaris - Permalink
Aim of this memo
The main purpose of this technical note is to demonstrate how to patch a running (live) system currently mirrored using SVM, minimizing the downtime as far as possible.
The idea is simple: detach one side of the mirror, apply the cluster patch
against it and reboot on it. If all seems OK, re-encapsulate the system. This
can achieve similar goal currently found in the Live Upgrade feature of the
Solaris OS (see live_upgrade(5)), with less complexity and
different requirement (LVM RAID-1 vs. spare disk, or free slice).
Using this solution, the downtime can go between 10 to 30 minutes of service unavailability (depending on the hardware POST) and a maximum of two reboots are required, whatever is the number of patches to apply.
Here it is
Here is a system encapsulated using SDS 4.x or SVM
1.x, and the associated SVM encapsulation
configuration:
# metastat -p d3 -m d13 d23 1 d13 1 1 c0t0d0s3 d23 1 1 c0t1d0s3 d1 -m d11 d21 1 d11 1 1 c0t0d0s1 d21 1 1 c0t1d0s1 d0 -m d10 d20 1 d10 1 1 c0t0d0s0 d20 1 1 c0t1d0s0 # # cat /etc/vfstab #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/d3 - - swap - no - /dev/md/dsk/d0 /dev/md/rdsk/d0 / ufs 1 no - /dev/md/dsk/d1 /dev/md/rdsk/d1 /var ufs 1 no - swap - /tmp tmpfs - yes -
Run an explorer and generate a cluster patch,
based on tools provided by the OSE for example, if you are luckily enough to have one
included with your support plan (or just pick one provided at SunSolve).
Then, be sure to be able to boot on the two disks, just in case:
# installboot /usr/platform/`uname -i`/lib/fs/ufs/bootblk /dev/rdsk/c0t0d0s0 # installboot /usr/platform/`uname -i`/lib/fs/ufs/bootblk /dev/rdsk/c0t1d0s0
The next step is to voluntarily detach one side of the mirror: take the
first one for the sake of simplicity (i.e. c0t0d0). Indeed, in
this case we are pretty sure that its alias name at the
OBP is
disk.
Note: You can always create it at the OBP (using the
usual set of commands, such as show-disks, devalias,
etc.) if you want. That is just a matter of personal preferences.
# lockfs -af /* Just to minimize the fs inconsistencies at next fsck(1m). */ # # metadetach d0 d10 # metadetach d1 d11 # metadetach d3 d13 # # metaclear d10 # metaclear d11 # metaclear d13
Check and repair the file systems if necessary, since we will boot on them the next time:
# fsck /dev/dsk/c0t0d0s0 # fsck /dev/dsk/c0t0d0s1
Next steps include mounting the recently detached file systems and prepare
the first disk to boot without SVM encapsulation:
# mkdir /mirror # mount /dev/dsk/c0t0d0s0 /mirror # mount /dev/dsk/c0t0d0s1 /mirror/var # # cat << EOF > /mirror/etc/vfstab #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/c0t0d0s3 - - swap - no - /dev/dsk/c0t0d0s0 /dev/rdsk/c0t0d0s0 / ufs 1 no - /dev/dsk/c0t0d0s1 /dev/rdsk/c0t0d0s1 /var ufs 1 no - swap - /tmp tmpfs - yes - EOF # # cp /mirror/etc/system /mirror/etc/system.orig # sed -e 's;rootdev:/pseudo/md@0:0,0,blk;*rootdev:/pseudo/md@0:0,0,blk;' \ /mirror/etc/system.orig > /mirror/etc/system
Last, install patches against the first disk, clean things up a little and reboot if the install procedure went all smooth:
# ./install_all_patches -R /mirror # # umount /mirror/var # umount /mirror # rmdir /mirror # # shutdown -y -g 0 -i 6
After rebooting, carefully review the behavior of the very freshly patched system. If all seems well, don't forget to re-encapsulate the second disk. Here is a quick and easy way to this:
/* Recreate the metadb. */ # metadb -d c0t0d0s4 c0t1d0s4 # metadb -a -c3 -f c0t0d0s4 c0t1d0s4 # /* Clean the system metadevices always present. */ # metaclear d0 # metaclear d1 # metaclear d3 # metaclear d20 # metaclear d21 # metaclear d23 # /* Re-create them as part of a mirror. */ # metainit -f d10 1 1 c0t0d0s0 # metainit d0 -m d10 # metainit -f d11 1 1 c0t0d0s1 # metainit d1 -m d11 # metainit -f d13 1 1 c0t0d0s3 # metainit d3 -m d13 # /* Be able to boot on the new metadevices. */ # metaroot d0 # /* Reboot, and create the second side of the mirror. */ # shutdown -y -g 0 -i 6 [...] # metainit d20 1 1 c0t1d0s0 # metattach d0 d20 # metainit d21 1 1 c0t1d0s1 # metattach d1 d21 # metainit d23 1 1 c0t1d0s3 # metattach d3 d23
For a little more detailed explanation about encapsulating the system using SVM on Sun Solaris, please refer to the dedicated entry in this blog.
Last, it must be mentioned that this documentation was written by our OSE, and that this procedure was officially marked as supported by Sun Microsystems.

Oracle ACE
Comments
hey thanks for the nice tips!
"./install_all_patches" ...... is this a Sun script ?
I've used basically the same procedure to apply Solaris 8 patches (8_Recommended-and-Security-161106) ...and have found an issue.
I split the mirror (sync,metadetach,metaclear,fsck,mount,edit vfstab/system) and then booted off the mirror (then rebooted off primary and patched primary). 5 days after patching I re-attached the mirror (attached secondary to primary)
Systems have not been re-booted since.
This week I've found that none of my systems are able to "metadetach/fsck/mount" .. thay ALL panic :) , I've tried installing the latest disk suit patch "-28" , I tried using a "fsck -o f"....nothing helps.
The panic string says: panic[cpu1]/thread=30003031460: free: freeing free block, dev:0x2000000008, block:22840, ino:2, fs:/mnt
Anyways....will post then fix.....if we can find it :)
Cheers
Copy of my session incase it helps someone else:
# df -k
> Filesystem kbytes used avail capacity Mounted on
> /dev/md/dsk/d0 15358662 3146152 12058924 21% /
> /proc 0 0 0 0% /proc
> mnttab 0 0 0 0% /etc/mnttab
> fd 0 0 0 0% /dev/fd
> /dev/md/dsk/d5 10323610 3032708 7187666 30% /var
> swap 5831928 32 5831896 1% /var/run
> swap 5831976 80 5831896 1% /tmp
> /dev/md/dsk/d6 5161437 2050239 3059584 41% /export/home
>
> # prtconf -pvvv | grep boot
> boot-retained-page:
> bootargs: 00
> bootpath: '/pci@1c,600000/scsi@2/disk@0,0:a'
> auto-boot-on-error?: 'false'
> auto-boot?: 'true'
> boot-command: 'boot'
> boot-file:
> boot-device: 'rootdisk rootmirror'
> error-reset-recovery: 'boot'
>
> # metastat -p
> d0 -m d20 d10 1
> d20 1 1 c0t1d0s0
> d10 1 1 c0t0d0s0
> d1 -m d21 d11 1
> d21 1 1 c0t1d0s1
> d11 1 1 c0t0d0s1
> d5 -m d25 d15 1
> d25 1 1 c0t1d0s5
> d15 1 1 c0t0d0s5
> d6 -m d26 d16 1
> d26 1 1 c0t1d0s6
> d16 1 1 c0t0d0s6
>
> # sync
>
> # sync
>
> # sync
>
> # metadetach d0 d20
> d0: submirror d20 is detached
>
> # metaclear d20
> d20: Concat/Stripe is cleared
>
> # fsck -y /dev/rdsk/c0t1d0s0
> ** /dev/rdsk/c0t1d0s0
> ** Last Mounted on /
> ** Phase 1 - Check Blocks and Sizes
> ** Phase 2 - Check Pathnames
> ** Phase 3a - Check Connectivity
> ** Phase 3b - Verify Shadows/ACLs
> ** Phase 4 - Check Reference Counts
> ** Phase 5 - Check Cylinder Groups
>
> CORRECT BAD CG SUMMARIES? yes
>
> CORRECTED SUMMARY FOR CG 0
> FRAG BITMAP WRONG
> FIX? yes
>
> 82581 files, 3130904 used, 12212510 free (14102 frags, 1524801 blocks,
> 0.1% fragmentation)
>
> ***** FILE SYSTEM WAS MODIFIED *****
>
>
> # mount /dev/dsk/c0t1d0s0 /mnt
>
> panic[cpu1]/thread=30003031460: free: freeing free block,
> dev:0x2000000008, block:22840, ino:2, fs:/mnt
>
> 000002a100856e80 ufs:real_panic_v+70 (0, 1047bfe0, 2a100857120, 0,
> 104749f8, 30003488ec0)
> %l0-3: 00000000102752ac 00000300031a7868 0000000000002000
> 000002a10001fd20
> %l4-7: ffffffffffffffff 0000000000000000 0000000000000000
> 0000000000000001 000002a100856f30 ufs:ufs_fault_v+cc (30002d1ad38,
> 2a100857120, 0, 3000345b530, 5b, 1)
Back again, just a follow up.
Sun have confirmed the error I mentioned was caused by a UFS patch included in the 8_Recommended-and-Security-161106 patch bundle.
I have since applied the (8_Recommended-and-Security-270607) and confirmed it works.
The issue described above is related to "SunAlert 102756", the patch in question is: "110910-05" (also patch 110910-04)
Cheers
Nice to see that the important problem you had encountered was known by Sun, and already fixed.
FYI, the script install_all_patches was provided at that time by our OSE (along with the appropriate bundle of patches). Currently, we tend to prefer the use of the TLP method to provide custom clusters of patches, trimmed for a particular machine, and using a defined baseline.
Great doc very helpful :-)
My only comment is on the fsck command, you seem to be running fsck on the block device /dev/dsk rather than the raw device /dev/rdsk
Regards
Mike
The fact is
fsckworks as excepted using the raw device, the block device or the mount point (if known from the/etc/vfstabconfiguration file). But you are right, the proper way is to mention the raw device as argument--from thefsckmanual page:Hmm, we do it a little different than this. We simply create one BE on slice 0 of drive #1 and mirror it to slice 0 of drive #2. We then format another slice (say slice #6) and make it the same size as slice 0. This will be our Secondary BE and it is mirrored to slice 6 of drive #2. This way we never break a mirror (which leaves the system vulnerable during the patching period and we keep our old BE around until we patch again.
GMO
Absolutely. In fact, we proceed in a similar way right now. The point is, it was not planned beforehand on the system I worked on in this post to used Live Upgrade to update/upgrade the environment. Thank you for your comments.