VBoxRawdisk

broken image


  1. Vbox Raw Disk
  2. Vbox Raw Disk Access
  • The wrong place for a cooking competition. At lease it was the wrong place for the late Maxwell Gregory. Each of the chef-contestants had a history with Gregory, and none of the histories was pleasant.
  • To use a raw disk in our virtual machine we must create a special VMDK file and then to use it when adding a hard drive to our virtualbox virtual machine with 'Use an existing virtual hard disk dile'. Here are the right steps to add a raw disk: STEP 1) Permissions – your user must have (write) permissions to access raw disks.

I have written VBoxRawdisk, a utility for macOS to help use a raw disk with VirtualBox. This is the first release and should be considered alpha level software. The software does nothing that you can't do manually with VBoxManage, diskutil and the command line. VBoxRawdisk is a small utility that makes it a little easier to generate the raw disk (VMDK) file required to load a real disk drive into VirtualBox. Download VB.Net PDF 2021.1.29 from our software library for free. The most popular versions among the software users are 2020.9, 2020.6 and 2020.3. The latest installation package that can be downloaded is.

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

Vbox

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

Vbox Raw Disk

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).

VBoxRawdisk

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

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

Vbox

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

Vbox Raw Disk

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

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.

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!

Luckily this is in a VM on my segregated test machine. I wouldn't want to be exposing all that to my network!

View recently run applicationsRecentApps
Create ISO file from a macOS InstallerInstallerApp2ISO
Utility for monitoring file activityFileWatcher
Utility for monitoring/controlling Macintosh fansPhantasmic
Utility for changing macOS system name componentsSystemName
Utility for generating VirtualBox raw disk VMDK filesVBoxRawDisk
Utility for configuring and monitoring the chronyd NTP daemonChronyControl
Enable or disable individual CPU coresCPUSetter
Text-to-speech network initiated messagesSquawker

Vbox Raw Disk Access

  • If you have found any of this software to be useful ...
    ... please consider making a donation to ensure the ongoing development and maintenance.




broken image