This is strange there is no way to add a physical disk to your virtual machine under virtualbox! Still it is possible and it is simple, but you need to execute few commands under console so you need to open a terminal and to have a root privileges!
To use a raw disk in our virtual machine we must create a special VMDK file and then to use it when adding a hard drive to our virtualbox virtual machine with “Use an existing virtual hard disk dile”.
Here are the right steps to add a raw disk:
STEP 1) Permissions – your user must have (write) permissions to access raw disks
In most cases your user do not have write permission to the disk – it is the same under MS Windows and any Linux distribution (and probably MAC)! So here is the right way how to give permissions under Linux and Windows:
- Under Linux (Ubuntu, Centos, Fedora, Gentoo and probably all other). There are at least two ways to give WRITE permission to the raw disk (use one of them, the first one is preferred). We want to add our third disk the “/dev/sdc” so the examples are with this device:
- add your user to “disk” group and log out. After you log in you’ll have WRITE permissions to the disks. Probably you must log off your GUI (Gnome, KDE and so on), too!
srv@local ~ $ sudo sudo usermod -a -G disk myuser
“myuser” is the username of the user I am logged in. The log out and log in (if you are using a GUI – gnome, kde or something else, you must log out from the GUI, too and then log in again).
- execute virtualbox with root user
- change the permission of the physical device you want to use (this is temporary, because next time you reboot you must change it again)
srv@local ~ $ sudo chmod o+rw /dev/sdc
- add your user to “disk” group and log out. After you log in you’ll have WRITE permissions to the disks. Probably you must log off your GUI (Gnome, KDE and so on), too!
- Under Windows 10 (or 7) – you must start the command prompt and Virtualbox with “run as Administrator” – look at the next step (STEP 2).
STEP 2) Add the raw disk
- Under Linux (use one of these solutions)
- With ordinary user and WRITE permission is set:
srv@local ~ $ VBoxManage internalcommands createrawvmdk -filename /home/myuser/.VirtualBox/physical-sdc.vmdk -rawdisk /dev/sdc RAW host disk access VMDK file /home/myuser/.VirtualBox/physical-sdc.vmdk created successfully.
As you can see no root is required and now you can start VirtualBox without root permissions as always you have done it.
- With root user
srv@local ~ $ sudo VBoxManage internalcommands createrawvmdk -filename /home/myuser/.VirtualBox/physical-sdc.vmdk -rawdisk /dev/sdc RAW host disk access VMDK file /home/myuser/.VirtualBox/physical-sdc.vmdk created successfully. srv@local ~ $ sudo VirtualBox
“/home/myuser” is my home user directory. Yours could be with different name so change the name accordingly.
- With ordinary user and WRITE permission is set:
- Under Windows (7 and 10)
-
First you must start the command line tool under linux also with administrative privileges!
Search for command prompt and with right click you hit “Run as administrator”. Change the directory to the VirtualBox executables and then execute the command. Use your path for “filename” (c:\Users\homer\.VirtualBox\physical-sdc.vmdk – change to your path), your home user directory or nay other directory you use for storing the VirtualBox files.
- Accept the privileges escalation:
-
Execute the following line:
Microsoft Windows [Version 10.0.16299.125] (c) 2017 Microsoft Corporation. All rights reserved. C:\Windows\system32>cd C:\Program Files\Oracle\VirtualBox C:\Program Files\Oracle\VirtualBox>VBoxManage.exe internalcommands createrawvmdk -filename "c:\Users\homer\.VirtualBox\physical-sdc.vmdk" -rawdisk \\.\PhysicalDrive3 RAW host disk access VMDK file c:\Users\homer\.VirtualBox\physical-sdc.vmdk created successfully. C:\Program Files\Oracle\VirtualBox>
- As you can see now we have a generated file, which can use when creating a virtual machine (look at STEP3))
-
First you must start the command line tool under linux also with administrative privileges!
* Create virtual machine under Linux and Windows using raw disk
- Under Windows 10 (and 7) we must run VirtualBox as administrator. Skip this if you are using linux.
- Confirm administrator privileges escalation under Windows 10 (and 7). Skip this if you are using linux.
- Create Virtual Machine with name “test”
-
Set the memory to the virtual machine – for example 1024Mbytes.
- Set the hard disk – our VMDK file to use our raw disk. Check “Use an existing virtual hard disk file” and click on “Choose a virtual hard disk file…” – a dialog will open.
- Navigate to where is your freshly created VMDK file from the STEP 2) and select it to open.
- Click “Create” to create the virtual machine.
* Here is how it looks like our VMDK file in VirtualBox “Virtual Media Manager”
* Troubleshooting under Linux
The permission problem accessing the disk under linux – NO WRITE permissions here:
srv@local ~ $ VBoxManage internalcommands createrawvmdk -filename "sdc-physical.vmdk" -rawdisk /dev/sdc VBoxManage: error: Cannot open the raw disk '/dev/sdc': VERR_ACCESS_DENIED VBoxManage: error: The raw disk vmdk file was not created
* Troubleshooting under Windows (10)
The permission problem accessing the disk under linux – NO WRITE permissions here:
Microsoft Windows [Version 10.0.16299.125] (c) 2017 Microsoft Corporation. All rights reserved. C:\Users\homer>cd C:\Program Files\Oracle\VirtualBox C:\Program Files\Oracle\VirtualBox>VBoxManage.exe internalcommands createrawvmdk -filename "c:\Users\homer\.VirtualBox\physical-sdc.vmdk" -rawdisk \\.\PhysicalDrive3 VBoxManage.exe: error: Cannot open the raw disk '\\.\PhysicalDrive3': VERR_ACCESS_DENIED VBoxManage.exe: error: The raw disk vmdk file was not created C:\Program Files\Oracle\VirtualBox>
You did not execute Command Prompt “Run as administrator”
And if you get the following error:
Permission problem accessing the file for the medium 'C:\Users\homer\.VirtualBox\physical-sdc.vmdk' (VERR_ACCESS_DENIED). Result Code: VBOX_E_FILE_ERROR (0x80BB0004) Component: MediumWrap Interface: IMedium {4afe423b-43e0-e9d0-82e8-ceb307940dda} Callee: IVirtualBox {9570b9d5-f1a1-448a-10c5-e12f5285adad} Callee RC: VBOX_E_OBJECT_NOT_FOUND (0x80BB0001)
- Create a virtual machine with our VMDK file
- Use our VMDK file
- VirtualBox – Error
What is in the VMDK file generated for a raw disk
- Linux
# Disk DescriptorFile version=1 CID=c7936918 parentCID=ffffffff createType="fullDevice" # Extent description RW 1953525168 FLAT "/dev/sdc" 0 # The disk Data Base #DDB ddb.virtualHWVersion = "4" ddb.adapterType="ide" ddb.geometry.cylinders="16383" ddb.geometry.heads="16" ddb.geometry.sectors="63" ddb.uuid.image="6386fe41-7f5c-49b6-930f-1bb7dd811603" ddb.uuid.parent="00000000-0000-0000-0000-000000000000" ddb.uuid.modification="00000000-0000-0000-0000-000000000000" ddb.uuid.parentmodification="00000000-0000-0000-0000-000000000000" ddb.geometry.biosCylinders="1024" ddb.geometry.biosHeads="255" ddb.geometry.biosSectors="63"
- Windows
# Disk DescriptorFile version=1 CID=7999bf08 parentCID=ffffffff createType="fullDevice" # Extent description RW 250069680 FLAT "\\.\PhysicalDrive3" 0 # The disk Data Base #DDB ddb.virtualHWVersion = "4" ddb.adapterType="ide" ddb.geometry.cylinders="16383" ddb.geometry.heads="16" ddb.geometry.sectors="63" ddb.uuid.image="70bcd06f-51e5-4468-b9ed-f356be4afd6b" ddb.uuid.parent="00000000-0000-0000-0000-000000000000" ddb.uuid.modification="00000000-0000-0000-0000-000000000000" ddb.uuid.parentmodification="00000000-0000-0000-0000-000000000000"
This ( along with https://www.pendrivelinux.com/boot-a-usb-flash-drive-in-virtualbox/) helped me figure out how to get ubuntu up and running inside virtualbox. Much appreciated
chmod 777 /dev/sdc* will solve it
You should go back to windows and think about what you’ve done.
it gives me an access denied and says this program will not run on your pc