Skip to content

Instantly share code, notes, and snippets.

@mapio
Created January 17, 2014 09:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mapio/8470611 to your computer and use it in GitHub Desktop.
Save mapio/8470611 to your computer and use it in GitHub Desktop.
To boot Virtualbox from a USB pendrive you must first create a virtual disk to access to it and then add it as storage.
#!/bin/bash
if [ -r USB.vmdk ]; then
VBoxManage storageattach "BootFromUSB" --storagectl "SATA" --port 0 --device 0 --medium none
VBoxManage closemedium disk USB.vmdk --delete
fi
sudo chown $USER /dev/disk1*
VBoxManage internalcommands createrawvmdk -filename USB.vmdk -rawdisk /dev/disk1 -partitions 1,2
VBoxManage storageattach "BootFromUSB" --storagectl "SATA" --port 0 --device 0 --type hdd --medium USB.vmdk
@mapio
Copy link
Author

mapio commented Jan 17, 2014

Of course, this assumes several things, such as, the name of the VM, the name of the device where the pen is mounted and the number of partitions that it is divided in… but should be quite easy to adapt it to different setups.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment