Hi Jignesh, * Jignesh K. Shah (J.K.Shah at Sun.COM) wrote: > > Hello, > > For past couple of days I have been working on distro constructor to > figure out how we can use it to create a RAW disk image consisting of > "custom" opensolaris virtual appliances (read minimized without desktop > features) which then as needed can be converted to either VDI or VMDK or > AMI (Amazon EC2 images). > > The concept that I am using is simple: I created my own virtapp.xml > (ala slim_cd.xml) with minimum packages that I need and at the end > where slim_cd create ISO image I create an hdd image formed by using > lofiadm on a blank file which acts as my logical empty hard disk of a > fixed size say 3GB and then I create a zpool on top of that lofi device > and in the end I have an hard disk image which I can convert to VDI > format using VBoxManage convertdd or any other format. > > However I am seeing few problems: > My biggest problem that I have encountered is installing grub on this > lofi device > installgrub fails if I use the following (lofi presents /dev/rlofi/1 as > a character acess) > > First of all /boot/solaris/update_grub returns but it actually fails > while using lofi device (without throwing any message)... > > Doing the individual components I found the script update_grub is not > handling zpools devices which are special devices for example it tries > to prepend /dev/rdsk to every device it finds even if it is /dev/lofi/1 > > Secondly if I try to do the same steps manually I get two problems > > First bootadm update on a lofi device throws error: > # bootadm update-menu -Z -R /mnt -o /dev/rlofi/1 > bootadm: invalid device /dev/rlofi/1: cannot determine pool name > bootadm: failed to get pool for device: /dev/rlofi/1 > bootadm: invalid device /dev/rlofi/1: cannot determine pool name > bootadm: failed to get pool name from /dev/rlofi/1 > bootadm: failed to create GRUB boot signature for device: /dev/rlofi/1 > bootadm: failed to get grubsign for root: /mnt, device /dev/rlofi/1 > > > or even if I try the regular block access /dev/lofi/1 > # bootadm update-menu -Z -R /mnt -o /dev/lofi/1 > bootadm: invalid device /dev/lofi/1: cannot determine pool name > bootadm: failed to get pool for device: /dev/lofi/1 > bootadm: invalid device /dev/lofi/1: cannot determine pool name > bootadm: failed to get pool name from /dev/lofi/1 > bootadm: failed to create GRUB boot signature for device: /dev/lofi/1 > bootadm: failed to get grubsign for root: /mnt, device /dev/lofi/1 > > > > The second problem with the manual approach is using installgrub on lofi > device.. > # installgrub /mnt/boot/grub/stage1 /mnt/boot/grub/stage2 /dev/rlofi/1 > mount: /dev/lofi/1 is not a DOS filesystem. > cannot mount /dev/lofi/1 > > I can potentially try it with an actual hard disk but I don't have any > spare one right now and thought I could leverage lofi to do the magic > but guess not.. Does anybody have any other ideas?
I've been working on exactly this sort of thing (creating pre-constructed virtualbox images for OpenSolaris 2008.x). You'll have much better luck using a 'real' disk. As you've found out, various tools don't understand how to deal with 'pseudo' disk-like things. Even using a ZVOL straight up doesn't work (you'll get the same error as when trying to write to a lofi device). That said, once you've populated your disk, you'll need to 'doctor' it before it will boot normally in virtualbox. What I'm doing is I create a raw disk in virtualbox that points to the physical disk I've installed to. Then I create a vm using that raw disk. I also attach an OpenSolaris liveCD to the vm and boot the vm using the livecd. Once booted, I zfs import the pool on the 'raw' disk, beadm mount the only boot environment available (opensolaris in my case) and then run the following commands: devfsadm -C -r /<mountpoint of be> devfsadm -c disk -r /<mountpoint of be> Then just beadm unmount the boot environment and reboot the vm (from the raw disk instead of the liveCD) and the system boots up just fine. I haven't tried to convert the raw disk at this point into a straight vdi file. And naturally having to boot the raw disk in vbox under a liveCD to run the devfsadm commands isn't exactly the picture of automation I'm shooting for. I'm still doing some investigation. Anyway, hopefully some of this is useful for you. Cheers, -- Glenn