37

I created a virtualbox raw disk pointing to a functioning, booting USB drive with a small linux distro on it.

sudo ./VBoxManage internalcommands createrawvmdk -filename ~/VirtualBox\ VMs/MyTinyLinux/rawdiskonusb.vmdk -rawdisk /dev/disk2 -partitions 2

When I try to add it to a virtualbox VM, I get this error:

Failed to open the disk image file ~/VirtualBox VMs/MyTinyLinux/rawdiskonusb.vmdk.

Permission problem accessing the file for the medium '~/VirtualBox VMs/MyTinyLinux/rawdiskonusb.vmdk' (VERR_ACCESS_DENIED).

Result Code: VBOX_E_FILE_ERROR (0x80BB0004)
Component: MediumWrap
Interface: IMedium {4afe423b-43e0-e9d0-82e8-ceb307940dda}
Callee: IVirtualBox {0169423f-46b4-cde9-91af-1e9d5b6cd945}
Callee RC: VBOX_E_OBJECT_NOT_FOUND (0x80BB0001)

I saw that the raw disk vmdk file was owned by root. I chown'ed it to my own user.

Still get the same error. I suspect it would work if I ran virtualbox as root, but I really do not want to do that. Is there anyway to make this work?

3
  • VirtualBox needs root access for a bunch of things, and you already use sudo so you might as well do a proper root startup to get proper environment and user properties. May 21, 2016 at 22:43
  • That's probably related to the "method" you used to create the disk. So, you're trying to access the USB disk, but the Error is referencing the previous image file location.
    – ILMostro_7
    May 22, 2016 at 1:55
  • Same issue for me. When I try to execute as sudo, it does not allow x64 machines, that was my case, and then there is no solution for me... :'( - usind on linux
    – kokbira
    Feb 8, 2019 at 20:01

8 Answers 8

36

User should be in a disk group to access raw partitions (as Gilles mentioned by last reference in his answer).

sudo usermod -a -G disk $USER
4
  • 14
    this works for me too - note that you are required to log out after adding yourself to the group, or this change will not be applied. That goes for any group modifications actually
    – CybeX
    Dec 28, 2017 at 7:53
  • Using only that command was sufficient for me
    – kokbira
    Mar 28, 2019 at 17:59
  • 1
    You have to logout/in to have group membership reevaluated. You can do su - $USER to reevaluate it for a single terminal. superuser.com/questions/272061/…
    – robm
    Jan 21 at 22:46
  • As user you can also activate the new group by newgrp disk; newgrp $USER w/o logout.
    – abu_bua
    Mar 25 at 17:07
33

The poster used linux on the host machine. If you came here and use Windows as a host (like me) there is an easy solution to this error. Windows doesn't allow raw disk access if you don't start VirtualBox with administrator priviledges.

0
12

Check the permission on all the files involved, including the directories: ~/VirtualBox VMs, ~/VirtualBox VMs/MyTinyLinux, ~/VirtualBox VMs/MyTinyLinux/rawdiskonusb.vmdk, /dev/disk2. The directories need to be readable and traversable by your user (chmod +rx) and the image file and the raw disk need to be readable and writable (chmod +rw).

You'll need to allow your user to access the disk; since /dev is populated automatically at each boot, you'll need to add a udev to do this. See Give a specific user permissions to a device without giving access to other users

7

from 2020 here:

  1. run virtual box service as administrator (VBoxSVC.exe), if running kill it first.
  2. run virtual box main executable (VirtualBox.exe whatever is on your desktop) as adminstrator too
2
  • 2
    This answer is a bit unclear, also it is for Windows, not Linux…
    – Jaleks
    Apr 25, 2020 at 20:00
  • This a thousand times... The fact that it's for Windows is irrelevant. This is information you cannot find anywhere else. I tried every combination of offline-ing disks, double clearing readonly attributes just to be sure, running as admin, not running as admin, etc to no avail... Finally, a solution to this damn problem that creeps up on me randomly once a year. Running VBovSVC as admin/su is crucial when you are running virtual machines on a physical medium. Thank you kapo!
    – DeeJayh
    Feb 19, 2021 at 9:01
4

Depending on the distribution, you might have to add your username to the VirtualBox group.

usermod -a -G vboxusers myusername

Additionally, according a similar Q&A on askubunt, you might have a corrupt ISO. In your case, I would guess it means a botched conversion to raw disk. Try searching on how to correctly do that procedure and repeat it, in case the conversion got botched somehow during the first procedure.


If that's still not a solution, then follow the advice in the VirtualBox Manual and add the -relative option:

Creating the image requires read/write access for the given device. Read/write access is also later needed when using the image from a virtual machine. If this is not feasible, there is a special variant for raw partition access (currently only available on Linux hosts) that avoids having to give the current user access to the entire disk. To set up such an image, use

VBoxManage internalcommands createrawvmdk -filename /path/to/file.vmdk -rawdisk /dev/sda -partitions 1,5 -relative

When used from a virtual machine, the image will then refer not to the entire disk, but only to the individual partitions (in the example /dev/sda1 and /dev/sda5). As a consequence, read/write access is only required for the affected partitions, not for the entire disk. During creation however, read-only access to the entire disk is required to obtain the partitioning information.

4

Since there's no accepted answer, I'll post this as an answer for the moment. In addition to ensuring you're in the right groups, as others have posted above:

sudo usermod -a -G disk $USER
sudo usermod -a -G vboxusers $USER

If you are still getting the VERR_ACCESS_DENIED error, you need to, as per the comment by @Cybex, logout and log back in for the above group additions to take effect.

1
  • "vboxusers" was not needed for my case, only "disk" (fedora29). On mint19, I could not run that VM with rawdisk, except using sudo.
    – kokbira
    Mar 28, 2019 at 18:00
1

The problem (for me) was To show only file name without the entire directory path. ... Only filename is needed:

VBoxManage internalcommands createrawvmdk -filename rawdiskonusb.vmdk -rawdisk \\.\PhysicalDrive#

worked nicely.

1
  • this worked for me on windows with ubuntu VM -- for some reason when i was doing like -filename C:\rawdisk it did not work, but -filename rawdisk does. It puts the file in the virtual box directory though (which is fine) May 31, 2020 at 17:29
0

I had a similar problem but the issue was that I was running the sudo command while in finder I was in my home volume, I cd'd to Volume/Users/Owner where my profile is called owner and then it worked perfectly.

Not the answer you're looking for? Browse other questions tagged or ask your own question.