Accessing the real hard drives

This is for discussing general topics about how to use VirtualBox.
Post Reply
skippy456
Posts: 5
Joined: 10. May 2012, 07:48

Accessing the real hard drives

Post by skippy456 »

I'm running windows 7 64 bit pro, I've installed Gparted on Virtualbox as I want to partition hard drives and SD cards, but Gparted can't see any of the hard drives on my PC.

Same thing happens when I install Windows XP etc.... it can see "virtual" hard drives but not the ones in the real world.

How can i make Virtualbox see all my hard drives etc in the real world ?

Instead of having to reboot my PC to use an OS in multi boot setup, the aim of me getting that was install different OS on my PC and use them with my real hard drives etc..

Can you guys help.

By the way I am an IT professional like you.
BillG
Volunteer
Posts: 5105
Joined: 19. Sep 2009, 04:44
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows 10,7 and earlier
Location: Sydney, Australia

Re: Accessing the real hard drives

Post by BillG »

The simple answer is that you can't. You can share files between the host and guest using shared folders (once you have an OS installed) but you cannot directly access the hard drive in a vm from the host or vice versa. The guest is effectively another computer with its own hard drive(s) and vice versa.

There may be ways to do what you want but they would probably not be supported by VirtualBox or the hardware manufacturer.
Bill
skippy456
Posts: 5
Joined: 10. May 2012, 07:48

Re: Accessing the real hard drives

Post by skippy456 »

Thats very strange to hear ... for yrs I've been using emulators to play ZX Spectrum games on my PC and they can access real hard drives etc...

I thought Virtualbox was an emulator....and considering Oracle own it... you'd think it would do what I want it to do...

Can Oracle add the features I want to it ?

Is there software I can use to do what I want ?
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Accessing the real hard drives

Post by mpack »

This is all nonsense.

VirtualBox is not an emulator, it's a VM hypervisor.

And your ZX Spectrum emulator could not directly use host drives either. Two PCs cannot be in charge of one hard disk... and anyway the ZX Spectrum certainly never supported the NTFS filesystem! I have no idea what feature you might be thinking of that made you believe this.

Use Google to answer your other questions.
skippy456
Posts: 5
Joined: 10. May 2012, 07:48

Re: Accessing the real hard drives

Post by skippy456 »

i wasnt being rood to you.... all i want is to install an os in virtualbox which has full access to my pc inc physical hard drives, usb drives etc.
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Accessing the real hard drives

Post by mpack »

In fact VirtualBox does support one feature - raw disk access - which is similar to what you describe. However that feature is clearly not for you, as its extremely dangerous (meaning: it's going to destroy all data on the host drive if you get it even slightly wrong), experts only, and even experts mostly avoid it if they possibly can.

If all you want is to access some files (as opposed to entire hard disks), then read about shared folders in the user manual.
skippy456
Posts: 5
Joined: 10. May 2012, 07:48

Re: Accessing the real hard drives

Post by skippy456 »

Gparted is a disk partitioning tool and raw disk access in Virtualbox would be perfect for that ....as i want to format and partition disks and SD cards.

I want any o.s. in Virtualbox to access data via raw disk access.
BillG
Volunteer
Posts: 5105
Joined: 19. Sep 2009, 04:44
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows 10,7 and earlier
Location: Sydney, Australia

Re: Accessing the real hard drives

Post by BillG »

I think that you can safely assume that mpack knows what gparted is and what it does!

How VirtualBox handles raw disk access is explained in the manual under Advanced topics|Advanced storage config (Chapter 9.8 in the current version). Please read the warnings and be aware that you are on your own. It is beyond the scope of the forum.
Bill
skippy456
Posts: 5
Joined: 10. May 2012, 07:48

Re: Accessing the real hard drives

Post by skippy456 »

no worries.... sorry if upset anyone.... didn't mean to but you gave me the answer I wanted and I will look at that chapter... if it works then the chance to have many virtual OS's access real hard drives etc on one windows PC sounds great.
Marinewonder
Posts: 1
Joined: 2. Mar 2019, 05:47

Re: Accessing the real hard drives

Post by Marinewonder »

It's unfortunate this thread ended like this. I'm using VirtualBox6. What the OP was asking is relevant to me. Having a dedicated hard disk in a multi-disk system for imaging operations is especially convenient when imaging operations need to happen from different OS VMs. Having VirtualBox access the raw disk for partitioning tasks like this is ideal.

This means this particular disk can and will be often wiped and re-imaged for this purpose. The data loss is expected. I was currently having issues even accessing my real disk within VirtualBox when its mode was "Shareable". I used this method to prepare it from a command-line:
vboxmanage internalcommands createrawvmdk -filename diskname.vmdk -rawdisk \\.\PHYSICALDRIVEx
The disk was often partitioned or had data from work directly from the host. I assumed the VM would just see the same data, it couldn't.

The VirtualBox I've added this disk to was never able to access the disk, it would try but never succeed. diskpart within the VM was unable to start as I believe it tried to negotiate with a disk that it wasn't able to manage somehow. So I suspected it was because the host machine was not releasing or able to "share" the disk to the VM.

The host machine is Win7, the Virtual machine is Win10. Not sure it should matter. I've now cleaned the disk from the host's diskpart, then booted into the VM again. I was now able to partition/format the disk within the VM. More operations and tests to follow.

Upon exiting the VM, I wanted to confirm the host machine could see the disk's partitions, but it considered it completely unallocated and unassigned. So I went ahead and partitioned/formatted the disk again in the host, just to figure more things out. This would account to a "data loss" on whatever was put on that disk from within the VM.

I went back into the VM to see how it sees the re-partitioned disk changes. Sure enough, dispart could not completely open for operations. But at least I know how to make it work. Just thought I'd share.

While the worries and concerns the OP's request raised in this thread are valid, the hands-off approach did leave the OP on his own for something that probably wasn't as daunting as it was described.

Cheers
Last edited by socratis on 2. Mar 2019, 09:06, edited 1 time in total.
Reason: Enclosed the information in [quote][pre] tags for better readability
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: Accessing the real hard drives

Post by socratis »

This thread was opened on 2012-05-10, just when VirtualBox 4.1.14 (2012-04-13) was out, and just before 4.1.16 (2012-05-22) hit the market shelves. Don't you think you could have found a more recent thread to hijack? Or even open a new one? But, since that area has not changed, I'm going to let it stand, not lock it down as a resurrected Lazarus/zombie thread...

So, the issue remains and remains there; you can royally screw up your data if you're not careful. It's akin to having knives in your house; if you use them the wrong way you can create a lot of bad situations, even charged with a "possession of a murder weapon". And since no one wants to be an "accomplice to a murder", nobody is going to help you with specific advice without a big, fat, red, flashing warning! The same one that's in the User Manual:
Warning
Raw hard disk access is for expert users only. Incorrect use or use of an outdated configuration can lead to total loss of data on the physical disk. Most importantly, do not attempt to boot the partition with the currently running host operating system in a guest. This will lead to severe data corruption.
Marinewonder wrote:It's unfortunate this thread ended like this.
Most of the rawdisk access threads end up like that, don't feel that the OP was specifically targeted to be left on their own...
Marinewonder wrote:This means this particular disk can and will be often wiped and re-imaged for this purpose. The data loss is expected.
That's a huge difference in your setup; you don't really care if the data gets wiped or not, you got nothing to lose.
Marinewonder wrote:I assumed the VM would just see the same data, it couldn't ... So I suspected it was because the host machine was not releasing or able to "share" the disk to the VM.
That would be a correct assumption. A lot of OSes these days are actively trying to prevent a user from doing something stupid, like shooting themselves in both their feet. The methodology differs, depending on the host OS. Since you didn't mention what that OS is in your case, I can only confirm what you realized; the host OS needs to release the disk. Even more requirements sometimes, like being an admin.
Marinewonder wrote:I was currently having issues even accessing my real disk within VirtualBox when its mode was "Shareable".
Did you happen to read the warning about "Shareable" disk mode? Let me enlighten you. From ch. 5.4. Special Image Write Modes:
Shareable disks may be attached to several VMs which may run concurrently. This makes them suitable for use by cluster filesystems between VMs and similar applications which are explicitly prepared to access a disk concurrently.
Warning: This is an expert feature, and misuse can lead to data loss – regular filesystems are not prepared to handle simultaneous changes by several parties.
Marinewonder wrote:Upon exiting the VM, I wanted to confirm the host machine could see the disk's partitions, but it considered it completely unallocated and unassigned.
Right. That's called a complete data loss.

So, you see, you've already misunderstood what is going on here. You're lucky that you don't really care about the disk...
Marinewonder wrote:the hands-off approach did leave the OP on his own for something that probably wasn't as daunting as it was described.
Seriously? Not daunting??? You just finished describing how you royally screwed up your hard drive and you lost everything, and you wanted us to help with the destruction? Not going to happen, no, no, no...
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.
Post Reply