Virtualbox and raw disk problem

raw-diskvirtualbox

I'm trying to use a raw disk in virtualbox, following this guide.

Anyhow I get an error:

mamluck@mamluck:~/VirtualBox VMs/disks$ VBoxManage internalcommands createrawvmdk -filename /home/mamluck/VirtualBoxVMs/disks/disk1.vmdk -rawdisk /dev/sda
VBoxManage: error: Cannot open the raw disk '/dev/sda': VERR_ACCESS_DENIED
VBoxManage: error: The raw disk vmdk file was not created

and:

mamluck@mamluck:~/VirtualBox VMs/disks$ sudo !!
sudo VBoxManage internalcommands createrawvmdk -filename /home/mamluck/VirtualBoxVMs/disks/disk1.vmdk -rawdisk /dev/sda
VBoxManage: error: VMDK: could not create new file '/home/mamluck/VirtualBoxVMs/disks/disk1.vmdk'
VBoxManage: error: Error code VERR_ALREADY_EXISTS at /home/vbox/vbox-4.0.6/src/VBox/Storage/VMDK.cpp(3591) in function int vmdkCreateRawImage(VMDKIMAGE*, VBOXHDDRAW*, uint64_t)
VBoxManage: error: Cannot create the raw disk VMDK: VERR_ALREADY_EXISTS
VBoxManage: error: The raw disk vmdk file was not created

what am I doing wrong?

Best Answer

The error is VERR_ALREADY_EXISTS.

Is there already a file named /home/mamluck/VirtualBoxVMs/disks/disk1.vmdk ? If there is a file named disk1.vmdk, stop naming your disks with default names. You should be able to clearly recognize the disk from its filename. This will help avoid name collisions.

You can't/shouldn't use the same disk/partition that is in use on the host. Is sda or any partition on sda being used?

You'll need a separate drive that is not mounted and has no swap partitions in use to use for the virtual raw disk or you'll have to use a partition only that is not mounted/in use for raw access.

The raw virtual disk for a full disk works fine whether the disk is partitioned or not, contrary to what Muad'Dib said. You can partition/re-partition a raw virtual full disk at your leisure, just as you would a physical disk.

A raw disk mapped to a partition would of course have to exist first.