While we wait for the do-everything astromech droid to become a reality, ConnectWise Automate is the next best thing. With out-of-the-box scripts, around-the-clock monitoring, and unmatched automation capabilities, our RMM software will have you doing way more with less and bring real value to. THE GOAL Provide easy to use, accessible tools for creating UI for Powershell scripts. People all around the world are creating amazing automation using Powershell.
Download |
Usage and Limitations |
It implements the steps described in Section 9 of the VirtualBox manual - 9.9.1.1 Access to entire physical hard disk and 9.9.1.2 Access to individual physical hard disk partitions, running VBoxManage to perform the steps based on data you supply via VBoxRawdisk.
When the utility is initiated it scans the physical drives attached to your Mac and presents a table similar to that used by Disk Utility. When a drive is selected, key attributes of that device are displayed, enabling you to determine which drive contains the data you wish to use in VirtualBox.
VBoxRawdisk also reads the VirtualBox registry to determine which virtual machines you have configured. When a disk has been selected, the menu of virtual machines is enabled and you can proceed with generating the VMDK file.
Usage and Limitations
This is dangerous stuff and there is a very real risk of destroying data if you inadvertently choose the incorrect virtual machine, incorrect partitions or the wrong disk. Be warned!!Entire physical disk access is on the whole easier to use than accessing individual partitions and seems to have (slightly) fewer caveats.
Entire Disk (Preferred)
- All partitions on the disk are available for use by Virtual Box.
Individual Partitions
- This is difficult to configure. In VBoxRawdisk you select the partitions that you wish to use. Use command-click to select multiple partitions.
- Running VirtualBox under macOS, the VMDK file MUST be attached to an IDE controller. It just doesn't work when attempting to attach to a SATA controller. This may be a bug in VirtualBox. For now, VBoxRawdisk does this attachment to IDE for you.
- In general, you will need to use 2 partitions, the EFI partition (containing boot strap code) and the partition containing your OS. If you are attemting to run Linux as the guest OS, you will probably also want to add a small partition for use as swap.
- The VirtualBox manual indicates that it's possible to embed the bootstrap code inside the raw partition, but I have been unable to get this to work. Again, maybe a VirtualBox bug.
- I found it easier to initially configure individual partition access after having first made the host bootable from the partitions that will be used by VirtualBox. Its a bit of a chicken/egg situation and a lot of mucking around but the advantage is that you can then either run the guest OS virtually or alternatively, boot the hardware and run the OS in native mode.
General comments/limitations
- VBoxRawdisk does not create a virtual machine - you must use VirtualBox to do that, creating a new machine configured as required for the OS installed (or to be installed) on your raw drive.
- VBoxRawdisk will present a standard 'Save as' dialog for saving the generated VMDK file to somewhere on your machine. The default file name will be the same as the name of the selected virtual machine, so make sure you have selected things as you intended.
- VirtualBox requires ownership of the system device files (/dev/diskn*) associated with the selected disk. By default these device files are owned by the root user. You will see an authentication dialog enabling this change of ownership.
- Once created, your VMDK file will be added to the VirtualBox media registry. You can now cancel further operations in VBoxRawdisk and manually (i.e with VirtualBox) attach your VMDK to your virtual machine.
- VBoxRawdisk will optionally attach your VMDK to either SATA controller 0, port 0 (entire disk) or to an IDE controller (selected partitions). You should add the appropriate disk controller to your virtual machine configuration.
- VBoxRawdisk will optionally attempt to start the virtual machine.
Download VBoxRawdisk 1.3.7
VBoxRawdisk 1.3.7 - Changes and FeaturesChanges
- Compiled with Xcode 12.4
- Get VM configuration directory from VirtualBox.
Download VBoxRawdisk 1.3.6
VBoxRawdisk 1.3.6 - Changes and FeaturesChanges
- Compiled with Xcode 12.2 for Big Sur
- Unmount APFS volumes associated with the disk.
- Cache the disk images.
Download VBoxRawdisk 1.3.5
VBoxRawdisk 1.3.5 - Changes and FeaturesChanges
- Compiled with Xcode 11, Swift 5.1
- Hide APFS volumes - VirtualBox cannot use them.
- Disks are now sorted by BSD unit number.
- Fixed minor memory leak.
Download VBoxRawdisk 1.3.4
VBoxRawdisk 1.3.4 - Changes and FeaturesEnhancements
- Compiled with Xcode 10.2, Swift 5
Download VBoxRawdisk 1.3.3
VBoxRawdisk 1.3.3 - Changes and FeaturesEnhancements
- Sparkle updated to version 1.21.2.
- Check device permissions before propmpting to change.
- Relaunch if VBoxRawdisk has been translocated.
- Use new Preferences framework.
Download VBoxRawdisk 1.3.2
VBoxRawdisk 1.3.2 - Changes and Features- VBoxRawdisk is now notarized by Apple.
Download VBoxRawdisk 1.3.1
VBoxRawdisk 1.3.1 - Changes and Features- Built with Xcode 10, Swift 4.2.
Download VBoxRawdisk 1.3.0
VBoxRawdisk 1.3.0 - Changes and Features- Update to Swift 4.
- Improved raw partition support.
Download VBoxRawdisk 1.2.0
VBoxRawdisk 1.2.0 - Changes and Features- Use raw partitions (previously only entire disk).
- Access to system utilities (Disk Utility and Terminal) from the toolbar.
- Added Help links.
Download VBoxRawdisk 1.1.0
VBoxRawdisk 1.1.0 - Changes and Features- Option to start VM headless.
- New Icon.
- Save/Restore default settings.
- VM menu sorted by most recently used.
Download VBoxRawdisk 1.0.0
VBoxRawdisk 1.0.0 - Changes and Features- First public release
- If you have found VBoxRawdisk to be useful ...
... please consider making a donation to ensure the ongoing development and maintenance of the software.
Friday 9th November 2018
I recently acquired a computer with an OEM/factory-imaged Windows 10 disk inside. Straight away I took the disk out and replaced it with a Linux SSD, however since I don't own any other Windows systems, this will come in useful for testing my website for browser compatibility in Internet Explorer and Edge.
I have put the Windows 10 disk in a USB SATA drive enclosure, and configured VirtualBox to be able to boot the raw disk. Now I'm able to test my site in IE and Edge usng the virtual machine running on my system.
Skip to Section:
Identifying the Disk
Mounting the disk/partitions is not actually required for VirtualBox to be able to boot it, however you will need to identify the correct block device ID for the disk (e.g. /dev/sdb
).
If you're using a modern desktop environment and file manager (e.g. XFCE with Thunar), the Windows 10 disk will probably be automatically mounted (if you get stuck at the error 'Windows is hibernated, refused to mount.', please see the troubleshooting here). In my case, the Windows
and Recovery Image
partitions were auto-mounted. Then, you can use lsblk
(List Block Devices) to identify the correct device. For example:
From this, you can determine that /dev/sdb
is the Windows 10 disk.
If your disk is not automatically mounted, you don't need to mount it. You can use lshw
to determine the correct device. For example:
From this example output, you can see that /dev/sdb
is the Windows 10 disk. This may differ for you though.
For the rest of this document, I will refer to the correct block device ID for your system as /dev/sdX
. Make sure to substitute this with the correct one for your system in commands that you execute.
File System Permissions
In order to have full, unrestricted access to the Windows 10 disk without having to use sudo
, you need to give your user account the appropriate permissions.
There are two main ways that this can be configured. The proper, higher-security method which is best for production/important systems, or the quicker, lower-security method which is suitable for test/disposable systems. You can choose which is best for you - you only need to complete one of them.
Higher-Security File System Permissions Configuration
If you are using a system where security is important, the best way to achieve this is to create a udev rule to match the Windows 10 disk and assign it to a particular group. Then, your non-privileged user account will have full read-write access to the disk(s) that match the rule, while the others remain protected.
First, create a new group to use for the Windows 10 disk:
Then add your own user to the group:
Next, you need to determine the UUID of the Windows 10 disk. You can do this using udevadm
:
This should output the UUID of the Windows 10 disk. For example:
E:
means that it's a device environment variable, and the variable could be ID_PART_TABLE_UUID
, ID_FS_UUID
or something else with a similar meaning.
If no UUID is outputted, try omitting the grep
and looking for other variables that contain the UUID. If for some reason no UUID is returned, you may be able to use other attributes to uniquely identify the disk, however this may result in inaccuracies.
Take a copy of the variable name and UUID, and create a file in the udev rules directory, such as /etc/udev/rules.d/99-win10disk.rules
. Edit the file and add the following content, adjusting the variable name, UUID and group as required:
Make sure to pay attention to the operators used in the rule. Like in most programming languages, is an equality check and =
is an assignment, so make sure to get these the right way around in the rule. You want to be checking the UUID and assigning the group, not the other way around!
Save the file, then power cycle the Windows 10 disk (disconnect and reconnect, reboot, etc).
Then, check that the rule worked by listing the block device file and checking the group:
This should output similar to the following:
The key attribute to check is that the group is win10disk
. If it is, then the file system permissions are configured correctly and you can proceed to the next section.
Lower-Security File System Permissions Configuration
On the other hand, if you're using a system where security is less important (such as a disposable test machine), there is a quicker method. First, determine the group that has access to the drive:
This will output something like the following:
From this, you can determine that the group is disk
, and that this group has read and write access to the block device (brw-rw----
).
The group name and permissions may differ for you, however in many cases it will be as above.
Next, add your user to the group. Please be aware of the potential security implications of this, as you will probably be giving your user account full read-write access to some or all storage devices. If the group is something else such as root
, you should consider the higher-security setup instead.
VirtualBox Raw Host Access VMDK File
In order for VirtualBox to be able to boot the physical Windows 10 disk, you need to a create a special VMDK (Virtual Machine Disk) file that represents the physical disk.
These raw host disk access VMDK files do not actually contain any data from the physical disk, they are just a pointer that VirtualBox can use to access it.
You can create a VirtualBox raw disk image using VBoxManage
. You can specify a location in the -filename
argument:
This should output something similar to the following:
The raw host disk access VMDK file only contains ASCII test, so you can cat
or less
it and have a look!
Creating and Configuring the Virtual Machine
Now that the raw host disk access VMDK has been created, you need to create a new VM and boot from it.
Just set up a virtual machine as you normally would. Make sure to choose the correct type and version.
When you get to the 'Hard disk' section, select 'Use an existing virtual hard disk file', and choose the VMDK file that you created in the previous step.
Once you have completed the initial setup wizard, open the settings for the virtual machine, give it some extra CPU cores if possible, then set the boot order to 'Hard Disk' first, with all other options disabled.
If the Windows 10 install on the disk is an EFI install, make sure to tick the 'Enable EFI' box.
Save the settings, and then boot the virtual machine. If everything has worked, Windows 10 should boot up successfully.
If this is the first time you've booted the drive (it was for me), you'll have to go through the initial Windows 10 setup process where you choose the region, language, keyboard layout, etc. Cortana started speaking to me during the setup process so watch out for that!
Once you're all done with setup, Windows 10 should boot to the desktop successfully.
If you want to be able to make Windows 10 full screen, etc, install the VirtualBox Guest Additions using Devices -> Insert Guest Additions CD image...
, then run the installer in the virtual machine.
Once this is complete, reboot the virtual machine and Windows should automatically display in full screen. If not, you should be able to manually set your resolution using the display settings in Windows.
When it comes to Windows Product Activation, I'm not really able to advise. I've heard that Windows will often become unactivated when changing hardware, however in my case the activation remained. This may be because I never actually fully booted the Windows 10 disk when it was in the original desktop machine.
Troubleshooting: Windows is Hibernated, Refused to Mount
Vbox Create Raw Disk
When mounting the Windows 10 disk, you may see the following error:
This can occur if Windows 10 is hibernated, or was otherwise not correctly shut down.
In order to fix this you need to remove the hibernation file. This can be done using mount
.
In the command examples below, make sure to change N
in /dev/sdXN
to the partition number of the main Windows partition. Also change the X
to the correct block device ID as usual.
Please be aware that this will permanently erase the hibernation file, so any data not properly saved will be lost.
Conclusion
I'm pleasantly surprised that this worked - I was expecting Windows to fail to boot or at least have serious problems due to the drastic change in hardware from the original machine, but it seems to work fine.
I'm going to use this VM to test my website for compatibility in Internet Explorer and Edge, in order to make sure that everything is presented as best as it can be.
Vbox Raw Disk
On a side note, look how much bloatware came pre-installed on this. It's just a standard Windows 10 disk pulled from a shop-bought HP desktop machine... unbelievable!
Vbox Raw Disk Access
Luckily this is in a VM on my segregated test machine. I wouldn't want to be exposing all that to my network!