Well it’s done, opensolaris 2008.05 re-installed. This time I took a snapshot and cloned the rootfs.
It wasn’t quite as easy as I though. Well actually it was, it just lost everything I had installed into /opt.
Eventually figured it out though. At some point /opt has become a seperate zfs file system that is somehow linked to the rootfs being booted at boot time. Not 100% sure how it does that as the mountpoint is set to /opt for all the zfs /opt filesystems, so I guess it uses the name of rootfs somehow and looks for other filesystems that match it and mounts them ??.
Anyway, after cloning rpool/ROOT/opensolaris to rpool/ROOT/live20081006, mounting it, updating the vfstab in it, umounting it, seting mountpoint to legacy, and adding it to the grub menu.lst file (plus a single user mode boot option for it), I could boot into it ok.
But as noted above, /opt no longer had anything in it.
After examining all the zfs filesystems, and taking a wild guess, I also cloned rpool/ROOT/opensolaris/opt to rpool/ROOT/live20081006/opt and set the mountpoint of the clone to /opt, which immediately mounted it and the files were back.
Not really a wild guess I suppose, the zfs filesystem names made it an obvious guess, but I didn’t know if it would work. It did.
The gnome menu had lost the items for those files though, so another guess, reboot.
On the reboot the correct new cloned opt filesystem was mounted on /opt, and the gnome menu items had returned; they must be dynamically built ???, or consistency checked at startup time and entries with missing files removed (oh yeah, that would also be dynamically built).
Filesystem kbytes used avail capacity Mounted on rpool/ROOT/live20081006 36126720 2762633 32753455 8% / /devices 0 0 0 0% /devices /dev 0 0 0 0% /dev ctfs 0 0 0 0% /system/contract proc 0 0 0 0% /proc mnttab 0 0 0 0% /etc/mnttab swap 2209352 752 2208600 1% /etc/svc/volatile objfs 0 0 0 0% /system/object sharefs 0 0 0 0% /etc/dfs/sharetab /usr/lib/libc/libc_hwcap1.so.1 35516088 2762633 32753455 8% /lib/libc.so.1 fd 0 0 0 0% /dev/fd swap 2208608 8 2208600 1% /tmp swap 2208640 40 2208600 1% /var/run rpool/ROOT/live20081006/opt 36126720 458509 32753455 2% /opt rpool/export 36126720 19 32753455 1% /export rpool/export/home 36126720 29698 32753455 1% /export/home rpool 36126720 56 32753455 1% /rpool rpool/ROOT 36126720 18 32753455 1% /rpool/ROOT -bash-3.2#
-bash-3.2# zfs list NAME USED AVAIL REFER MOUNTPOINT rpool 3.22G 31.2G 56.5K /rpool rpool@install 17.5K - 55K - rpool@20081005 19K - 56.5K - rpool/ROOT 3.19G 31.2G 18K /rpool/ROOT rpool/ROOT@install 17K - 18K - rpool/ROOT/live20081006 20.1M 31.2G 2.63G legacy rpool/ROOT/live20081006/opt 99K 31.2G 448M /opt rpool/ROOT/opensolaris 3.17G 31.2G 2.63G legacy rpool/ROOT/opensolaris@install 88.6M - 2.24G - rpool/ROOT/opensolaris@20081006 10.2M - 2.63G - rpool/ROOT/opensolaris/opt 448M 31.2G 448M /opt rpool/ROOT/opensolaris/opt@install 72K - 3.60M - rpool/ROOT/opensolaris/opt@20081006 0 - 448M - rpool/export 29.1M 31.2G 19K /export rpool/export@install 15K - 19K - rpool/export/home 29.0M 31.2G 29.0M /export/home rpool/export/home@install 18K - 21K - -bash-3.2#
And now I know the commands and setup a base I have scripted all future snapshots, the script simply does a ‘df -k /’, strips out the YYYYMMDD of the filesystem, confirms there is a matching /opt filesystem for that date by grepping a zfs list, and if it does look like I have a working clone on / (with my naming conventions) running it just snapshots and clones to the current days date and sets the zfs mountpoints, seds the vfstab on the new filesystem, adds new boot entries to grubs menu.lst and… well thats it, it’s available on a reboot. What was 15-20 minutes work is now 20 seconds work so I will be taking a clone before every big change now.
And no, my script will not automatically delete old zfs filesystems/snapshots/grub entries. Obviously I will do that only when I am 100% sure the new ones work.
But damn, forgot, no javac, php or mysql, back to the package manager. And looking at the df -k above I havn’t changes the quota value for /export/home yet. I wonder what other customisations will come to mind as I slowly try and get this snapshot back to the point I was at before breaking it last time. hmm, javac, mysql, php…
To do – investigate plan/b and areca as backup tools, at least with one of those there will be a remote backup solution in place.
Update 2008/10/12
Hmm, after finally getting it going in virtualbox and playing with the clone boots I’ve hit a minor issue.
If you set mountpoint=/opt on the cloned opt filesystem before rebooting, you get errors booting either the clone of the origional.
On the origional you just get /opt already mounted as it tries to mount the clone one as well, and you never get xwindows started, just a command line login.
On the clone, forget it, straight into service mode. BUT the service mode was beacuse it was complaining about invalid drivers etc from virtualbox… because an init 6 didn’t seem to update the boot archive; in the steps below I did exactly the same steps but always shutdown (instead of init 6) every change, and that worked a lot better.
So deleting my snapshots and clones, I redid the snapshot and clone but left both the new rootfs and opt as mountpont legacy, booted into the clone (no /opt as expected) and set the clones opt to mount on /opt from within the clone image. That worked, and it reboots perfectly.
But, rebooting from the origional while still mounting the origional /opt filesystem gives an error of /opt already mounted and remains in command line mode (xwindows never starts). This is not a problem as at least I can login, set the clone mount point back to legacy, and reboot ok if I really need to go back; but it would have to be only if going back as that would break the clone reboot again.
So cloning is not the wonderfull featute I thought it was.
still beats buying a second disk to do a live upgrade on though. But I have’nt tried an upgrade on zfs so maybe it won’t work ?.