Ubuntu – Install a guest Win10 in VirtualBox in Ubuntu 20.04 from USB

20.04bootusbvirtualbox

I am running VirtualBox 6.1.6_Ubuntu r137129 under Ubuntu 20.04.

I have a USB stick with a Win10 installer created from within Win10.
I want to create a VM and install Win10 from the USB.

How can I do that?
When trying, I get an error, see below.

Install a guest Win10 in VirtualBox in Ubuntu 20.04 from ISO
is a "companion", but different, question.


This asks something similar, but with much older versions (Virtualbox 4.0.4 Fedora 14), so the question is not exactly the same.
The accepted answer links to here, dating back to 2013.
The solution posted:

  1. Create a VM access which points to the USB (I could do that)
$ sudo vboxmanage internalcommands createrawvmdk -filename ~/VirtualBox_VMs/usb.vmdk -rawdisk /dev/sda1
RAW host disk access VMDK file /home/user1/VirtualBox_VMs/usb.vmdk created successfully.
  1. In the VM (I had already created it), go to Settings -> Storage -> Adds hard disk. (a small icon to the right of Controller: SATA) -> Add -> (Navigate to and select the usb.vmdk file just created) -> OK.

    Here I get the error
Permission problem accessing the file for the medium '/home/santiago/VirtualBox_VMs/usb.vmdk' (VERR_ACCESS_DENIED).

Result Code: 
VBOX_E_FILE_ERROR (0x80BB0004)
Component: 
MediumWrap
Interface: 
IMedium {ad47ad09-787b-44ab-b343-a082a3f2dfb1}
Callee: 
IVirtualBox {d0a0163f-e254-4e5b-a1f2-011cf991c38d}
Callee RC: 
VBOX_E_OBJECT_NOT_FOUND (0x80BB0001)

Error trying to make USB drive into bootable host drive in Virtualbox (also an old question) deals with the same error, but since the guest OS is Ubuntu it has the option of mounting the .iso image, which apparently solves the issue.
I do not have that option, I have to create a RAW host disk access instead.

Install windows 7 through virtual box
provides the same solution (.iso file).


Related:

Cannot run native Ubuntu in virtualbox with a vmdk created using the createrawvmdk command with partitions specified

installing an os from a usb

How to Boot From a USB Drive in VirtualBox

Google search

Best Answer

With the command you refer in your point 1) you create a raw vmdk device who points to the /dev/sda1 partition. However, when you try to access it you get a permission error. So my guess is that, although you have the right permissions on the usb.vmdk file you just created, you probably don't have read/write access to the raw partition device, which is where VirtualBox ultimately goes.

Try ls -l /dev/sda* and check the permissions. As you will use this raw vmdk device solely for installation purposes, I suggest to temporarily allow access to everyone to this device: chmod a+rw /dev/sda1.

I just had this identical problem and that solved the error for me.