Tuesday, May 5, 2009

Live upgrading a Solaris Express Community Edition

It would really be difficult for me to tell the feature I love most in Sun Solaris OS.

Today, trying to troubleshoot a font problem I'm experiencing, I decided to live upgrade my Solaris Express Community Edition from build 110 to build 113.

If you're interested in discovering the details of the Solaris features of the day, you could easily check the extensive official documentation. Let's say that Live upgrade lets you upgrade your OS while the system is running, creating an alternate boot environment. This process, which could be used with UFS, it's even easier with ZFS.

Check your tools.
The first thing you should do is installing the Live Upgrade packages from the Solaris distribution you're going to install. I'll repeat: The first thing you should do is installing the Live Upgrade packages from the Solaris distribution you're going to install. If you're installing from a DVD, just insert into the drive bay. If you just downloaded an ISO image you can just:
# mkdir /mnt/iso
# lofiadm -a /path/to/solaris/iso
[lofiadm will print on standard output a lofi device number such as /dev/lofi/n]
# mount -F hsfs -o ro /dev/lofi/n /mnt/iso
Now you can upgrade your tools:
# pkgrm SUNWlucfg SUNWluu SUNWlur
# pkgadd -d /mnt/iso/Solaris_your-version-here/Product SUNWlucfg SUNWluu SUNWlur
Creating a boot environment.
The creation of a boot environment is a straightforward process, which is pretty instantaneous on ZFS:
# lucreate -n BEName
I usually use snv_buildnum as my boot environments' name and in this case it's snv_113. If you want to check that everything's OK you can issue a:
# lustatus
and check the output to see if your new boot environment has been correctly initialized. If you check your ZFS file systems and snapshots, you'll notice something like this (don't look at used space because these boot environments have already been upgraded):
# zfs list
rpool 115G 113G 35.5K /rpool
rpool/ROOT 21.9G 113G 18K legacy
rpool/ROOT/snv_110 19.1G 113G 12.2G /
rpool/ROOT/snv_110/var 6.84G 113G 6.84G /var
rpool/ROOT/snv_113 2.82G 113G 11.8G /a
rpool/ROOT/snv_113/var 102M 113G 6.85G /a/var
You have a couple of brand new file systems for your new boot environment. Your output may vary because I decided to have /var on a separate file system.
# zfs list -t snapshot
rpool/ROOT/snv_110@snv_113 9.17M - 12.2G -
rpool/ROOT/snv_110/var@snv_113 1.94M - 6.84G -
What happened, basically, is that ZFS snapshotted your current boot environment and subsequently cloned it. That's ZFS in action! With traditional file systems, such as UFS, "snapshotting" or "cloning" the entire partition would have taken a great amount of time. With ZFS copy on write semantics, it takes fractions of a second and almost a null amount of additional storage.

Upgrading the boot environment.
The last, and longest, step in the procedure. I suggest you to read luupgrade man page but, basically, you can just issue a:
# luupgrade -u -n snv_113 -s /mnt/iso
and wait until the end. Please read luupgrade output, which usually is important, and save it to a file. You would probably need to revise it later. If everything went fine you can activate your new boot environment, reboot, and enjoy your new OS with just a:
# luactivate snv_113
# init 6
You will be told by luactivate but I'll repeat: use init or shutdown to reboot your system. Before switching boot environment, Solaris needs to execute the final configuration steps which are performed during a clean reboot.

The last suggestion.
Live Upgrade helps you upgrade your system without risk and downtimes but remember: time is a precious asset and I don't like to restart a long-running task because a remote connection has been reset. If you plan to live upgrade from a remote terminal, at least use screen or some equivalent tool. Don't lose your session!

Forewarned is forearmed.

In the next blog entry I'll tell you about housekeeping activities you must perform after live upgrading.

No comments: