Using a physical drive on a virtual machine
-
- Posts: 25
- Joined: 13. Jun 2011, 22:45
- Primary OS: openSUSE
- VBox Version: OSE other
- Guest OSses: WinXP
Using a physical drive on a virtual machine
It is possible for a virtual machine to mount a physical drive? It only seems to want to make/use virtual drives.
I'm running a Ubuntu 10.04 host and Oracle VirtualBox 4.0.8.
I'm running a Ubuntu 10.04 host and Oracle VirtualBox 4.0.8.
-
- Volunteer
- Posts: 7639
- Joined: 7. Jun 2007, 21:53
Re: Using a physical drive on a virtual machine
Yes, its possible. But its a feature for professionials because of disk may get corrupted.
Its decribed in the manual (raw disk access). But first use the standard mode (guest on a vdi image), so that you know, what virtualization is.
Its decribed in the manual (raw disk access). But first use the standard mode (guest on a vdi image), so that you know, what virtualization is.
German Howto (Linux): http://www.linuxforen.de/forums/showthread.php?t=236444
User Manual / Download Section: http://www.virtualbox.de/wiki/Downloads
FAQ: http://www.virtualbox.de/wiki/User_FAQ http://forums.virtualbox.org/viewtopic.php?t=8669
User Manual / Download Section: http://www.virtualbox.de/wiki/Downloads
FAQ: http://www.virtualbox.de/wiki/User_FAQ http://forums.virtualbox.org/viewtopic.php?t=8669
-
- Posts: 25
- Joined: 13. Jun 2011, 22:45
- Primary OS: openSUSE
- VBox Version: OSE other
- Guest OSses: WinXP
Re: Using a physical drive on a virtual machine
Hmm, yes I see. Could I add it as read-only? I have to need no write to the drive.
But I'm running into a few problems:
But I'm running into a few problems:
- I tried but it told me
Code: Select all
VBoxManage internalcommands createrawvmdk -filename /home/angus/VirtualBox\ VMs/XP/my_hdd.vmdk -rawdisk /dev/sda
VBoxManage: error: Cannot open the raw disk '/dev/sda': VERR_ACCESS_DENIED - Assuming it was a permissions issue I put a sudo in front of it, and it worked
- Now trying to add my_hdd.vmdk in the GUI gave me:
and for details:Failed to open the hard disk /home/angus/VirtualBox VMs/XP/my_hdd.vmdk.Result Code:
NS_ERROR_FAILURE (0x80004005)
Component:
Medium
Interface:
IMedium {9edda847-1279-4b0a-9af7-9d66251ccc18}
Callee:
IVirtualBox {d2de270c-1d4b-4c9e-843f-bbb9b47269ff} - Then, assuming it was because it'd created my_hdd.vmdk as owned by root, I changed the ownership and group to angus, but I still get the same error.
- returns
Code: Select all
VBoxManage storageattach XP --storagectl "IDE Controller" --port 0 --device 0 --type hdd --medium /home/angus/VirtualBox\ VMs/XP/my_hdd.vmdk
(although, this might not be what I wanted it to do, because the manual promises that the vm will boot off the physical disk)VBoxManage: error: The medium '/home/angus/VirtualBox VMs/XP/my_hdd.vmdk' can't be used as the requested device type
VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component Medium, interface IMedium, callee nsISupports
Context: "OpenMedium(Bstr(pszFilenameOrUuid).raw(), enmDevType, AccessMode_ReadWrite, pMedium.asOutParam())" at line 209 of file VBoxManageDisk.cpp
VBoxManage: error: Invalid UUID or filename "/home/angus/VirtualBox VMs/XP/my_hdd.vmdk"
-
- Posts: 3
- Joined: 23. Jun 2011, 10:53
- Primary OS: Ubuntu other
- VBox Version: OSE Debian
- Guest OSses: FreeBSD
- Location: Hobart, Tasmania, Australia
Re: Using a physical drive on a virtual machine
I'm having exactly the same issue. Have you managed to to find a solution?
-
- Volunteer
- Posts: 17798
- Joined: 17. Mar 2008, 13:41
- Primary OS: Debian other
- VBox Version: PUEL
- Guest OSses: Windows XP, Windows 7, Linux
- Location: /dev/random
Re: Using a physical drive on a virtual machine
Direct disk access is a special privilege that is dangerous to have. So only the disk user and root can access them in read/write raw mode. You found that out when creating the VMDK.
You can't use RAW disk and make it read only. Especially when using it for boot. Want to access the files, use network shares or shared folders.
You can't use RAW disk and make it read only. Especially when using it for boot. Want to access the files, use network shares or shared folders.
Read the Forum Posting Guide before opening a topic.
VirtualBox FAQ: Check this before asking questions.
Online User Manual: A must read if you want to know what we're talking about.
Howto: Install Linux Guest Additions
Howto: Use Shared Folders on Linux Guest
See the Tutorials and FAQ section at the top of the Forum for more guides.
Try searching the forums first with Google and add the site filter for this forum.
E.g. install guest additions site:forums.virtualbox.org
Retired from this Forum since OSSO introduction.
VirtualBox FAQ: Check this before asking questions.
Online User Manual: A must read if you want to know what we're talking about.
Howto: Install Linux Guest Additions
Howto: Use Shared Folders on Linux Guest
See the Tutorials and FAQ section at the top of the Forum for more guides.
Try searching the forums first with Google and add the site filter for this forum.
E.g. install guest additions site:forums.virtualbox.org
Retired from this Forum since OSSO introduction.
-
- Posts: 3
- Joined: 23. Jun 2011, 10:53
- Primary OS: Ubuntu other
- VBox Version: OSE Debian
- Guest OSses: FreeBSD
- Location: Hobart, Tasmania, Australia
Re: Using a physical drive on a virtual machine
What I want to do is boot my freebsd VM from the normal virtual disk provided through the host OS but I want that VM to also have access to a second disk in "raw" mode. I want to have the FreeBSD access that raw disk using ZFS and I don't want to layer the ZFS filesystem on top of whatever filesystem the host is using. I understand that it may be dangerous in some circumstances but my machine has several physical drives and the one I want for raw access is not used by the host at all and I'm prepared to accept the risks.
John.
John.
-
- Volunteer
- Posts: 17798
- Joined: 17. Mar 2008, 13:41
- Primary OS: Debian other
- VBox Version: PUEL
- Guest OSses: Windows XP, Windows 7, Linux
- Location: /dev/random
Re: Using a physical drive on a virtual machine
So? How does that change the facts I've just noted? The post above showed how it's done, the manual shows how you use RAW disk. What's keeping you?
Read the Forum Posting Guide before opening a topic.
VirtualBox FAQ: Check this before asking questions.
Online User Manual: A must read if you want to know what we're talking about.
Howto: Install Linux Guest Additions
Howto: Use Shared Folders on Linux Guest
See the Tutorials and FAQ section at the top of the Forum for more guides.
Try searching the forums first with Google and add the site filter for this forum.
E.g. install guest additions site:forums.virtualbox.org
Retired from this Forum since OSSO introduction.
VirtualBox FAQ: Check this before asking questions.
Online User Manual: A must read if you want to know what we're talking about.
Howto: Install Linux Guest Additions
Howto: Use Shared Folders on Linux Guest
See the Tutorials and FAQ section at the top of the Forum for more guides.
Try searching the forums first with Google and add the site filter for this forum.
E.g. install guest additions site:forums.virtualbox.org
Retired from this Forum since OSSO introduction.
-
- Posts: 3
- Joined: 23. Jun 2011, 10:53
- Primary OS: Ubuntu other
- VBox Version: OSE Debian
- Guest OSses: FreeBSD
- Location: Hobart, Tasmania, Australia
Re: Using a physical drive on a virtual machine
What I was hoping for was some helpful advice on how to set up the raw disk facility. I've read the manual several times and tried it several times on a test system but I get the same issues as AngusM mentioned earlier in this thread.
It may be that I've simply overlooked a minor detail or it may be that there's a bug in the system. Either way I'd like someone to suggest what I could try next.
It may be that I've simply overlooked a minor detail or it may be that there's a bug in the system. Either way I'd like someone to suggest what I could try next.
-
- Volunteer
- Posts: 7639
- Joined: 7. Jun 2007, 21:53
Re: Using a physical drive on a virtual machine
That is what i said.
There are 2 possibilities: You know what you do and it works.
Or it works not, And that is better, because of disk corruption will be following this way.
Use the standard way with an image for the guest and shared folders. That is an approach without any risk.
There are 2 possibilities: You know what you do and it works.
Or it works not, And that is better, because of disk corruption will be following this way.
Use the standard way with an image for the guest and shared folders. That is an approach without any risk.
German Howto (Linux): http://www.linuxforen.de/forums/showthread.php?t=236444
User Manual / Download Section: http://www.virtualbox.de/wiki/Downloads
FAQ: http://www.virtualbox.de/wiki/User_FAQ http://forums.virtualbox.org/viewtopic.php?t=8669
User Manual / Download Section: http://www.virtualbox.de/wiki/Downloads
FAQ: http://www.virtualbox.de/wiki/User_FAQ http://forums.virtualbox.org/viewtopic.php?t=8669
-
- Posts: 13
- Joined: 27. Sep 2009, 05:00
- Primary OS: Ubuntu other
- VBox Version: OSE Debian
- Guest OSses: Linux, Windows
Re: Using a physical drive on a virtual machine
Lets do everyone a favor and keep this discussion clear of the negative talk. We all know the risks involved, but for whatever reason, we want to use a raw disk.
I also have need of this solution. I was using raw disk access on a Windows host, but have changed the host to Linux. I am not having difficulty. I believe I have gotten one step further than the others on this discussion in that I was able to assign the disk to the guest and boot up.
You have to make sure the user running VirtualBox has read/write access to the device. The way I accomplished this was assigning the disk group to the user using the adduser command.
So, like I said, the guest booted fine, then when I tried the access the drive on the guest (a Windows guest) it froze up on me and I had to power down the VM.
I had not unmounted the device from the host file system, would that have caused a problem? Any thoughts?
I also have need of this solution. I was using raw disk access on a Windows host, but have changed the host to Linux. I am not having difficulty. I believe I have gotten one step further than the others on this discussion in that I was able to assign the disk to the guest and boot up.
You have to make sure the user running VirtualBox has read/write access to the device. The way I accomplished this was assigning the disk group to the user using the adduser command.
So, like I said, the guest booted fine, then when I tried the access the drive on the guest (a Windows guest) it froze up on me and I had to power down the VM.
I had not unmounted the device from the host file system, would that have caused a problem? Any thoughts?
-
- Volunteer
- Posts: 17798
- Joined: 17. Mar 2008, 13:41
- Primary OS: Debian other
- VBox Version: PUEL
- Guest OSses: Windows XP, Windows 7, Linux
- Location: /dev/random
Re: Using a physical drive on a virtual machine
Trying to use one partition from two places is exactly where the corruption occurs. You know the risks of RAW disk, but you don't know how extremely dangerous this is?mblahay wrote:I had not unmounted the device from the host file system, would that have caused a problem? Any thoughts?
Read the Forum Posting Guide before opening a topic.
VirtualBox FAQ: Check this before asking questions.
Online User Manual: A must read if you want to know what we're talking about.
Howto: Install Linux Guest Additions
Howto: Use Shared Folders on Linux Guest
See the Tutorials and FAQ section at the top of the Forum for more guides.
Try searching the forums first with Google and add the site filter for this forum.
E.g. install guest additions site:forums.virtualbox.org
Retired from this Forum since OSSO introduction.
VirtualBox FAQ: Check this before asking questions.
Online User Manual: A must read if you want to know what we're talking about.
Howto: Install Linux Guest Additions
Howto: Use Shared Folders on Linux Guest
See the Tutorials and FAQ section at the top of the Forum for more guides.
Try searching the forums first with Google and add the site filter for this forum.
E.g. install guest additions site:forums.virtualbox.org
Retired from this Forum since OSSO introduction.
-
- Posts: 13
- Joined: 27. Sep 2009, 05:00
- Primary OS: Ubuntu other
- VBox Version: OSE Debian
- Guest OSses: Linux, Windows
Re: Using a physical drive on a virtual machine
Please explain the mechanics of
how corruption can occur in that situation and how I can remedy the situation.
how corruption can occur in that situation and how I can remedy the situation.
-
- Volunteer
- Posts: 17798
- Joined: 17. Mar 2008, 13:41
- Primary OS: Debian other
- VBox Version: PUEL
- Guest OSses: Windows XP, Windows 7, Linux
- Location: /dev/random
Re: Using a physical drive on a virtual machine
I already explained that: make the data available on two separate systems at the same time using RAW disk. If you don't unmount the partition/drive when using VB, then two OSes that have no idea about the other's whereabouts will attempt to read and write the same file system. Have you ever tried to write on the same piece of paper on the exact same place as someone else, and you didn't know about the other's existence? That's what you have here.
Read the Forum Posting Guide before opening a topic.
VirtualBox FAQ: Check this before asking questions.
Online User Manual: A must read if you want to know what we're talking about.
Howto: Install Linux Guest Additions
Howto: Use Shared Folders on Linux Guest
See the Tutorials and FAQ section at the top of the Forum for more guides.
Try searching the forums first with Google and add the site filter for this forum.
E.g. install guest additions site:forums.virtualbox.org
Retired from this Forum since OSSO introduction.
VirtualBox FAQ: Check this before asking questions.
Online User Manual: A must read if you want to know what we're talking about.
Howto: Install Linux Guest Additions
Howto: Use Shared Folders on Linux Guest
See the Tutorials and FAQ section at the top of the Forum for more guides.
Try searching the forums first with Google and add the site filter for this forum.
E.g. install guest additions site:forums.virtualbox.org
Retired from this Forum since OSSO introduction.
-
- Posts: 13
- Joined: 27. Sep 2009, 05:00
- Primary OS: Ubuntu other
- VBox Version: OSE Debian
- Guest OSses: Linux, Windows
Re: Using a physical drive on a virtual machine
Thanks, I will try unmounting the disk from the host and see if that helps.
-
- Posts: 13
- Joined: 27. Sep 2009, 05:00
- Primary OS: Ubuntu other
- VBox Version: OSE Debian
- Guest OSses: Linux, Windows
Re: Using a physical drive on a virtual machine
I got it working, though the disk I was initially trying to mount to the VM I am still having issues with. I must have some underlying problem with that disk that is causing my Windows VM to not read it. The disk is read just fine by the ubuntu host. The second disk I tried, also an NTFS, attaches to the VM as expected and works. Surprisingly, it works whether it is mounted on the host or not. Please note that I am not advocating that the drive stay mounted on the host, its just that the mounting tends to happen automatically with Ubuntu and I have to figure out how to prevent it.
I hope my experience with this helps.
I hope my experience with this helps.