how to create VMDK file in Virtualbox for adding USB as a new OS?

3

4

I have a USB which has OSes on it. Now I want to create VMDK file to use them in VirtualBox.

I read many articles but never found how I can use them. In an article I found the way that:

C:\Program Files\Oracle\VirtualBox > VBoxManage internalcommands createrawvmdk -filename D:\usb.vmdk -rawdisk \\.\physicalDrive<Disk 1> -register

It's not working. I try it without register but nothing happened. If I open my diskmsgmt.msc then they show me the drive's name is Disk 1 Removable

I want to know how I can do this. The problem is that when I run the command the system tells me file not found.

I tried checking the USB. It's working fine. I think that there is may be two reasons for the problem:

  1. The disk name has whitespace so I think it doesn't work because of that.
  2. I'm missing something in the commands.

Can anyone explain what commands I need to use so that it works for me?

(I tried the commands with VirtualBox not VMware)

Anirudha Gupta

Posted 2011-03-29T01:42:46.007

Reputation: 1 083

Answers

5

Simply open a terminal on Linux or a command-line tool on Windows (Win+R cmd) and change directory to your VirtualBox folder.

cd "C:\Program Files\Oracle\VirtualBox"

Then we run the VBoxManage command with the following options to link the USB Drive to a vmdk file (Virtual Machine Disk):

VBoxManage internalcommands createrawvmdk -filename usb.vmdk -rawdisk "path_to_usb"

For example on Linux if I want to save in /home/thomas/.VirtualBox/usb.vmdk a virtual machine disk that links to my USB in /dev/sdb, I type the following line:

VBoxManage internalcommands createrawvmdk -filename /home/thomas/.VirtualBox/usb.vmdk -rawdisk /dev/sdb

On Windows, if I want to save the virtual machine disk in C:\Users\Thomas.VirtualBox\usb.vmdk that links to my USB in in Disk 1 (according to the previous Disk Management), I type the following line:

VBoxManage internalcommands createrawvmdk -filename C:\Users\Thomas\usb.vmdk -rawdisk \\.\PhysicalDrive1

Replace the 1 in \\.\PhysicalDrive1 by YOUR device number of the USB drive (for example \\.\PhysicalDrive2).

If any path contains spaces, write it between quotation marks (") to make it work. Example:

VBoxManage internalcommands createrawvmdk -filename "C:\Documents and Settings\Carletdesiles\.VirtualBox\usb.vmdk" -rawdisk \\.\PhysicalDrive1

That's it, you have done a Virtual Machine disk that should be very tiny (~1KB) and links to your USB drive.

You just need to import this hard drive in VirtualBox and use it as primary hard drive (to boot on) for your new system.

cyberkeeper1

Posted 2011-03-29T01:42:46.007

Reputation: 66

Works perfectly! You will need to run both VirtualBox and VBoxManage as administrator in order to use this (to run VBoxManage as admin, run the command prompt as admin) – Barak Itkin – 2014-11-15T09:36:35.757

Any changes I make to the mounted partition do not appear back on this USB disk, is this normal? – Panda – 2015-03-24T15:14:44.783

On linux, if you don't want to run virtualbox or VBoxManage as root, you can chown the disk to your user: sudo chown USER:USER /dev/sdx – nishantjr – 2016-03-11T04:07:05.443

you dont need the "-register" command. follow the text exactly and it will work. – cyberkeeper1 – 2011-12-04T05:16:46.877