Simple Live Upgrade Example For Fun and Profit
By Danx-Oracle on Nov 30, 2007
Live Upgrade Introduction Solaris Live Upgrade (LU) clones your root filesystem to allow Solaris upgrades while remaining booted on your original root filesystem. LU term "Boot Environment" (BE) refers to one or more bootable root filesystems. You need two slices to do this—your current root slice and an alternate root slice. OpenSolaris installation creates two 10GB partitions by default, if you have enough disk space. Slice 0 (a) has root and slice 3 (d) has "second_root", which is initially empty and reserved for a live upgrade during upgrade installs. The other filesystems, such as /export/home are left untouched.
This simple example shows how to clone your root filesystem with LU and boot to it. This is useful for such things as a backup, future upgrade, or testing (without worrying about destroying your system configuration). I'm just covering the simple case—clone one root filesystem. More elaborate operations are possible with multiple filesystems, zones, mirroring, and volume managers.
Prerequisites During LU, the alternate root filesystem must not be mounted, or even in the /etc/vfstab file—just comment it out. Also, your system should be up-to-date with LU patches (see InfoDoc 72099 referenced below). Also, update Live Upgrade with /media/SOL_11_X86/Solaris_11/Tools/Installers/liveupgrade20 from the DVD.
Create a new Boot Environment (BE) The lucreate(1M) command clones your root filesystem. You specify the root mount point (which will be cloned) and an (empty) disk slice to contain the cloned filesystem. The -n option specifies the name of the new BE. For example:
# lucreate -m /:/dev/dsk/c0d0s4:ufs -n second_root Discovering physical storage devices Discovering logical storage devices Cross referencing storage devices with boot environment configurations Determining types of file systems supported Validating file system requests Preparing logical storage devices Preparing physical storage devices Configuring physical storage devices Configuring logical storage devices Analyzing system configuration. Comparing source boot environment <c0d0s0> file systems with the file system(s) you specified for the new boot environment. Determining which file systems should be in the new boot environment. Updating boot environment description database on all BEs. Searching /dev for possible boot environment filesystem devices Updating system configuration files. The device </dev/dsk/c0d0s4> is not a root device for any boot environment; cannot get BE ID. Creating configuration for boot environment <second_root>. Source boot environment is <c0d0s0>. Creating boot environment <second_root>. Checking for GRUB menu on boot environment <second_root>. The boot environment <second_root> does not contain the GRUB menu. Creating file systems on boot environment <second_root>. Creating <ufs> file system for </> in zone <global> on </dev/dsk/c0d0s4>. Mounting file systems for boot environment <second_root>. Calculating required sizes of file systems for boot environment <second_root>. Populating file systems on boot environment <second_root>. Checking selection integrity. Integrity check OK. Populating contents of mount point </>. Copying. Creating shared file system mount points. Creating compare databases for boot environment <second_root>. Creating compare database for file system </>. Updating compare databases on boot environment <second_root>. Making boot environment <second_root> bootable. Updating bootenv.rc on ABE <second_root>. Population of boot environment <second_root> successful. Creation of boot environment <second_root> successful.
Type lustatus to verify your system configuration:
# lustatus Boot Environment Is Active Active Can Copy Name Complete Now On Reboot Delete Status -------------------------- -------- ------ --------- ------ ---------- c0d0s0 yes yes yes no - second_root yes no no yes -
Booting to your target BE (cloned root filesystem) First (for x86 systems), I recommend saving a hard copy of the GRUB boot menu, /boot/grub/menu.lst — then you can boot to a partition in the GRUB command line no matter what might happen to the GRUB menu.lst file (in case you hit bug 6639959). Newer versions of Live Upgrade don't have this problem, but it doesn't hurt to save menu.lst. To activate your target BE, use luactivate. Then reboot. You must use init(1M) or shutdown(1M) to reboot—do not use halt(1M) or reboot(1M), as the latter commands skip graceful shutdown procedures, including switching your BE. Be patient in this step as this could take awhile updating the new BE. For example:
# luactivate second_root Saving latest GRUB loader. Generating partition and slice information for ABE <second_root> Boot menu exists. Generating direct boot menu entries for ABE. Generating direct boot menu entries for PBE. \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* 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. Do \*not\* change \*hard\* disk order in the BIOS. 2. Boot from the Solaris Install CD or Network and bring the system to Single User mode. 3. Mount the Parent boot environment root slice to some directory (like /mnt). You can use the following command to mount: mount -Fufs /dev/dsk/c0d0s0 /mnt 4. Run <luactivate> utility with out any arguments from the Parent boot environment root slice, as shown below: /mnt/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 GRUB menu is on device: </dev/dsk/c0d0s0>. Filesystem type for menu device: <ufs>. Activation of boot environment <second_root> successful. # lustatus Boot Environment Is Active Active Can Copy Name Complete Now On Reboot Delete Status -------------------------- -------- ------ --------- ------ ---------- c0d0s0 yes no no yes - second_root yes yes yes no - # shutdown -i6
After rebooting, you'll notice (for x86) that the GRUB menu (file /boot/grub/menu.lst in the old (source) BE) has been updated with the new BE, allowing you to boot to the old (source) BE or the target BE.
# /boot/grub/menu.lst default 1 timeout 10 title Solaris Express Developer Edition 9/07 snv_70b X86 kernel$ /platform/i86pc/kernel/$ISADIR/unix module$ /platform/i86pc/$ISADIR/boot_archive title second_root root (hd0,2,e) kernel$ /platform/i86pc/kernel/$ISADIR/unix module$ /platform/i86pc/$ISADIR/boot_archive
Solaris Upgrade with Live Upgrade Use luupgrade to upgrade a BE. Just specify the BE name to upgrade (not the currently-active BE) and the root directory of the install DVD or DVD image. For example:
# luupgrade -u -n second_root -s /media/SOL_11_X86 Copying failsafe kernel from media. Uncompressing miniroot Uncompressing miniroot archive (Part2) 13353 blocks Creating miniroot device miniroot filesystem is <ufs> Mounting miniroot at </media/SOL_11_X86/Solaris_11/Tools/Boot> Mounting miniroot Part 2 at </media/SOL_11_X86/Solaris_11/Tools/Boot> Validating the contents of the media </media/SOL_11_X86>. The media is a standard Solaris media. The media contains an operating system upgrade image. The media contains <Solaris> version <11>. Constructing upgrade profile to use. Locating the operating system upgrade program. Checking for existence of previously scheduled Live Upgrade requests. Creating upgrade profile for BE <second_root>. Checking for GRUB menu on ABE <second_root>. Checking for x86 boot partition on ABE. Determining packages to install or upgrade for BE <second_root>. Performing the operating system upgrade of the BE <second_root>. CAUTION: Interrupting this process may leave the boot environment unstable or unbootable. Upgrading Solaris: 30% completed
Upgrading Solaris: 100% completed Installation of the packages from this media is complete. Deleted empty GRUB menu on ABE <second_root>. Adding operating system patches to the BE <second_root>. The operating system patch installation is complete. ABE boot partition backing deleted. Configuring failsafe for system. Failsafe configuration is complete. INFORMATION: The file </var/sadm/system/logs/upgrade_log> on boot environment <second_root> contains a log of the upgrade operation. INFORMATION: The file </var/sadm/system/data/upgrade_cleanup> on boot environment <second_root> contains a log of cleanup operations required. WARNING: <2> packages failed to install properly on boot environment
LU Bug Workaround:
With a Live Update to NV79a you may have a problem with the /bin directory in the new BE. This is a bug and you'll notice it when several services fail during booting. Directory /bin should be a softlink to /usr/bin, not a directory. If it is, then fix it as follows and reboot:
mv /bin /bin.old; ln -s usr/bin /bin
Reverting or cleanup of a BE To switch back to the original BE, run luactivate again:
# luactivate c0d0s0
# ludelete c0d0s0
Other lu commands
To copy from the current BE to an existing BE (one where lucreate was ran), run lumake.
To look at or edit a file in your original BE (say, for example, to edit your GRUB configuration file /boot/grub/menu.lst), use lumount. For example,
lumount c0d0s0 /mnt
Use luumount to unmount. For example,
luumount /mnt I use lurename to rename BEs to a more meaningful BE name.
- Solaris Live Upgrade How-To Guide Good tutorial on LU concepts and use.
- Solaris 10 Installation Guide: Solaris Live Upgrade and Upgrade Planning Detailed reference manual.
- "Rapid Patching and Upgrading with Solaris Live Upgrade Software" by Amy Rich (2004). LU for use with patching and upgrading software, with extensive examples.
- "Solaris Live-Upgrade Minimum Patch Requirements." InfoDoc 72099 Search for it at SunSolve
- Packages: SUNWlur and SUNWluu
- LU commands (overview at live_upgrade(5) man page): luactivate(1M), lucancel(1M), lucompare(1M), lucreate(1M), lucurr(1M), ludelete(1M), lufslist(1M), lumake(1M), lumount(1M), luumount(1M), lurename(1M), lustatus(1M), and luupgrade(1M).
Update: (Sept. 2008): OpenSolaris now has beadm(1M) for use with ZFS bootable filesystems. To use in the simple case, simply type beadm create; beadm list and it will clone the current Boot Environment