Hi everyone,
I am not sure if this is possible, but I'd like to somehow mount a physical zfs pool (2 disks) on an Ubuntu VM running inside a Windows 10 host. I have already successfully mounted the ZFS pool on a real Ubuntu installation, but would prefer to run Ubuntu as a VM instead of dual-booting or running a separate physical machine if possible.
Are there any guides on how to do this, or a quick rundown on how it could be done? I did some searching but didn't seem to turn up anything that inspired a lot of confidence. Thanks!
Mounting Physical ZFS Pool on Ubuntu Guest/Windows 10 Host
-
- Posts: 1
- Joined: 1. Mar 2016, 05:50
-
- Site Moderator
- Posts: 20965
- Joined: 30. Dec 2009, 20:14
- Primary OS: MS Windows 10
- VBox Version: PUEL
- Guest OSses: Windows, Linux
Re: Mounting Physical ZFS Pool on Ubuntu Guest/Windows 10 Ho
There is a way to use physical disks in a guest, it's called raw disk access. See section 9.9.1 in the help file. It's an experts-only feature, quite possibly resulting in data loss while one is learning how to use it. Be prepared to poke a hole in your pool accidentally & have to patch it and refill it from a backup.
Re: Mounting Physical ZFS Pool on Ubuntu Guest/Windows 10 Host
Has there been any progress making this less error prone?
I need to do the same physical mount of a ZFS mirrored pair under an Ubuntu guest of a Windows host -- only difference being I'm running Windows 7 rather than Windows 10.
I need to do the same physical mount of a ZFS mirrored pair under an Ubuntu guest of a Windows host -- only difference being I'm running Windows 7 rather than Windows 10.
-
- Site Moderator
- Posts: 20965
- Joined: 30. Dec 2009, 20:14
- Primary OS: MS Windows 10
- VBox Version: PUEL
- Guest OSses: Windows, Linux
Re: Mounting Physical ZFS Pool on Ubuntu Guest/Windows 10 Host
I have just successfully run a raw-disk access guest using a USB-attached physical drive on a Windows host. It is not foolproof, but it can be done carefully.
First, the designation for physical drives on Windows is "\\.\PhysicalDrive#" (without the double-quotes). You can see the # of the desired disk in Disk Management or in DISKPART. In my experiment the numbers of the disks listed in Disk Management and DISKPART matched; I haven't tried this enough to see if they always match. Now here's the ticklish part: Through reboot or shutdown, the disk numbers might change. Or if you are raw-disk-ing a USB drive, and you unplug the drive then replug it later, its number might change. So you can't always assume that just because the drive was #6 last time it will always be #6. Next boot, your drive with all your movies, family photos, and 2000 LP's carefully WAV-encoded de-noised and de-popped, might be drive #6, then you boot your guest on it and - oops! Thus the warning that raw-disk is an expert feature. You will have to double-check each time that the drive number for your desired disk hasn't changed. This double-check may be scriptable.* You will have to be able to Run-As-Administrator the Disk Management console and the command window launching DISKPART, and probably your double-check script as well.
Second, raw-disk on a Windows host requires the main Virtualbox program or the command window for the Vboxmanage commands to be Run-As-Administrator. This means there are more attack vectors for malware on the host. Virtualbox is a secure program, but it, like all hypervisors, punches all sorts of holes in the PC security paradigm to allow more than one operating system to use the PC at once. So you should not run Virtualbox as Administrator under normal usage, unless you can lock down your host from malware really well.
* re scripting:
From Stack Overflow, Hans Olsson's answer, this VBscript will match disk letter and disk number using WMI:
It may also be possible to skip drive letters and go for drive serial numbers instead. You may be able to cobble together a decent disk number doublechecker to establish data for automatic Vboxmanage commands to prepare your guest raw disk right every time.
First, the designation for physical drives on Windows is "\\.\PhysicalDrive#" (without the double-quotes). You can see the # of the desired disk in Disk Management or in DISKPART. In my experiment the numbers of the disks listed in Disk Management and DISKPART matched; I haven't tried this enough to see if they always match. Now here's the ticklish part: Through reboot or shutdown, the disk numbers might change. Or if you are raw-disk-ing a USB drive, and you unplug the drive then replug it later, its number might change. So you can't always assume that just because the drive was #6 last time it will always be #6. Next boot, your drive with all your movies, family photos, and 2000 LP's carefully WAV-encoded de-noised and de-popped, might be drive #6, then you boot your guest on it and - oops! Thus the warning that raw-disk is an expert feature. You will have to double-check each time that the drive number for your desired disk hasn't changed. This double-check may be scriptable.* You will have to be able to Run-As-Administrator the Disk Management console and the command window launching DISKPART, and probably your double-check script as well.
Second, raw-disk on a Windows host requires the main Virtualbox program or the command window for the Vboxmanage commands to be Run-As-Administrator. This means there are more attack vectors for malware on the host. Virtualbox is a secure program, but it, like all hypervisors, punches all sorts of holes in the PC security paradigm to allow more than one operating system to use the PC at once. So you should not run Virtualbox as Administrator under normal usage, unless you can lock down your host from malware really well.
* re scripting:
From Stack Overflow, Hans Olsson's answer, this VBscript will match disk letter and disk number using WMI:
Code: Select all
Dim query
Dim objWMI
Dim diskDrives
Dim diskDrive
Dim partitions
Dim partition ' will contain the drive & partition numbers
Dim logicalDisks
Dim logicalDisk ' will contain the drive letter
Set objWMI = GetObject("winmgmts:\\.\root\cimv2")
Set diskDrives = objWMI.ExecQuery("SELECT * FROM Win32_DiskDrive") ' First get out the physical drives
For Each diskDrive In diskDrives
query = "ASSOCIATORS OF {Win32_DiskDrive.DeviceID='" + diskDrive.DeviceID + "'} WHERE AssocClass = Win32_DiskDriveToDiskPartition" ' link the physical drives to the partitions
Set partitions = objWMI.ExecQuery(query)
For Each partition In partitions
query = "ASSOCIATORS OF {Win32_DiskPartition.DeviceID='" + partition.DeviceID + "'} WHERE AssocClass = Win32_LogicalDiskToPartition" ' link the partitions to the logical disks
Set logicalDisks = objWMI.ExecQuery (query)
For Each logicalDisk In logicalDisks
Wscript.Echo logicalDisk.DeviceID & " - " & partition.Caption
Next
Next
Next