This is a discussion on Stupid VirtualBox & ZFS Tricks - Solaris Rss ; So the other day I had the idea to flip things around, instead of running a Windows 7 guest within an OpenSolaris host (with virtualbox) on my desktop, run an OpenSolaris guest within a Windows 7 host. I thought I'd ...
So the other day I had the idea to flip things around, instead of running a Windows 7 guest within an OpenSolaris host (with virtualbox) on my desktop, run an OpenSolaris guest within a Windows 7 host.
I thought I'd do this on my primary desktop at work. The only problem is that I have a ZFS pool that contains the large majority of all my work at Sun over the nearly 20 years. Without access to that, the whole "experiment" would be of little use.
Fortunately the pool was on a second set of disks in the desktop, so I could happily leave it alone while I did the first part of the switch, install Windows 7 (64bit) and VirtualBox on bare metal, and then an OpenSolaris guest. This was all pretty straight forward, nothing additional I can offer over what is out there already.
Now the interesting part(s), first hurdle, how do I get VirtualBox to recognize the physical disks the ZFS pool resides on. After a little web searching, it ended up being pretty easy, the key is to use the VBoxManage internalcommands createrawvmdk command that VirtualBox provides.
Using this command, you can create a vmdk definition that points to a physical disk or partition. In my case, I wanted to point to the entire disk, so I used the following commands.
VBoxManage internalcommands createrawvmdk -filename C:\Users\Mocker\.VirtualBox\HardDisks\PhysicalDriv e2.vmdk" -rawdisk \\.\PhysicalDrive2 -registerVBoxManage internalcommands createrawvmdk -filename C:\Users\Mocker\.VirtualBox\HardDisks\PhysicalDriv e3.vmdk" -rawdisk \\.\PhysicalDrive3 -register Now, here's the rub, in order to do this, VBoxManage needs to be run as administrator. Windows 7 apparently has some pretty tight restrictions on who/what is allowed to access raw disks. One of the easier ways to do this is to just run a command shell as administrator, which will then execute VBoxManage as administrator.
I did this by simply clicking the Start menu, entering "cmd" in the search box, which will present cmd.exe as a result, right click on cmd.exe and select "Run as Administrator".
Ok so now I had created vmdks for the physical drives. I needed to attach them as virtual disks to my OpenSolaris guest. I just used the VirtualBox UI for this. Click on the guest (make sure its not running), then click on the Storage section of the configuration, Add a couple of hard disks using the "Add Hard Disk" button of the IDE controller, then select the physical drive vmdks for each.
Note, same rub as above applies, I needed to run VirtualBox as administrator. This is getting to be a drag.
Finally, the moment of truth, time to fire up the OpenSolaris guest, and see if it will recognize the ZFS pool...
After the guest booted up, I logged in, using the format command, I could see the guest recognized the new disks, good.
Next, I ran zpool import, and, drum roll, yes, it indeed found my ZFS pool!
Finally, I ran zpool import and voila! OpenSolaris happily imported the pool - lock, stock and barrel --
# zpool status storage pool: storage state: ONLINE scrub: none requestedconfig: NAME STATE READ WRITE CKSUM storage ONLINE 0 0 0 mirror-0 ONLINE 0 0 0 c8d1s0 ONLINE 0 0 0 c7d1s0 ONLINE 0 0 0 One caveat, I noticed Windows 7 doesn't play well with EFI labels. Although this initial attempt worked fine, later on I found that the pool became inaccessible after reboots of the guest. Running the Disk Management tool in Windows would complain about these two disks since they had EFI labels on them.
I managed to fix this pretty easily though, I simply booted back into OpenSolaris on bare metal (yeah, I actually created a dual boot system), then though a process of zfs detach, format, zfs attach, I relabeled the disks and Windows 7 was much happier.