Tuesday, March 17, 2015

Solaris 10: Migrating From UFS to ZFS with Live Upgrade


Solaris 10 Live Upgrade with ZFS is really simple compared to some of the messes you could get into with SVM mirrored root disks. Below is a simple live upgrade BE creation and patching example. Also, Solaris Live Upgrade works the same as in previous releases when you use ZFS. The same commands. As I said, it's just easier. Also, a really great feature is that you can now migrate from UFS file systems to a ZFS root pool and create new boot environments within a ZFS root pool.

Create the new rpool
You will need a new disk to be used as your ZFS boot disk. First task is to create a new root pool or rpool. You have to create a new boot environment in that rpool from the existing UFS boot and root file system.
In this example, the zfs list command shows the ZFS root pool created by the zpool command. The next zfs listcommand shows the datasets created by the lucreate command.

# zpool create rpool c0t2d0s2

# zfs list
NAME USED AVAIL REFER MOUNTPOINT
rpool 12.4G 90.1G 20K /rpool

We now need to create the new Boot Environment BE using the existing boot disk (UFS based) as the source and use the newly created rpool and the destination BE.

Create a new ZFS Boot Environment

# lucreate -c c0t0d0 -n Nov2012-zfsBE -p rpool

# zfs list
NAME USED AVAIL REFER MOUNTPOINT
rpool 12.4G 90.1G 20K /rpool
rpool/ROOT 8.12G 90.1G 18K /rpool/ROOT
rpool/ROOT/Nov2012-zfsBE 8.12G 90.1G 551M /tmp/.alt.luupdall.899001
rpool/dump 3.95G - 3.95G -
rpool/swap 3.95G - 3.95G -

This is so cool, and easy. All that is left is to patch the new Nov2012 BE, activate it and reboot. So lets say we had the typical Oracle (old Sun) patch cluster.

Patch the new ZFS based Boot Environment Using luupgrade

To patch the new BE, I would do:

# luupgrade -n Nov2012-zfsBE -s /root/10_Recommended/patches -t `cat patch_order`
>snip to remove all the patching output.

Then we activate the new ZFS based BE so we can boot off of the new disk.

Activate the new ZFS based Boot Environment

# luactivate Nov2012-zfsBE
A Live Upgrade Sync operation will be performed on startup of boot environment <Nov2012-zfsBE>.
**********************************************************************
The target boot environment has been activated. It will be used when you
reboot. NOTE: You MUST NOT USE the reboot, halt, or uadmin commands. You
MUST USE either the init or the shutdown command when you reboot. If you
do not use either init or shutdown, the system will not boot using the
target BE.
**********************************************************************

 
In case of a failure while booting to the target BE, the following process
needs to be followed to fallback to the currently working boot environment:
1. Enter the PROM monitor (ok prompt).
2. Boot the machine to Single User mode using a different boot device
(like the Solaris Install CD or Network). Examples:
At the PROM monitor (ok prompt):
For boot to Solaris CD:  boot cdrom -s
For boot to network:     boot net -s
3. Mount the Current boot environment root slice to some directory (like
/mnt). You can use the following commands in sequence to mount the BE:
zpool import rpool
zfs inherit -r mountpoint rpool/ROOT/Nov2012-zfsBE
zfs set mountpoint=<mountpointName> rpool/ROOT/Nov2012-zfsBE
zfs mount rpool/ROOT/Nov2012-zfsBE
4. Run <luactivate> utility with out any arguments from the Parent boot
environment root slice, as shown below:
<mountpointName>/sbin/luactivate
5. luactivate, activates the previous working boot environment and
indicates the result.
6. Exit Single User mode and reboot the machine.
**********************************************************************
Modifying boot archive service
Activation of boot environment <Nov2012-zfsBE> successful.

Let's see if it worked. Yes, Nov2012-zfsBE is now Active on Reboot. Let's reboot with init 6.

Boot from your new ZFS root disk

# lustatus
Boot Environment           Is       Active Active    Can    Copy
Name                       Complete Now    On Reboot Delete Status
-------------------------- -------- ------ --------- ------ ----------
Nov2012-zfsBE        yes      no     yes       no     -

 
# init 6

Login and check patch level and see if the new software I installed is there.

# uname -a
SunOS mygreatbox 5.10 Generic_147440-26 sun4v sparc sun4v

How easy and cool was that? The handy thing with luactivate is it changes the boot environment for you, meaning the OBP boot device settings don't have to be changed, it is all handled by the operating system during the BE activation process.

No comments:

Post a Comment