Bienvenido! - Willkommen! - Welcome!

Bitácora Técnica de Tux&Cía., Santa Cruz de la Sierra, BO
Bitácora Central: Tux&Cía.
Bitácora de Información Avanzada: Tux&Cía.-Información
May the source be with you!

Tuesday, April 16, 2013

Booting from USB devices in virtual box

Problems with older versions of virtual box
Direct booting from an USB device is not possible with VirtualBox as this requires USB support in the BIOS which we don't provide.
It is not passible directly but it is possible indirectly. Configure your USB drive as a raw disk in VirtualBox (page 105 of the manual). Then the guest will see your USB drive as a IDE drive and will be able to boot on it.
---------------------------------
RAW access isn't possible under NT6 (Vista, Server 2008 and Seven), because MS restricted it ... To avoid this Sun has to implent a driver which enables the option again ...
------
I can confirm that the plop manager does work outside of the virtual environment (I used to from a CD ][iso file] to boot from USB on an old motherboard)
------
Works great in VMware, other machines etc so I'm attributing it to VB environment.
------
Jul 2010
Made it work on VB 3.2.6 (non OSE) without freezing at the host 1 message.
Just had to enable the USB support (without enabling the USB 2.0 box in the settings window).
---------------------------------
I came up with this method for booting virtual box guests from USB devices a while ago. It works for me but might not work for others...
This guide contains a method for creating a Bootable CD that includes the Linux kernel and some other stuff including the USB driver needed to use a bootable USB device. This CD boots up and loads the USB driver then continues the boot process from any USB device.
This CD (iso file) can be used to boot a USB HDD in VirtualBox.
After creating a new virtual machine, select the USB section of that device’s settings and add a new USB device which would be the USB HDD. Then start the machine, boot from the bootable CD created before, and then the boot process continues and the OS found on the HDD would load.
Notes
    Saving the machine state doesn’t work.
---------------------------
Bingo! "Enable USB 2.0 (EHCI) Controller" must be un-checked before USB Booting will work with the PLOP iso. I've noticed that although it works, it reads from the usb key slowly.
 If anyone has a clue on how to fix the speed issue then everything would be working perfect!
---------------------------
I've got a bootable USB drive which contains (X)Ubuntu Linux, ie a kind of portable Ubuntu Linux. Boots well natively with the help of the PC's BIOS.
As suggested earlier in the forum, with the help of a Virtualbox command creating a small ".vmdk" file (which points to that USB drive), you can also boot the USB drive's Linux from within Virtualbox.
However, the Windows user account which runs Virtualbox needs Administrator rights in order to use the vmdk file.
On some Windows XP machines I've got Virtualbox running without Administrator rights and I still would like to boot this USB drive from within Virtualbox, but it won't work.
Is it possible?
To these Virtualboxes there's also attached a small virtual harddrive (real .vdi file) with a mini Xubuntu Linux. This could act as a starter. But how would you edit the GRUB2 loader so that it loads an USB driver and then boot from the USB drive (USB ports are enabled in the Virtualbox) ?
To be more clear: When I boot the mini Xubuntu from the virtual harddrive, at boot time there's no USB device available, but if Xubuntu has been loaded I can see and access the USB drive. So there must be some USB driver which sees that USB device within Virtualbox?
(P.S. PLOP within Virtualbox doesn't work on that USB device. No matter of USB 1 or 2 setting. It just hangs, like some posters already noticed.)
---------------------------
Here is a much easier and better way to get a USB drive to boot in a Virtual Machine. 
1. Go to http://www.plop.at/en/bootmanagerdl.html , and download the most recent .zip . 
2. Extract it, and navigate to /intsall/plpbtin.iso . 
3. Add the ISO in the VM, and install PLoP to the virtual hard disk (option 1)
4. Now, when you turn on the VM, it gives you an option to boot USB, Floppy, Hard Drive, and CD.
---------------------------
---------------------------
There is a guide to do it easily with VirtualBox 4:
---------------------------
---------------------------
I have v4.04 on W7 and have installed the same version of the Extensions. The USB thumb drive is in fact disk 2 according to disk administrator. I've also tried adding it with and without the USB section of Settings configured for the device, and with and without USB 2.0 being checked there. I even tried creating a second vmdk for another device, but no go.
# Disk DescriptorFile
version=1
CID=e1212ff4
parentCID=ffffffff
createType="fullDevice"

# Extent description
RW 3948544 FLAT "\\.\PhysicalDrive2" 0

# The disk Data Base
#DDB

ddb.virtualHWVersion = "4"
ddb.adapterType="ide"
ddb.geometry.cylinders="3917"
ddb.geometry.heads="16"
ddb.geometry.sectors="63"
ddb.uuid.image="46c5e09d-34c9-49fb-9f07-365ee7c21657"
ddb.uuid.parent="00000000-0000-0000-0000-000000000000"
ddb.uuid.modification="00000000-0000-0000-0000-000000000000"
ddb.uuid.parentmodification="00000000-0000-0000-0000-000000000000"
Reason of failure
If you are using Vista/Windows 7, due to access limitation rights you should run the VB with admin credentials. And it should work.
============================
VirtualBox is a free and easy to use multi-platform Virtualization software.
It means you can run a different OS inside your current OS (Linux in Windows, Windows in Linux, Linux in Linux, Windows in Windows, almost everything is possible!).
VirtualBoxLinux in Windows
It is very easy to start a new virtual machine and use space on a virtual hard drive on your local hard drive (or USB drive). Just follow the VirtualBox wizard.
However, some people want more portability in the physical meaning. To have a system that you can put in your pocket, bring anywhere, plug into any computer and it will run YOUR system.
This is possible by installing a system on a USB stick! This guide won't explain how to install an OS on a USB stick but how to boot on this USB disk in VirtualBox.
Sometimes you don't want to boot on your USB stick directly but within another running system. Then, you need to run the system in a Virtual Machine.
Unfortunately, VirtualBox doesn't allow you to boot from the USB from the GUI.
Nevertheless, there is a small trick to make it possible, using only a single built-in VirtualBox command-line tool.
Let see how to do so in this tutorial!
This tutorial is largely inspired by the Boot your USB Drive in VirtualBox tutorial by AgniPulse, only updating it to the last current version of VirtualBox (4.0).
I assume you have:
  • a bootable USB stick/drive with the system you want to boot on
  • VirtualBox installed with the Expansion Pack (to support USB2 devices)
First, we need to know what is the device ID of your USB. Plug your USB in.
If you are running VirtualBox on Linux, the USB ID will be something like /dev/sdx (for example /dev/sdb for me).
On Windows,  you can see it in the "Disk Management".
Start typing "dsk" after entering the Start Menu and choose Create and Format Hard Disk Partitions:
01_-_Disk_Management
Create and format disk partitions
Then you will have a page where you can identify the device number of your USB stick or drive.
In my case, my 8GB USB stick is on the Disk 1:
02_-_Disk_Manager
Disk Management
Note that on Ubuntu with VirtualBox 4.0.4 OSE (Open Source Edition): Make sure that you remove the USB device from the "USB Device Filters" list in the machine's settings (thanks Tim).
Now we are ready to create a Raw Virtual Machine Disk that will link to our USB stick.
Simply open a terminal on linux or a command-line tool on Windows (Win+R cmd) and change directory to your VirtualBox folder.
cd "C:\Program Files\Oracle\VirtualBox"
Then we run the VBoxManage command with the following options to link the USB Drive to a vmdk file (Virtual Machine Disk):
VBoxManage internalcommands createrawvmdk -filename output_usb.vmdk -rawdisk path_to_usb

You need to change the two red color highlighted parts to YOUR settings.

For example on Linux if I want to save in /home/thomas/.VirtualBox/usb.vmdk a virtual machine disk that links to my USB in /dev/sdb, I type the following line:
VBoxManage internalcommands createrawvmdk -filename /home/thomas/.VirtualBox/usb.vmdk -rawdisk /dev/sdb
On Windows, if I want to save the virtual machine disk in C:\Users\Thomas\.VirtualBox\usb.vmdk that links to my USB in in Disk 1 (according to the previous Disk Management), I type the following line:
VBoxManage internalcommands createrawvmdk -filename C:\Users\Thomas\usb.vmdk -rawdisk \\.\PhysicalDrive1
Replace the 1 in \\.\PhysicalDrive1 by YOUR device number os the USB drive (for example \\.\PhysicalDrive2).
Note: As noticed by Carlet, if any path contains spaces, write it between quotation marks (") to make it work.
Example: VBoxManage internalcommands createrawvmdk -filename "C:\Documents and Settings\Carletdesiles\.VirtualBox\usb.vmdk" -rawdisk \\.\PhysicalDrive1
Note: As noticed by Alex and skydvr, on Windows Vista/7, you need to start the command prompt as administrator (right click -> run as administrator) in order to access to the USB drive/stick.
That's it, you have done a Virtual Machine disk that should be very tiny (~1KB) and links to your USB drive.
You just need to import this hard drive in VirtualBox and use it as primary hard drive (to boot on) for your new system.
You can do it step by step by following the screenshots:
You can see the result of my Ubuntu 10.10 on my 8GB USB stick running on VirtualBox on Windows 7 at the very beginning of this article (first screenshot).
see Video of this tutorial
============================
http://www.plop.at/en/bootmanagers.html
The Plop Boot Manager is a small program with unbelievable many features.
Here is a list of features, but you can do more...
USB boot without BIOS support (UHCI, OHCI and EHCI)
CD/DVD boot without BIOS support (IDE)
PCMCIA CardBus support to enable boot from USB PC-Cards
Floppy boot
Different profiles for operating systems
Define up to 16 partitions
No extra partition for the boot manager
Hidden boot, maybe you have a rescue system installed and the user should not see that there is another system installed
Boot countdown
Hide partitions
Password protection for the computer and the boot manager setup
Backup of partition table data
Textmode user interface 80x50
Graphical user interface 640x480, 800x600, 1024x786, 1280x1024
MBR partition table edit
Start of the boot manager from harddisk, floppy, USB, CD, DVD
Starting from Windows boot menu
Starting from LILO, GRUB, Syslinux, Isolinux, Pxelinux (network)
It can be used as PCI option ROM in your BIOS
Access the whole USB hard disk (up to 2TB) even when the bios has a 128 GiB limit
You can run the boot manager over the network
Start the networkcard bootrom from the boot manager to boot from the network
Documentation - Download - News


Ubuntu Linux 10.04 LTS live USB flash drive with a Ubuntu ISO image and Oracle Virtual Box


19/06/2010
See how to make a Ubuntu Linux 10.04 LTS live USB flash drive with a Ubuntu ISO image and Oracle Virtual Box. No CD burning or Ubuntu install in Virtual Box is required. This is one of the fastest and most hassle free ways to make a Bootable USB live Flash drive with Ubuntu installed on it.

You need to first make the virtual machine in Oracle Virtual Box and mount your Ubuntu CD or ISO file on your newly created Virtual machine by going into the settings for Virtual Box and setting the CD to your Ubuntu ISO install Live Cd which you download from Ubuntu. Mount your USB thumb drive which has at least 700MB of free space or is 1 GB in size. Also, make sure the USB drive is at least a USB 2.0 drive. If you have a USB 3.0 drive it will be faster, but USB 2.0 is good enough for a Ubuntu live Flash drive. Save your settings, and start Ubuntu from Virtual box.

Wait for Ubuntu to load and pick "Try Ubuntu 10.04 LTS". Once Ubuntu is done loading, you should go to your System then Administration tools and Make Startup Disc creator, and pick your USB thumb drive. Click the "Make start up disc" button.

If you like, you can change the amount of space Ubuntu reserves for storing your personal files like music, docs, videos, etc.

Wait for Ubuntu to finish making your Ubuntu startup USB drive. It should take about 10-20 minutes depending on how fast your computer is and how fast your USB is.

The benefits of installing Ubuntu on a flash drive compared to a CD is it is faster, and quieter, and you can also install programs on your Ubuntu Flash drive and put your files on your drive.
 Create a Bootable USB Flash Drive to Install Ubuntu 11.10 in 2 min========================
http://reboot.pro/topic/8581-boot-your-usb-drive-in-virtualbox/
I am aware of three types of rawdisk-descriptors.
The names are given by the parameter "createType"
"fullDevice" used by VMware
"fullDevice' used by VirtualBox
"partitionedDevice" used by VMware
The examples all describe a 4 Gb kingston USB-stick
"fullDevice" used by VMware:
# Disk DescriptorFile
version=1
encoding="windows-1252"
CID=9e497682
parentCID=ffffffff
createType="fullDevice"
# Extent description
RW 7868416 FLAT "\\.\PhysicalDrive3" 0

# The Disk Data Base 

#DDB
ddb.virtualHWVersion = "7"
ddb.uuid = "60 00 C2 91 f9 42 a4 72-10 10 ca bb ac d1 35 28"
ddb.geometry.cylinders = "489"
ddb.geometry.heads = "255"
ddb.geometry.sectors = "63"
ddb.geometry.biosCylinders = "489"
ddb.geometry.biosHeads = "255"
ddb.geometry.biosSectors = "63"
ddb.adapterType = "lsilogic"
"fullDevice' used by VirtualBox:
# Disk DescriptorFile
version=1
CID=7a174421
parentCID=ffffffff
createType="fullDevice"

# Extent description
RW 7868416 FLAT "\\.\PhysicalDrive3"

# The disk Data Base 

#DDB
ddb.virtualHWVersion = "4"
ddb.adapterType="ide"
ddb.geometry.cylinders="7805"
ddb.geometry.heads="16"
ddb.geometry.sectors="63"
ddb.uuid.image="f005cd99-df1b-4c8d-8f75-1f71f37b4d75"
ddb.uuid.parent="00000000-0000-0000-0000-000000000000"
ddb.uuid.modification="00000000-0000-0000-0000-000000000000"
ddb.uuid.parentmodification="00000000-0000-0000-0000-000000000000"
"partitionedDevice" used by VMware:
# Disk DescriptorFile
version=1
encoding="windows-1252"
CID=bf09c8c4
parentCID=ffffffff
createType="partitionedDevice"

# Extent description
RW 63 FLAT "esx4-1-pt.vmdk" 0
RW 7855785 FLAT "\\.\PhysicalDrive3" 63
RW 12568 ZERO 

# The Disk Data Base 

#DDB
ddb.virtualHWVersion = "7"
ddb.uuid = "60 00 C2 9d 71 10 ee 3e-79 74 69 77 b1 97 70 df"
ddb.geometry.cylinders = "489"
ddb.geometry.heads = "255"
ddb.geometry.sectors = "63"
ddb.geometry.biosCylinders = "489"
ddb.geometry.biosHeads = "255"
ddb.geometry.biosSectors = "63"
ddb.adapterType = "lsilogic"
this type stores a copy of the first 63 sectors in an additional file named *-pt.vmdk"
In the case of the VMware - descriptors ... they can be easily redefined as IDE-disks.
Don't know if this works with virtualbox ? - never tested it.
The uuid-values can be skipped - they are not essential.
------------------

  • A "link" is not an image.
  • A "descriptor file" is not an image. 
  • A "virtual hard disk file" is not an image.
------------------
Added Linux Live USB which uses portable virtualbox . 
Updated tutorial to work with Virtualbox 4.
http://agnipulse.com...-in-virtualbox/
The new vboxmanage command no longer supports the register switch.So you have to manually add the vmdk file to your virtual machine. 
------------------
For LinuxLive USB Creator, I created a launcher for VirtualBox which automatically virtualizes the hard drive (or USB key) it is run from.
My launcher is a derivative work of Portable VirtualBox 
http://vbox.me
and can either runs in Portable Mode or in regular mode if you already have VirtualBox installed on your machine.
You can download it from :
  • Here for VirtualBox 4.X
You just have to unzip it to the hard drive you want to Virtualize then run VirtualBox.exe for full interface orVirtualize_this_key.exe to directly run the VM.
/!\ DO NOT USE THIS ON YOUR SYSTEM HARD DRIVE IT MAY CORRUPT IT /!\
How it works
It automatically creates the VMDK file for your hard drive (or USB key). I'm talking about a raw device mapping here, not a clone image.
Launcher then checks if you already have VirtualBox :
  • if you do have it, then it runs the regular VirtualBox (no changes are made to your VirtualBox config since it's another one that is loaded)
  • if you don't have it, then it runs Portable-VirtualBox
Now you can show Linux (or any other OS) to your friends directly on their computers.
Technical details
I'm using VBOX_USER_HOME environment variable in order to start VirtualBox with another configuration.
To create a Raw Device Mapping, i'm using WMI, which may not work on Windows Home editions (needs confirmation).
Portable version may not have all the features working.
==============================
http://www.pendrivelinux.com/boot-a-usb-flash-drive-in-virtualbox/
http://como-hace.blogspot.com/2011/07/como-hacer-el-usb-bootable-en.html

No comments: