OS Installation on USB drive with VirtualBox

VirtualBox virtualization software allows you to install any operation system directly to any attached block device such as USB stick/drive etc. This is actually a cool way to create you personalized Live Linux USB stick. This short “howto” describes how it works.
For the sake of this tutorial we will be using block device file name /dev/sdb to refer to our attached USB drive. First we need to create a raw vmdk virtual file disk linked to our /dev/sdb USB drive. As a privileged user execute the below command:

# vboxmanage internalcommands createrawvmdk -filename linux-live.vmdk -rawdisk /dev/sdb

With the above command we have created a raw VMDK file linux-live.vmdk linked to our USB drive /dev/sdb. Next, it is important to update permissions to give a non-administrative user write access to both /dev/sdb block device file and to the newly create VMDK file:

# chmod 666 linux-live.vmdk
# chmod 666 /dev/sdb

All done. Now you can start VirtualBox as a regular user and create a new virtual machine as per usual and when asked which virtual disk is to be used simply point the VirtualBox wizard to linux-live.vmdk and proceed with the OS installation.

Troubleshooting

The following error message appears if you have not give appropriate permission privileges as stated above:

Failed to open the disk image file /home/lubos/linux-live.vmdk.

Permission problem accessing the file for the medium '/home/lubos/linux-live.vmd' (VERR_ACCESS_DENIED).

Result Code: VBOX_E_FILE_ERROR (0x80BB0004)
Component: MediumWrap
Interface: IMedium {4afe423b-43e0-e9d0-82e8-ceb307940dda}
Callee: IVirtualBox {0169423f-46b4-cde9-91af-1e9d5b6cd945}
Callee RC: VBOX_E_OBJECT_NOT_FOUND (0x80BB0001)


Comments and Discussions
Linux Forum