OS Hacking and more.

8.22.2008

Rapid Upgrade for OpenSolaris with ZFS

When upgrading an OpenSolaris install, we would like to preserve personal files and information with as little hassle as possible. This is particularly easy when we have multiple disks among which to separate OS and personalization. Unfortunately, it is not trivial to upgrade a single disk install of OpenSolaris while preserving one's files. I think I can change this though.

Currently, there are a limited number of options for updating an existing OpenSolaris install.
We can reinstall with a newer version of the OS, using the installer. Problem with this is the installer requires you to reformat and create the zfs pool and volume to be installed on. It is possible to have another partition and/or zfs pool on that disk to preserve your files, but this is contrary to the purpose of ZFS...And if you have 50Gbs of files, you don't want to spend hours backing them up and restoring.
We can use the package manager to upgrade the distribution and associated packages, but this can be a painfully slow process, downloading and installing thousands of packages...
We would use LiveUpgrade, except for the fact that a ZFS version doesn't exist atm...

So...we try a different approach, tailored to ZFS...
Simply put, we will install the system on another drive, then clone the boot environment created by the installer to our host/favorite machine via zfs snapshots...Lost? here are the instructions, its easier that it sounds:

You will need,
-A USB harddisk or external drive big enough to fit your Solaris Install (~4Gb or more) Remember that you can add packages later, so a small drive may be ok.
-Solaris Install media or Jumpstart Server
-Your target disk(what you want to upgrade), with more than enough space for a new install (>4Gb)

1) With the external disk plugged in, boot from your install media. You may want to disconnect your working drive for safe measure.

2) Use your installer to install to the external disk. DO NOT REBOOT when it finishes, or at least don't boot off USB.

3) Reconnect your target drive, and boot from a LiveCD distribution. We'll need to transfer the new boot environment to the old drive without having either running.

4) In a superuser shell (su)
There are 2 "rpool"s connected, so importing the correct zfs pool will be interesting. We need to find the vdev associated with the target drive so we can find its UUID.

$ format -e



This will print out the disk devices present. Find the cXtXdX associated with your target drive.


$ zpool import



This will print out the zfs pools present. Find the rpool that contains cXtXdX you noted above. Note its UUID (a long string of numbers).


$ zpool import [UUID]



5) [Optional] Preserve your old boot environment, this wil allow you to rollback the changes if necessary. This can be done as follows:


$ zfs snapshot rpool/ROOT/opensolaris@itwasworking
$ zfs send rpool/ROOT/opensolaris@itwasworking > /rpool/oldbe.snapshot



we won't be playing with your export/home because that's where your home directory is...we wanna save that, right?

6) Kill the old BE...


$ zfs destroy rpool/ROOT/opensolaris"




7) Import the USB drive...
Once again, find its UUID by calling "zpool import"(see step 4). Then:


$ zpool import [UUID] xpool



This should rename that pool xpool...

8) Copy over the new OpenSolaris Install


$ zfs snapshot xpool/ROOT/opensolaris@iamnew
$ zfs send xpool/ROOT/opensolaris@iamnew > /rpool/iamnew.snapshot
$ zfs recv rpool/ROOT/opensolaris@iamnew < iamnew.snapshot



9) When that's finished...we're done. Make sure to scrub and export rpool, and eject your live media and external drive. Then boot from the target disk!

Good luck

No comments: