The other day I was trying to create multiboot USB drive with Ventoy in my Linux system. After creating the bootable drive, I added a few Linux ISOs to the bootable drive. But the problem is I had to reboot my system every time after adding a new ISO to the USB to check if the USB drive is working as intended. Since I had no additional system, It seemed a little bit time consuming task to me. I thought it would be better If I could boot from USB drive in Virtualbox in my Linux system. As you might know, Oracle Virtualbox doesn't offer any direct way to boot from USB. Fortunately, I found a simple workaround to allow Virtualbox to boot from an USB flash drive.
Boot From USB Drive In Virtualbox In Linux
To allow Virtualbox boot from USB drives, you need to create a .vmdk
file and point it to your USB drive for booting to it.
Heads Up: For those wondering, a vmdk file is nothing but a virtual disk file which contains all the information of a virtual machine.
First, you need to find your USB drive name. Refer the following guide to learn different ways to find disk drive details in Linux.
I am going to use "fdisk
" command to find my USB drive details:
$ sudo fdisk -l
Sample output:
[...]
Disk /dev/sdc: 14.54 GiB, 15597568000 bytes, 30464000 sectors
Disk model: Cruzer Blade
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x4d924612
As you can see, my USB drive name is /dev/sdc.
Now, open your Terminal and run any one of the following commands to create a vmdk file:
$ sudo vboxmanage internalcommands createrawvmdk -filename ~/usb.vmdk -rawdisk /dev/sdc
In some Linux distros, the vboxmanage command is case-sensitive. In that case, use the following command to create vmdk file:
$ sudo VBoxManage internalcommands createrawvmdk -filename ~/usb.vmdk -rawdisk /dev/sdc
The above command will create a new vmdk file named "usb.vmdk" in your $HOME directory. Upon successful vmdk file creation, you will see an output like below:
RAW host disk access VMDK file /home/sk/usb.vmdk created successfully.
Set proper permission to the newly created vmdk file:
$ sudo chown $USER:$USER ~/usb.vmdk
Next, add your user to "vboxusers" and "disk" groups using the following commands:
$ sudo usermod -a -G vboxusers sk
$ sudo usermod -a -G disk sk
Replace "sk" with your own user name.
Please be mindful that adding a user to "disk" group is dangerous and security risk. Now remove the USB drive and reboot your system to take effect the changes. If you don't remove your USB, the name of your drive letter may change at next boot. So it is important to remove the USB first and reboot the system.
Now open Oracle Virtualbox application and create a new virtual machine:
Enter the name of the VM, OS type and version and click Next to continue:
Enter RAM size:
This is an important step. Choose "Use an existing virtual hard disk file" option and click the browse button (UP arrow button):
Click "Add" button to choose the newly created vmdk file:
Choose the newly created vmdk file from your local drive:
After adding the vmdk file, click "Choose" button to confirm:
You will now see the vmdk file is selected as the virtual hard disk for the new virtual mahine. Click Next to continue:
All done! Now, plug your bootable USB drive and start the virtual machine:
Now you can be able to boot from USB in Oracle Virtualbox. Here I am booting the USB bootable drive created with Ventoy tool in Virtualbox:
Create An ISO From A Bootable USB Drive In Linux
This is another way to boot USB drive in Virtualbox. In this method, we don't need to create vmdk file. Just create an ISO image from the bootable USB using "GNOME disk utility" or "dd" command as described in the following link:
After creating the ISO, open Virtualbox application and go to the Settings of the any VM and add (mount) this newly created .iso file as an optical drive under "Storage Controller: IDE" option.
Now start the VM and it will boot from the ISO image.
Please note that this method will not work with all USB images, especially with multi-partitioned USB drives.
6 comments
could not get the usb.vmdk file to load into virtualbox due to permissions issue. Could you help me with this?
Set permissions for your user as described in the guide and also reboot the system.
$ sudo chown $USER:$USER ~/usb.vmdk
$ sudo usermod -a -G vboxusers sk
$ sudo usermod -a -G disk sk
Replace “sk” with your username.
I used this tutorial to install Windows 10 in VB on Linux Mint. I thought I had it to where I wouldn’t need the USB to start windows, but it will only start that way. How can I move the files to the pc and direct the virtual storage to them so I can boot natively?
I know common sense is to just restart booting from an ISO, but I’m trying to learn more about how everything works. My original goal was to install windows 10 to vm through usb.
I don’t know any direct way to do this. If I were in this situation, I would create an ISO of the USB drive and install Windows using the ISO. https://ostechnix.com/create-iso-bootable-usb-drive-linux/
SK you helped me make a dream come true! I was looking for a way to do this same thing! Ventoy and all! I am in love with Ventoy! I figured out how to setup persistent data for my Live Distro’s, and I was like, “It sure would be convenient to test this out in Virtualbox!”
Glad I could help. Ventoy is indeed an useful tool.