The other day I setup my laptop with an eye to making it
live upgradable, so now it’s time to see if I had a clue what I
was doing.
LUvly
Solaris has a feature called Live Upgrade (LU).
The idea is you clone the system into a free slice
(called a ‘boot environment’ or BE), upgrade that, configure it, etc. -
then boot into it quickly when no-one’s looking.
Should it fail horribly, you just reboot and no-one is any the wiser.
It minimizes downtime for upgrades, and gives you a simple and reliable backout (a snapshot/rollback facility).
BE happy
My laptop is set up with a / slice , swap and a spare slice.
All the user data is on my zpool.
By default, LU will copy over all of / – /var /usr /etc , but also /opt.
If you stick /opt on ZFS, LU will try to copy everything to the new BE, which
a) takes hours and b) probably won’ fit. So I’ve put /opt/csw, /opt/SUNWspro, /opt/whatever on ZFS.
hypnotoad $ df -h -Fzfs
Filesystem size used avail capacity Mounted on
tank/home 16G 31K 14G 1% /export/home
tank/home/dick 16G 461M 14G 4% /export/home/dick
tank/SUNWappserver 16G 125M 14G 1% /opt/SUNWappserver
tank/SUNWspro 16G 468M 14G 4% /opt/SUNWspro
tank/csw 16G 216M 14G 2% /opt/csw
tank/netbeans-5.5 16G 210M 14G 2% /opt/netbeans-5.5
tank/netbeans-5.5.1 16G 132M 14G 1% /opt/netbeans-5.5.1
tank/src 16G 612K 14G 1% /src
These filesystems will be shared across BEs,
but the ‘OS’ (/var /usr/ /sbin etc) will be copied over to the new BE , then upgraded.
hypnotoad $ df -h -Fufs
Filesystem size used avail capacity Mounted on
/dev/dsk/c0d0s0 5.5G 2.8G 2.6G 52% /
get your media
I’m currently running b68 , so first thing to do is download the latest Nevada DVD ISO (b69) to a ZFS filesystem (there’s not enough room in my teeny root slice, and this avoids LU copying it over to the new BE).
hypnotoad $ pfexec zfs create tank/isos
hypnotoad $ pfexec zfs set mountpoint=/isos tank/isos
hypnotoad $ pfexec zfs set copies=1 tank/isos
mount the ISO
hypnotoad $ pfexec lofiadm -a /isos/sol-nv-b69-x86-dvd.iso
/dev/lofi/1
hypnotoad $ pfexec mount -F hsfs /dev/lofi/1 /mnt
hypnotoad $ ls /mnt/
Copyright autorun.inf
DeveloperTools autorun.sh
JDS-THIRDPARTYLICENSEREADME boot
License installer
README.txt sddtool
Solaris_11
plan your escape
The root filesystem doesn’t need to be backed up (that’s the
whole point!) but I’ll snapshot all the other (ZFS) filesystems just in case:
hypnotoad $ pfexec zfs snapshot -r tank@pre-lu
this recursively (-r) snapshots all filesystem in the zpool ‘tank’ with the label ‘pre-lu’
copy your BE
hypnotoad $ pfexec /usr/sbin/lucreate -c b68 -n b69 -m /:/dev/dsk/c0d0s3:ufs
this :
- calls the existing BE ‘b68’ (-c b68)
- creates a new BE called b69 (-n b69)
- clones the root FS (the OS) to the UFS slice ‘c0d0s3’ (-m /:/dev/dsk/c0d0s3:ufs)
the upshot of which is:
Discovering physical storage devices
Discovering logical storage devices
....
....
Making boot environment bootable.
Updating bootenv.rc on ABE .
Population of boot environment successful.
Creation of boot environment successful.
We now have 2 BEs (the one we’re in now, and the one we’ll be upgrading):
hypnotoad $ pfexec /usr/sbin/lustatus
Boot Environment Is Active Active Can Copy
Name Complete Now On Reboot Delete Status
------------- ---- --- ---- --- ------
b68 yes yes yes no -
b69 yes no no yes -
upgrade the new BE
hypnotoad $ pfexec /usr/sbin/luupgrade -u -n b69 -s /mnt/
that’s :
- do an OS upgrade (-u) …
- … of the ‘b69’ BE (-n b69) …
- … from the b69 ISO (-s /mnt).
This’ll take bloody ages (about an hour on my rubbish laptop).
suck it and see
hypnotoad $ pfexec /usr/sbin/luactivate b69
hypnotoad $ pfexec init 6
This’ll create a new default GRUB entry for the new BE. To rollback, either ‘luactivate b68’ or simply reboot and choose the old menu entry.
rolling upgrades
It’s worth knowing that GRUB still boots using the original root fs:
hypnotoad $ df -h -Fufs
Filesystem size used avail capacity Mounted on
/dev/dsk/c0d0s3 5.5G 2.8G 2.6G 52% /
hypnotoad $ pfexec bootadm list-menu
The location for the active GRUB menu is: /dev/dsk/c0d0s0 (not mounted)
The filesystem type of the menu device is
default 2
timeout 10
0 Solaris Express Community Edition snv_68 X86
1 Solaris failsafe
2 b69
3 b69 failsafe
4 b68
5 b68 failsafe
which means:
- the best way to edit the menu.lst is using bootadm (which knows where to find it)
- if you delete that partition, you are screwed.
I thought you’d need a dedicated /boot partition if you wanted to easily do rolling upgrades.
In fact, Live Upgrade knows all about GRUB:
hypnotoad $ pfexec /usr/sbin/ludelete b68
The boot environment contains the GRUB menu.
Attempting to relocate the GRUB menu.
Relocating GRUB slice to .
Mounted new GRUB slice .
Updating GRUB state.
Moving GRUB menu.
Installing latest GRUB loader.
stage1 written to partition 1 sector 0 (abs 385560)
stage2 written to partition 1, 260 sectors starting at 50 (abs 385610)
Determining the devices to be marked free.
Updating boot environment configuration database.
Updating boot environment description database on all BEs.
Updating all boot environment configuration databases.
Updating GRUB menu default setting
Boot environment deleted.
hypnotoad $ pfexec /usr/sbin/lustatus
Boot Environment Is Active Active Can Copy
Name Complete Now On Reboot Delete Status
------------- ---- --- ---- --- ------
b69 yes yes yes no -
(Obviously, don’t ‘ludelete’ until you’re happy the new build works well for you).
Now your original slice is freed up to use for b70.