EDIT: 7 Mar 2018
Something to note here. Leaving the USB drive in the computer when you reboot can change the
/dev/sd drive letter designation causing the raw
usb.vmdk file to point to the incorrect drive so it does not boot in VirtualBox. As a test I left one in my system. It was
/dev/sdi before I rebooted, after reboot it was
/dev/sdc. When you reboot your computer for any changes please remove the USB drive prior to rebooting. I am looking into if the raw disk can be created from the UUID of the drive instead as that will not change.
Since VirtualBox does not boot to USB drives, you can create a
.vmdk file that points to your USB drive for booting to it.
NOTE: You MUST add your user account to the
vboxusers group for VirtualBox to see your USB. You MUST also add your account to the
disk group as well, or you cannot add the
.vmdk file to your Virtual Machine. Added instructions below in EDIT. This also does not copy the USB drive to the hard drive and uses the USB directly. This can be helpful if there is persistence on the USB that you want to keep. Not every situation is the same so this may not work for every case.
First, you need to have your USB you created in your system, and determine what the physical drive is. We are going to assume that your drive is mounted as
/dev/sdb1. So, the physical drive would be
Next, type in the following from a terminal window to create the
.vmdk file that points to the USB drive:
sudo vboxmanage internalcommands createrawvmdk -filename ~/usb.vmdk -rawdisk /dev/sdb
sudo VBoxManage internalcommands createrawvmdk -filename ~/usb.vmdk -rawdisk /dev/sdb
Then you should see something similar to this:
RAW host disk access VMDK file /home/ravan/usb.vmdk created successfully.
Note: Some people have had issues of ownership of the newly created file. Take ownership of the new file:
sudo chown $USER:$USER ~/usb.vmdk
Then all you should have to do is to add the
.vmdk file to your VirtualBox Virtual Machine and make sure that you can boot to it.
To add your user to the
vboxusers group, run the following command:
sudo usermod -a -G vboxusers username
To add your user to the
disk group, run the following command:
Note: Adding your user to the disk group can be dangerous and a security risk. It is as dangerous as having sudo access to write to a raw disk.
sudo usermod -a -G disk username
Then you MUST REBOOT your system in order for the changes to take effect.
Hope this helps!