Accessing raw partitions with VMDK (VirtualBox 1.4)

This is for discussing general topics about how to use VirtualBox.
kilou
Posts: 53
Joined: 14. May 2007, 10:16

Accessing raw partitions with VMDK (VirtualBox 1.4)

Post by kilou »

Hi,

I'm trying to access my XP partition with VirtualBox 1.4. The XP partition is on /dev/sda2 and I'd like to access /dev/sda6 as well (documents). I've looked in the manual and it seems that the command I need to issue to create the appropriate VMDK file is:

VBoxManage internalcommands createrawvmdk -filename /home/user/.VirtualBox/WinXP.vmdk -rawdisk /dev/sda -partitions 2,6 -relative -register

When I do this I get:
Error opening the raw disk: VERR_ACCESS_DENIED

If I add "sudo" in front of the command then it works and the VMDK file is created in /home/user/.VirtualBox/ However when I launch VirtualBox I get a message that tells me this virtual disk is not currently accessible. If I look in virtual disk manager I can see WinXP.vmdk but it has a yellow tag on it.

/dev/sda2 is the partition where XP is installed
/dev/sda6 contains /home (it is also where the vmdk file is stored and this is the partition that I'd like to make accessible to both host and guest)

I also try to remove the /dev/sda6 from the command:

sudo VBoxManage internalcommands createrawvmdk -filename /home/user/.VirtualBox/WinXP.vmdk -rawdisk /dev/sda -partitions 2 -relative -register

but I still get the same results...

Is this because I created the VMDK as root (sudo)??

Any idea?
achimha
Volunteer
Posts: 217
Joined: 10. May 2007, 09:24

Post by achimha »

You have to change the permissions on /dev/sda2 and /dev/sda6 so that the VirtualBox user can read and write to it.

When creating the VMDK as root, make sure to change owner/permissions so that VirtualBox can access it. Note that creating the VMDK also needs read access to /dev/sda (for the boot sector) so doing this as root is the best solution.
zyzgak
Posts: 1
Joined: 7. Jun 2007, 12:08

Post by zyzgak »

I have similar problem. I'm trying to access my linux partition under XP:

Code: Select all

D:\xxx\pc\VirtualBox>VBoxManage internalcommands listpartitions -rawdisk \\.\Phys
icalDrive1
VirtualBox Command Line Management Interface Version 1.4.0
(C) 2005-2007 innotek GmbH
All rights reserved.

Number  Type   StartCHS       EndCHS      Size (MiB)  Start (Sect)
1       0x83  0   /1  /1   1023/254/63         16386           63
5       0x07  1023/1  /1   1023/254/63        131006     33559848
6       0x07  1023/1  /1   1023/254/63        131077    301861413

D:\xxx\pc\VirtualBox>VBoxManage internalcommands createrawvmdk -filename d:\test1
.vmdk -rawdisk \\.\PhysicalDrive1 -partitions 1
VirtualBox Command Line Management Interface Version 1.4.0
(C) 2005-2007 innotek GmbH
All rights reserved.

ERROR: VMDK: could not create new partition data file 'd:\test1-pt.vmdk'
Error code VERR_SHARING_VIOLATION at E:\vbox\w32-rel\src\VBox\Devices\Storage\Vmd
kHDDCore.cpp(2228) in function vmdkCreateImage
Error while creating the raw disk VMDK: VERR_SHARING_VIOLATION
Could somebody point my error? Or, if i have get privileges to access to that partition, how can i achieve this under XP?
kilou
Posts: 53
Joined: 14. May 2007, 10:16

Post by kilou »

Achimha, how do you change the permissions on /dev/sda2 and /dev/sda6?

My fstab file looks like:

/dev/sda6 /home ext3 defaults 0 2

/dev/sda2 /windows ntfs defaults,nls=utf8,umask=007,gid=46 0 1
achimha
Volunteer
Posts: 217
Joined: 10. May 2007, 09:24

Post by achimha »

You should not mount those partitions on your host. There must not by any concurrent access.

Use chmod on /dev/sda2 and /dev/sda6 to adjust the permissions.
kilou
Posts: 53
Joined: 14. May 2007, 10:16

Post by kilou »

chmod seems to be for files and folders only, not for entire partition. And since /dev/sda2 (where windows is installed) is a Ntfs partition, I guess linux can't change the permission since Ntfs is read-only on linux (except if a specific driver is installed).

All I could find to change the permission is to modify fstab entry for /dev/sda2 and add "uid=1000"......but this means that the xp partition would need to be mounted in linux (this would be required to run chmod as well) :?

I'm a bit confused on how to do that.
moonlight
Posts: 23
Joined: 13. May 2007, 09:52

Post by moonlight »

There is difference between permissions for file system of partition and permissions for partitions itself.
Chmod may also work with whole sda
kilou
Posts: 53
Joined: 14. May 2007, 10:16

Post by kilou »

Can you post an example of the chmod command to issue to set full access permission to /dev/sda2? Does this work also if /dev/sda2 is NTFS?

All the exmplaes I see are for chmod on a mounted filesystem.....and apparently the partition that VirtualBox accesses shouldn't be mounted.
achimha
Volunteer
Posts: 217
Joined: 10. May 2007, 09:24

Post by achimha »

First make sure /dev/sda2 and /dev/sda6 are not mounted. Then issue as root:

Code: Select all

chmod 777 /dev/sda2
chmod 777 /dev/sda6
Of course 777 is not the best solution but it will show you the direction.
kilou
Posts: 53
Joined: 14. May 2007, 10:16

Post by kilou »

Thanks achimha but I still have the same problem. I did:

1) unmount /dev/sda2
2) sudo chmod 777 /dev/sda2
3) sudo VBoxManage internalcommands createrawvmdk -filename /home/kilou/.VirtualBox/WinXP.vmdk -rawdisk /dev/sda -partitions 2 -relative -register

...and virtualdisk manager still warns that the registred virtual hardisk is not accessible.
nuudles
Posts: 9
Joined: 6. Jun 2007, 16:39

Post by nuudles »

kilou wrote:Thanks achimha but I still have the same problem. I did:

1) unmount /dev/sda2
2) sudo chmod 777 /dev/sda2
3) sudo VBoxManage internalcommands createrawvmdk -filename /home/kilou/.VirtualBox/WinXP.vmdk -rawdisk /dev/sda -partitions 2 -relative -register

...and virtualdisk manager still warns that the registred virtual hardisk is not accessible.
Try this:

1) sudo su
2) umount /dev/sda2
3) chmod 666 /dev/sda*
4) VBoxManage internalcommands createrawvmdk -filename /home/kilou/.VirtualBox/WinXP.vmdk -rawdisk /dev/sda -partitions 2 -relative -register
5) chown kilou:users /home/kilou/.VirtualBox/WinXP.vmdk
6) exit
achimha
Volunteer
Posts: 217
Joined: 10. May 2007, 09:24

Post by achimha »

you have to sudo chown kilou /home/kilou/.VirtualBox/WinXP.vmdk as well
PFilter
Posts: 3
Joined: 7. Jun 2007, 19:57

Post by PFilter »

kilou wrote:Thanks achimha but I still have the same problem. I did:

1) unmount /dev/sda2
2) sudo chmod 777 /dev/sda2
3) sudo VBoxManage internalcommands createrawvmdk -filename /home/kilou/.VirtualBox/WinXP.vmdk -rawdisk /dev/sda -partitions 2 -relative -register

...and virtualdisk manager still warns that the registred virtual hardisk is not accessible.
Each time you recreate the vmdk you will need to re-register it. VBox keeps a hash(MD5?) of somekind and if the file is replaced, even if the name is the same, you have to delete it from the Virtual Disk Manager and add it again.
kilou
Posts: 53
Joined: 14. May 2007, 10:16

Post by kilou »

Still no luck on my side :( I did:

1) sudo su
2) umount /dev/sda2
3) chmod 666 /dev/sda2 (also tried with 777)
4) VBoxManage internalcommands createrawvmdk -filename /home/kilou/.VirtualBox/WinXP.vmdk -rawdisk /dev/sda -partitions 2 -relative -register
5) chown kilou:users /home/kilou/.VirtualBox/WinXP.vmdk

Now I don't get any message when starting VirtualBox but when I launch virtual disk manager it is empty (the created vmdk disk is not registred?). I tried to click "Add" and then there are 2 vmdk files: WinXP.vmdk and WinXP-pt.vmdk. Selecting either of those files makes a popup message appear saying:

##############################################
Failed to register the hardisk /home/kilou/.VirtualBox/WinXP.vmdk

Could not access hard disk image /home/kilou/.VirtualBox/WinXP.vmdk
(VERR_VDI_INVALID_SIGNATURE)

Result Code:
0x80004005
Component:
HardDisk
Interface:
IHardDisk {fd443ec1-000f-4f5b-9282-d72760a66916}
Callee:
IVirtualBox {d1a2295c-d257-4a4c-a9a6-843d87db6f45}
###############################################

I tried to do the same but creating a vmdk file with another name but I still can't access it.
:?
nuudles
Posts: 9
Joined: 6. Jun 2007, 16:39

Post by nuudles »

Like I said, you should try this:

chmod 666 /dev/sda*

I think your problem is the permissions on /dev/sda and not /dev/sda2
Post Reply