How do I mount host physical partition from guest linux?

Discussions about using Linux guests in VirtualBox.
Post Reply
jlettvin
Posts: 6
Joined: 4. Nov 2011, 15:12
Primary OS: MS Windows 7
VBox Version: OSE other
Guest OSses: winxp, ubuntu10.04, ubuntu11.10

How do I mount host physical partition from guest linux?

Post by jlettvin »

Host OS: Windows 7
Host partition 1: primary NTFS reserved
Host partition 2: primary NTFS Win7
Host partition 5: logical ext4 ubuntu 11.10
Guest 1: ubuntu 11.10
Guest 2: ubuntu 10.04.03LTS

Both guests need the ability to mount Host partition 5
in the guest as /media/Host.partition5.
It would be great if they could be simultaneous,
one with read/write/exec and the other as read-only,
but one guest at a time would be fine.
Commands like the following (as root) would be ideal:

Code: Select all

# echo sdb5 /media/Host.partition5 defaults 0 0>>/etc/fstab
# mount -a
This would also be good enough:

Code: Select all

# mount -t ext4 /sdb5 /media/Host.partition5
Wordy descriptions confuse me. A sequence of steps would be easier to follow.

One web page that may have the elements I seek made me uneasy http://www.sysprobs.com/access-physical ... n-software.
Here is an entirely different approach that confused me http://n00bsys0p.wordpress.com/2011/07/ ... -in-linux/.

The concept is easy enough to not require much description.
1) make host partition 5 visible to guest os
2) mount host partition 5 in guest os

A linear sequence of commands as needed in each environment would be best.
Any help is appreciated.
Sasquatch
Volunteer
Posts: 17798
Joined: 17. Mar 2008, 13:41
Primary OS: Debian other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows XP, Windows 7, Linux
Location: /dev/random

Re: How do I mount host physical partition from guest linux?

Post by Sasquatch »

And you never considered reading the User Manual, where everything might be described? Are you also fully aware of the implications of RAW disk access?
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.
jlettvin
Posts: 6
Joined: 4. Nov 2011, 15:12
Primary OS: MS Windows 7
VBox Version: OSE other
Guest OSses: winxp, ubuntu10.04, ubuntu11.10

Re: How do I mount host physical partition from guest linux?

Post by jlettvin »

Thank you for your response.

1. I have read the manual with care.
I have tried every variation I found and could conceive to make the disk accessible.
Nothing in the manual has helped identify why none of these variations has worked.
I have created files named "RawPhysicalDrive0.vmdk" and "RawPhysicalDrive5.vmdk"
using the "vboxmanage internalcommands createrawvmdk ..." command.
The first is supposed to give me access to the entire disk.
The second is supposed to give me access to partition 5.
I got no errors when generating these files because
I carefully researched what the commands should be.
I have spent quite literally dozens of hours trying this and that
including ideas and instructions from at least 40 or so web pages.
When asking the question I did, I was hoping to avoid making a long unuseful request.
I apologize if it sounded like a lazy newbie question. It was not.

2. I understand exactly what the consequences of raw disk usage are.
Having been one of the early researchers/developers of IBM PC antiviruses
I have written boot sectors, master boot records, loaders, and entire operating systems from scratch.
I have used gparted and partition magic in the past and am quite at home with disks and filesystems.
I have no fear of lossage.
I have full backups of anything I might inadvertently lose.

Restating what I am trying to do is very simple:
I want to mount a host native linux partition on a mount point in a virtual guest linux.
This should be trivial, and I feel quite humbled by the efforts I've taken that have failed.

Directing me to literature may in the end be helpful.
But I have not found the literature to be sufficient to help me pass this impediment.
So, I will leave the question I asked originally as my continuing question
with this response providing a bit of background.

I appreciate any help you may be able to offer.
Martin
Volunteer
Posts: 2562
Joined: 30. May 2007, 18:05
Primary OS: Fedora other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: XP, Win7, Win10, Linux, OS/2

Re: How do I mount host physical partition from guest linux?

Post by Martin »

So you already have created the raw disk vmdk.
What were your next steps and which (error) messages did you get?
jlettvin
Posts: 6
Joined: 4. Nov 2011, 15:12
Primary OS: MS Windows 7
VBox Version: OSE other
Guest OSses: winxp, ubuntu10.04, ubuntu11.10

Re: How do I mount host physical partition from guest linux?

Post by jlettvin »

All directions I have seen concern using the host virtualbox dialog box.
There is no "add" button to add the disk and dragging and dropping it fails.
I have looked for commands that would effect the same result but found none.
So, I have no known next step.
That is what I seek.
Martin
Volunteer
Posts: 2562
Joined: 30. May 2007, 18:05
Primary OS: Fedora other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: XP, Win7, Win10, Linux, OS/2

Re: How do I mount host physical partition from guest linux?

Post by Martin »

Do you have the small buttons on the bottom of the storage settings page?
Screenshot-test - Settings.png
Screenshot-test - Settings.png (50.03 KiB) Viewed 36029 times
jlettvin
Posts: 6
Joined: 4. Nov 2011, 15:12
Primary OS: MS Windows 7
VBox Version: OSE other
Guest OSses: winxp, ubuntu10.04, ubuntu11.10

Re: How do I mount host physical partition from guest linux?

Post by jlettvin »

The problem persists. Here are the results I got.

Mixing "attrib *" and "dir" on my vmdk files gives the following result:
548 A I C:\Users\jlettvin\.VirtualBox\VDI\RawPhysicalDrive0.vmdk
65,536 A I C:\Users\jlettvin\.VirtualBox\VDI\RawPhysicalDrive5-pt.vmdk
815 A I C:\Users\jlettvin\.VirtualBox\VDI\RawPhysicalDrive5.vmdk

Using the "add disk" button, I tried both SATA and IDE.
Browsing to any of the above files,
An error box pops up with a message like the following:

Failed to open the hard disk C:
\Users\jlettvin\Virtualbox VMs\ubuntu11.10\RawPhysicalDrive5.vmdk

The medium 'C:
\Users\jlettvin\Virtualbox VMs\ubuntu11.10\RawPhysicalDrive5.vmdk'
can't be used as the requested device type.

Details:

Result Code:
E_FAIL (0x80004005)
Component:
Medium
Interface:
IMedium {53f9cc0c-e0fd-40a5-a404-a7a5272082cd}
Callee:
IVirtualBox {c28be65f-1a8f-43b4-81f1-eb60cb516e66}
jlettvin
Posts: 6
Joined: 4. Nov 2011, 15:12
Primary OS: MS Windows 7
VBox Version: OSE other
Guest OSses: winxp, ubuntu10.04, ubuntu11.10

Re: How do I mount host physical partition from guest linux?

Post by jlettvin »

I have tried all the advice I have been given
in addition to many experiments of my own.

I still seek a solution.
Thank you for your assistance so far.
brandonkirsch
Posts: 12
Joined: 9. May 2011, 17:56
Primary OS: openSUSE
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Win7

Re: How do I mount host physical partition from guest linux?

Post by brandonkirsch »

Hi jlettvin, I just ran into the same problem trying to use a Linux host. I made a post over in the "Linux Host" area and you can see it here.

If I hear anything from that front, I'll remember to stop back over here and let you know what I found. I can't help but think this is a bug in the documentation or the VirutalBox software itself.
Sasquatch
Volunteer
Posts: 17798
Joined: 17. Mar 2008, 13:41
Primary OS: Debian other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows XP, Windows 7, Linux
Location: /dev/random

Re: How do I mount host physical partition from guest linux?

Post by Sasquatch »

Problem is mostly likely to be user privileges. You need root/administrator privileges to access a RAW disk.
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.
brandonkirsch
Posts: 12
Joined: 9. May 2011, 17:56
Primary OS: openSUSE
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Win7

Re: How do I mount host physical partition from guest linux?

Post by brandonkirsch »

My problem persists on Linux even when I run VirtualBox as root.

I've yet to solve this issue as well.

99.9% sure this is a bug at this point, so I don't think it will get resolved in the forums.
philippe44
Posts: 45
Joined: 31. Jul 2008, 20:56
Primary OS: MS Windows 7
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Kubuntu, misc Linux, XP

Re: How do I mount host physical partition from guest linux?

Post by philippe44 »

Can you post the exact createrawvmdk command that you use ? I'm doing this on my computer with a Win7 hosta and a Kubuntu 11.xx guest for a long time and it works w/o problem. In the past, Win7 and old version of VB had issues with raw partition access (was working fine with XP) and I posted a few tricks to workaround this, but since VB 4.0.4 (not sure of the exact version number), they have incorporated the driver to allow a guest to accees raw partition in Win7 host

Win7 Command should be something like that - in elevated mode
VBoxManage internalcommands createrawvmdk -filename “<path\\to\\file.vmdk>” -rawdisk \\.\PhysicalDrive0 -partitions <part#1, part#2, ... part#n>

In my case, VB in Win7 *must* be run in elevated mode to access the raw partition, otherwise an error occurs when adding the .vmdk (make sense, need admin privilege to access raw partition in Win7. I assume a regular user can be given that right too, I never took the time to do this)

NB : I just created a new partition from scratch to try and can confirm it works
oneflame
Posts: 1
Joined: 26. Jan 2012, 11:03
Primary OS: MS Windows 7
VBox Version: OSE other
Guest OSses: Ubuntu

Re: How do I mount host physical partition from guest linux?

Post by oneflame »

Not sure if this will help, or not... But I seem to be able to attach the raw partition to the virtual machine... There is an option to /skip/ the creation of the disk during the creation of the virtual machine ... Go ahead and skip this. Then go back to storage, and attach the disks again. The thing is, I got some weird bugs until I put the disks (I have two vmdks, the o.s. and the swap drive), into a different folder than the virtual machine.

All that being said, my virtual machine still won't boot. There is an option during the normal definition of the virtual machine to set the hard disk as the startup drive. I am trying to understand the configuration files, but I can't get the vm to understand that the drive I added after the fact is in fact a boot drive.

If you have any insight, I would appreciate it.

Code: Select all

C:\Program Files\Oracle\VirtualBox>VBoxManage.exe internalcommands createrawvmdk -filename D:\VirtualBox\Linux64.vmdk -rawdisk \\.\PhysicalDrive0 -partitions 3,5
RAW host disk access VMDK file D:\VirtualBox\Linux64.vmdk created
 successfully.
HTH
AlberoA
Posts: 1
Joined: 10. Mar 2012, 00:35

Re: How do I mount host physical partition from guest linux?

Post by AlberoA »

You must run VB as administrator.
I had the same problem until I run it as indicating the attached image
VB_Administrator.jpg
VB_Administrator.jpg (33.78 KiB) Viewed 34419 times
Sorry for my bad english
Post Reply