Linux install into, or boot from USB flash drive in VirtualBox

Requisites:

You have a working installation of Oracle VirtualBox

The directory you keep your virtual machines is $HOME/VM (our example)

You have created a virtual machine called alpha (our example) that has no hard disk

You have plugged in your USB stick and its device name is /dev/sdx (our example)

Objectives:

You want to install Linux on a USB flash drive from within VirtualBox
OR:
You want to boot a USB flash drive using VirtualBox

Once the above requisites are met, run the following in a terminal:

VboxManage internalcommands createrawvmdk -filename $HOME/VM/alpha/usbflash.vmdk -rawdisk /dev/sdx

Run the Oracle VM VirtualBox Manager, select the alpha virtual machine and go to its Storage properties, then select the hard disk controller and add the newly created disk usbflash.vmdk

Confirm all your changes and close the Storage properties.

Start the alpha virtual machine and you will find that your USB flash drive

now is attached as a hard disk that you can install Linux to, or boot from