By mrj on Jan 15, 2010
Now that we have zfs root, it's more difficult, and at the same time, much more powerful. zfs stores platform specific boot information in it's meta data which isn't easily accessed, making it more difficult. But, zfs supports live snapshots which makes it much more powerful.
With zfs, we can "easily move" the machine from one "machine" to another. This generally applies to S10 and Opensolaris, as long as it's running a zfs root.. You can go from a physical machine, VirtualBox guest, xVM guest, etc. to a different physical machine, VirtualBox guest, xVM guest, etc.
For an example, I thought I would share some tricks on how you can transform a x86 box running OpenSolaris to a VirtualBox guest without ever shutting down or rebooting the x86 box.
The first thing you want to do is boot a new VirtualBox guest with an OpenSolaris live install iso. You want to make sure that the zfs version in the install iso matches the zfs version on your x86 box.
Once you have booted the install iso, open a shell. Enable ssh, and then run format. Write down the disk your going to use (e.g. c4t0d0s0), then run fdisk from within format. Usually you will create a single disk partition for Solaris here.. Exit fdisk saving your changes.
Now partition your Solaris disk. Select the 0 partition, set the tag to "root" (without the quotes), and set the range from 1 to the last cylinder. Make sure partition 8 is set to 0 - 0 cylinders, then label the disk and exit format.
On your x86 box, write down your hostname and hostid info.
: core2#; hostname core2 : core2#; hostid 05bdb9c2 : core2#; echo "hw_serial,0xa?B" | mdb -k hw_serial: hw_serial: 39 36 33 31 39 39 33 38 0 0On your VirtualBox guest, update hostname and hostid to match your x86 system.
root@opensolaris:~# hostname core2 root@core2:~# hostid 00041f55 root@core2:~# echo "hw_serial/v 39 36 33 31 39 39 33 38 0 0" | mdb -kw root@core2:~# hostid 05bdb9c2 root@core2:~#Now, create the zfs root on the VirtualBox guest using the disk you saw in format. Make sure that you create the zpool on slice 0 (s0). If your moving multiple pools, you'll probably want to setup multiple pools on the guest now too.
zpool create -R /a -f rpool /dev/dsk/c4t0d0s0Back to the x86 system, snapshot the root pool, then send it to the opensolaris guest (which is 192.168.0.117 in my example). Do the same for all pools you want to move.
zfs snapshot -r rpool@p2v zfs send -R rpool@p2v | ssh firstname.lastname@example.org pfexec /usr/sbin/zfs receive -dF rpoolOnce this completes, if the x86 system is actively being used, you'll want to shut down the apps your using (e.g. databases, etc.), take a snapshot again, then do a differencing zfs send to do a final sync.
Back on the VirtualBox guest, lets finalize the disk. Set bootfs to the BE you want to boot.
zpool set bootfs='rpool/ROOT/--your-bootfs--' rpoolOn the VirtualBox guest, install grub
/a/sbin/installgrub /a/boot/grub/stage1 /a/boot/grub/stage2 /dev/rdsk/c4t0d0s0If your NICs are different, you need to update them. If you have hostname.--nic-- and dhcp.--nic-- files, update them to point to your new NIC(s). You may have neither. Or you may only have a hostname.--nic--. You may also have to update /a/etc/nwam/llp. For multiple BEs, don't forget to update the NICs in all the BEs you want to boot.
devfsadm -r /a -i e1000g mv /a/etc/hostname.--oldnic-- /a/etc/hostname.e1000g0 mv /a/etc/hostname.--oldnic-- /a/etc/dhcp.e1000g0If your using the same IP, you may want to take your x86 box off the net now... Eject the CDROM and reboot your VirtualBox guest... Hopefully it booted right up :-)