Run guest VM Linux partition located on same physical disk as Windows host

Discussions related to using VirtualBox on Windows hosts.
Post Reply
cheater00
Posts: 3
Joined: 6. Jun 2019, 09:28

Run guest VM Linux partition located on same physical disk as Windows host

Post by cheater00 »

I have a dual boot between Windows 10 and Ubuntu 18.04 using grub-efi. I would like to be able to run Windows 10 as host, and under that, launch the Linux partition as a guest VM under VirtualBox. There is an EFI partition, a Windows 10 partition, and a Ubuntu partition, all on the same physical disk. It appears under Windows 10 as Disk 1. EFI is partition 2, Windows is partition 4, Linux is partition 5. I have created a VirtualBox vmdk using the command:

Code: Select all

.\VBoxManage.exe internalcommands createrawvmdk -filename C:\VirtualBox\linux_and_efi_ro.vmdk -rawdisk \\.\PhysicalDrive1 -partitions 2r,5
grub boots up correctly and allows me to select Ubuntu in its menu. When I run the system, however, I get a non-fatal error.

This is taken from the VM's log file:

Code: Select all

00:05:13.338938 Changing the VM state from 'SUSPENDED' to 'RESUMING'
00:05:13.339747 AIOMgr: Endpoint for file 'C:\VirtualBox\linux_and_efi_ro.vmdk' (flags 00040723) created successfully
00:05:13.339927 AIOMgr: Endpoint for file 'C:\VirtualBox\linux_and_efi_ro-pt.vmdk' (flags 000c0723) created successfully
00:05:13.340637 AIOMgr: Endpoint for file '\\.\PhysicalDrive1' (flags 000c0781) created successfully
00:05:13.340682 AIOMgr: Async flushes not supported
00:05:13.340929 AioMgr0-N: Request 0x000000144f2c70 failed with rc=VERR_ACCESS_DENIED, migrating endpoint \\.\PhysicalDrive1 to failsafe manager.
00:05:13.341083 Changing the VM state from 'RESUMING' to 'RUNNING'
00:05:13.341090 Console: Machine state changed to 'Running'
00:05:13.341308 VM: Raising runtime error 'BLKCACHE_IOERR' (fFlags=0x6)
00:05:13.341336 Changing the VM state from 'RUNNING' to 'SUSPENDING'
00:05:13.343510 AIOMgr: Endpoint for file 'C:\VirtualBox\linux_and_efi_ro.vmdk' (flags 00040781) created successfully
00:05:13.343631 AIOMgr: Endpoint for file 'C:\VirtualBox\linux_and_efi_ro-pt.vmdk' (flags 000c0781) created successfully
00:05:13.344119 AIOMgr: Endpoint for file '\\.\PhysicalDrive1' (flags 000c0781) created successfully
00:05:13.441570 PDMR3Suspend: 100 209 505 ns run time
00:05:13.441583 Changing the VM state from 'SUSPENDING' to 'SUSPENDED'
00:05:13.441591 Console: Machine state changed to 'Paused'
00:05:13.441670 Console: VM runtime error: fatal=false, errorID=BLKCACHE_IOERR message="The I/O cache encountered an error while updating data in medium "ahci-0-0" (rc=VERR_ACCESS_DENIED). Make sure there is enough free space on the disk and that the disk is working properly. Operation can be resumed afterwards"
00:05:36.791668 GUI: UIMediumEnumerator: Medium-enumeration started...
00:05:37.323406 GUI: UIMediumEnumerator: Medium-enumeration finished!
Here is a screenshot of the console when running Ubuntu in recovery mode:
VirtualBox drive read error - Capture.PNG
VirtualBox drive read error - Capture.PNG (83.6 KiB) Viewed 3761 times
The error first happens when the following line appears:

Code: Select all

/dev/sda5: recovering journal
. Then I have to press ctrl-p to continue rendering the console, and after pressing it about 50x another line has rendered.

There are guides out there that tell you how to virtualize a physical partition that is located on a different disk than windows is on. Those guides suggest taking the disk that contains Linux offline in Windows. Putting Linux on a different drive is not an option for me. I could put grub (or another small boot loader or small file system) on another disk (e.g. usb stick), but I can't put Linux itself on another drive.

If this is possible with another virtualization option, please let me know.

I would appreciate any and all pointers on this topic. Thanks!
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Run guest VM Linux partition located on same physical disk as Windows host

Post by scottgus1 »

The manual, section 9.8.1, has info on raw disk access. It does suggest that using a partition from a disk is possible (9.8.1.2).

When I have used raw disk access, I have used the whole disk, not just a partition. But on my Windows hosts I have had to run the main Virtualbox window as Admin then start the guest to get raw disk access to work. I am rather certain that I had to take the disk offline in Disk Management before running the guest, but I don't remember exactly. You won't be able to offline your disk, because the host OS is running from it.

A bit of googling and investigating Diskpart on my Windows 10 host shows me that off-lining a disk or a volume is possible, but not a partition. If running Virtualbox as admin then running the guest doesn't work, then you may be stuck if you have to keep everything on the one disk drive.
cheater00
Posts: 3
Joined: 6. Jun 2019, 09:28

Re: Run guest VM Linux partition located on same physical disk as Windows host

Post by cheater00 »

Thanks. I tried running the VirtualBox Manager as admin and then running the VM, with the same result. How do I know that the VM itself is running as an administrator?
socratis
Site Moderator
Posts: 27329
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: Run guest VM Linux partition located on same physical disk as Windows host

Post by socratis »

cheater00 wrote:I tried running the VirtualBox Manager as admin and then running the VM, with the same result.
You have absolutely nothing to gain by running VirtualBox as Administrator. Let me repeat that; ABSOLUTELY NOTHING!
scottgus1 wrote:But on my Windows hosts I have had to run the main Virtualbox window as Admin then start the guest to get raw disk access to work
Not sure why you had to do that...
scottgus1 wrote:The manual, section 9.8.1, has info on raw disk access. It does suggest that using a partition from a disk is possible (9.8.1.2).
The problem is that you can't offline a partition in Win10, you can on Linux/OSX. There's no solution, no workaround. Win10 is way more restrictive these days. Yes, VirtualBox allows you to create a VMDK from a partition. But... in order to use said partition as a raw disk, your host OS needs to give you the permission to do so. And Win10 won't.

I suggest a 2nd HD. Use Clonezilla or any other tool of your preference to create that mirror of your Linux OS. You can still dual boot from your BIOS. Most BIOS offer a choice to select the boot disk at startup. Same thing as a multi-boot single HD, but without the fuss...
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
cheater00
Posts: 3
Joined: 6. Jun 2019, 09:28

Re: Run guest VM Linux partition located on same physical disk as Windows host

Post by cheater00 »

I've got a small update. If I use the vmdk with read-write access to the Linux partition, and set the sata controller to "Use Host I/O Cache", then I don't get the repeated BLKCACHE_IOERR non-fatal error. However, Linux still can't write to the partition.
socratis
Site Moderator
Posts: 27329
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: Run guest VM Linux partition located on same physical disk as Windows host

Post by socratis »

cheater00 wrote:However, Linux still can't write to the partition.
...because your host won't allow it!
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Run guest VM Linux partition located on same physical disk as Windows host

Post by scottgus1 »

scottgus1 wrote:But on my Windows hosts I have had to run the main Virtualbox window as Admin then start the guest to get raw disk access to work
socratis wrote:Not sure why you had to do that...
Good question! I did some experiments on a new topic so I don't hijack this thread:
viewtopic.php?f=6&t=93478
Post Reply