Installing windows on a flash drive via virtualbox. Booting from a USB drive into VirtualBox

Typically, the operating system is installed in VirtualBox via an ISO file or CD/DVD disc. But you know that you can also boot from USB disk in VirtualBox? Many people don't know this simply because the feature is hidden and not accessible through the GUI. In fact, you will have to open a terminal (or command line) and use the VBoxManage command to access this feature. In this guide, we will look at the ability to boot (or install an OS) from a USB device in VirtualBox.
Note: This guide is carried out on Windows machine. Steps may vary for Linux/Mac.
Note 2: This guide assumes that you already have a bootable USB drive with some operating system (probably a Linux distribution) installed on it.

Booting from a USB Drive in VirtualBox

Before you do anything, run Windows system, and connect the bootable USB drive. Now we need the number of this bootable usb disk.
Note: Don't confuse the drive number with the drive letter. They are not the same.
We can find out the disk number from Disk Management utility or any other third party disk management programs. Currently we will use Windows utility. Press the key combination “Win ​​+ R” and use the command “ diskmgmt.msc”, and then click the “OK” button. About others useful commands dialog box "Run" read the article.

Look at the USB drive and remember its number. In my case, the USB disk is shown as "Disk 7", so the disk number is "7".

After you have found out the disk number, run Command Prompt with administrator rights. In Windows 8, this can be done by pressing the “Win+X” key combination and selecting the desired menu item.

Go to folder VirtualBox installations using the following command. If you installed VirtualBox in some other directory or drive, then change the command accordingly.

cd %programfiles%\Oracle\VirtualBox

Enter the following command, replacing the “#” character with the actual drive number. This command will create a VMDK file in the C drive, which points to the physical USB drive.

VBoxManage internalcommands createrawvmdk -filename C:\extdisk.vmdk -rawdisk \\.\PhysicalDrive#

After you execute the command, you will receive a confirmation message and also see new file with the name “extdisk.vmdk” in the root of drive “C”.

Now open VirtualBox with administrator rights. If you do not do this, VirtualBox will not boot from the USB drive.
After opening VirtualBox, create a new virtual machine as usual. At the stage when VirtualBox prompts you to add a hard disk, set the switch to the “Use existing virtual HDD" Click on this little folder icon and select the file we just created. Click on the "Create" button to complete the process.

You will see the new virtual machine listed on the left side of the VirtualBox window. Just select it and click on the “Run” button located in top menu to boot from the USB drive. As you can see in the picture below, I have successfully booted into my Ubuntu live disk.

That's all there is to it, and it's actually very simple. I hope that my article was interesting to you. Write in the comments your tips for working with VirtualBox, subscribe to our news and stay with us.


Everyone is good for testing operating systems and software, but for some reason, none of these hypervisor programs provide the option to boot from a flash drive in a normal usable format. Having the ability to boot from images of bootable CDs/DVDs can solve the problem of viewing the contents of the latter, but in this way the need for testing a finished bootable flash drive will not be satisfied. Check the functionality of the bootable flash drive on the virtual machine, test the software contained in the resuscitation Live disk in conjunction with the virtual hardware, take screenshots of this action, install operating system, the distribution package of which is only available on a flash drive - but you never know for what needs you may need the ability to boot from a USB drive.

How to configure booting from a flash drive to virtual ones VirtualBox machines And VMware Workstation– we will look into this below. And for these purposes we will use the bootloader Plop Boot Manager.

1. Preparing the Plop Boot Manager disk image

Details about the purpose of demon paid program-the Plop Boot Manager loader was discussed in the site article. Designed to solve the problem of the lack of an option to boot from USB devices in the BIOS of older computers, Plop Boot Manager will also help solve the problem of booting from a flash drive in virtual machines. Download the latest distribution from the developer’s official website.

After unpacking the Plop Boot Manager archive, we can delete the contents of the folder, leaving only the required ISO disk image - the file "plpbt.iso".

It is better to immediately move this file to a secluded place, say, to a folder with the same virtual machines, since when using this ISO image, its placement path will be specified in the hypervisor settings. The latter, in fact, is what we will do next - we will configure the “plpbt” ISO image as a source for loading VirtualBox and VMware Workstation virtual machines.

2. Booting from a USB flash drive into VirtualBox

The VirtualBox virtual machine must be turned off when setting it up to boot from a flash drive. Click the settings button. In the window that appears, first look at the section “ System" to ensure that the boot order is for the drive initially. The checkbox should be checked at the item “ CD/DVD».

Now go to the section " Carriers" Click " Controller: IDE" and select the button labeled " Empty"(if no other disk image is attached to the virtual machine). Next we need the parameter “ Attributes" At the end of the column " Drive unit"Press the button in the form of a disk, then click the review button with the inscription " Select optical disk image».

In the Explorer window, open the same file “ plpbt.iso».

That's it: now the Plop Boot Manager disk image will be mounted into the VirtualBox virtual drive. Click " OK».

Insert the flash drive into the USB port of the computer. Let's start the virtual machine. The latter will boot from the Plop Boot Manager disk image and in its window we will see a minimalist boot menu, the options of which include USB devices. But first you need to connect the flash drive to the virtual machine. Click the small button at the bottom of the window with the image of a USB input and check the box for the desired USB device. In our case, the flash drive is the only one of these.

We will see the Plop Boot Manager interface again and now we can select the boot option – USB. To interact with the bootloader interface, you need to log into the virtual machine and grab the mouse - that is, double-click inside its window. Let us remind you that by default, releasing the mouse pointer from being captured by the virtual machine in the VirtualBox program is done using the right Ctrl key. To navigate through the boot options in the Plop Boot Manager menu, use the navigation keys “” “↓”, and confirm the selection of the boot device with the Enter key.

To get the VirtualBox virtual machine to boot again with hard drive, you can either set the boot order from last in the settings section " System" - which we, in fact, checked above, or remove the disk image from the drive virtual machine. The easiest way to do this is by clicking the disk-shaped button at the bottom of the virtual machine window. One of the available functions will be " Remove the disc from the drive».

However, if bootable flash drives are tested frequently, you can simply select the option to boot from the desired disk partition in the Plop Boot Manager window.

3. Booting from a USB flash drive to VMware Workstation

Okay, VirtualBox is still free, but for the paid VMware Workstation program, the lack of a simple and clear option for booting a virtual machine from a flash drive is unacceptable. However, even after paying, we will solve this problem through our own efforts.

As with VirtualBox, the VMware Workstation virtual machine must also be turned off. In its details window, click the option to change settings.

Let's get into the parameters of the virtual machine, here we need the tab " Equipment" Move to the tab " CD/DVD", set the active option " File ISO image ", then use the browse button to specify the path to the file " plpbt.iso" Click " OK».

Returning to the virtual machine details window, click on the drop-down list of its states and select “ Enable when flashing" In our case we are dealing with latest version VMware Workstation 11. But in earlier versions of the program or in different editions of the VMware Workstation translation, this option may be called differently, for example, “ Enable in BIOS", English version - " Power On to BIOS».

Unlike VirtualBox, VMware Workstation does not provide for setting the boot order of the virtual machine in its settings. Everything happens as if real computer: the priority of boot devices is assigned in the virtual BIOS - an analogue of the real basic input / output system.

After starting the virtual machine in BIOS mode, log into it (by double-clicking inside the window or using the keys Ctrl+G). For reference: by default, releasing the mouse pointer in VMware Workstation is done using the Ctrl+Alt keys. Using the navigation keys “→” we move to the “ Boot", then use the "↓" key to go down to the parameter " CD-ROM Drive" Use the “+” key to push it to the beginning of the list and click “ F10».

We confirm the decision by pressing Enter in the window with the preset answer option “ Yes» to the request to save the configuration.

The virtual machine will restart and we will see the Plop Boot Manager interface. Just as in the case of VirtualBox, at the bottom of the virtual machine window, click the USB devices button and connect the flash drive.

Restart the virtual machine.

Now we can go inside it and select the option to boot from USB devices in the Plop Boot Manager menu.

Returning the VMware Workstation virtual machine to boot from the hard drive is the reverse process. You need to enter the BIOS and set the boot priority to " Hard Drive" - just as it was before. You can do it differently and remove the Plop Boot Manager disk image itself. At the bottom of the virtual machine window there is a button in the form of a disk; it provides quick access to the drive settings. Click " Options».

In the virtual machine drive settings window, we can either uncheck the device status “ To plug", or make active the option to detect a physical CD/DVD drive.

Did this article help you?

From a flash drive, but not in quality removable media, but as bootable media. But let's talk about everything in order.

The Virtualbox functionality allows you to boot from a flash drive.

The first method works for Virtualbox versions 4.2.36 and lower. For newer versions, a second method has been added.

You must log in to the command line with administrator rights. To do this, go to “Start” and type “cmd” in the search bar, click right click mouse on the result and select “Run as administrator”. Necessarily! Otherwise the command will not create the file. If you don’t want to run the command line as an administrator every time, you can disable “Control accounts" The shutdown process is described at the end of the article.

The second method requires that Virtualbox and Virtual Machine USB Boot be run as administrator. You can check this by right-clicking on the program shortcut, going to the “Properties” window, and then switching to the “Compatibility” tab and making sure that the “Run this program as an administrator” checkbox is checked.

We try to connect in the usual way

Open the Virtual Machine Manager. Click the “Configure” button. Go to the “USB” section and click on the add a new device icon, select our flash drive. Click “OK”. Let's start the virtual machine. As we see, removable drive we have it, you can open it in “My Computer”. Let's try to boot from it. Click “Reboot”. During the reboot, we press the “F12” key and we do not see our flash drive in the list. Unfortunately, you won't be able to boot from it this way. What to do? And you don’t need to do much, but it’s interesting.

We turn off our virtual machine and close the Virtual Machine Manager for now. A removable media autorun message appears, which means that the Manager has transferred control of the flash drive to the system.

Using the command line to create a file

To boot from a flash drive into Virtualbox, you need to run this command:

C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" internalcommands createrawvmdk -filename D:\Transcend.vmdk -rawdisk \\.\PhysicalDrive2

Which states:

  • C:\Program Files\Oracle\VirtualBox\VBoxManage.exe - which program will execute the command (the path must be changed if the program was installed in a different location);
  • internalcommands createrawvmdk -filename - the command itself;
  • D:\Transcend.vmdk -rawdisk \\.\PhysicalDrive2 - with which file the disk will be created; The letter “D” at the beginning can be replaced with the letter of any of your drives, a file will be created there; the number “2” at the end is the disk number; we’ll look further at how to find it out.

We go to computer management, from there to disk management and find our drive among all the others. Its number will tell us which number to use in the command. In our case, “Disk 2”. It is important. If you specify the wrong drive, the system will not boot and work. We copy our command using the keyboard shortcut “Ctrl + C”. Open the command line as administrator and paste the command using “Ctrl+V”, click “OK”. A command line window will appear for a split second. Now let's find our file. It is located in the path that we specified earlier in the command and is named “Transcend.vmdk”. For convenience, move the file to the desktop.

Functionality check

Launch the Virtual Machine Manager and click “Configure”. It's very important point: The system will not boot until we disconnect our device in the “USB” tab. Go to the “Media” section and assign the first port to the existing “Test.vdi” disk. Select the controller, click the icon for adding a new hard drive, click “Select an existing disk” and select our file, click “Open”. Our flash drive has a zero port. What is it for? If you leave the default zero port on the disk that was in the virtual machine, and assign the first port to the flash drive file, then the system will boot from the disk that has a zero port. Let's check how it works, click "OK" and start the virtual machine.

We now have a menu where we can boot from the hard drive, select the programs we need, restart or turn off the computer. Let's try to restart the computer, everything is fine.

You can also connect an external hard drive to the Virtualbox virtual machine. Turn off the computer. Let's summarize.

If we connect a flash drive in the “USB” section, it will be displayed in our system, but we will not be able to find it. If you connect it in the “Media” section, then everything will work. If the number of the flash drive in the system suddenly changes, the file that was created can be edited using a regular notepad. We need to find the line with the phrase PhysicalDrive and replace the number with a new one.

The second method is with the Virtual Machine USB Boot program

As noted, the first method is only suitable for Virtualbox versions 4.2.36 and lower. The manipulations described below were tested on version 5.0.12 and definitely work on it.

Since version 4.3, users have had problems with installing Windows from under a bootable USB flash drive in a virtual machine. An error could appear at any stage of the installation and the process would be interrupted. The problem is solved by the Virtual Machine USB Boot program; the developers’ website has both a portable version and an installer; it weighs quite a bit. Be sure to check both the Virtual Machine Manager and our program to work with administrator rights. Before running the Virtual Machine USB Boot utility on the machine under test, you need to switch the hard drive from the SATA0 port to the SATA2 or SATA3 port. SATA0 should be empty; the utility will connect our flash drive into it.

We launch the Virtual Machine Manager, then launch the utility. In the utility window, click the “Add” button. We choose the name of the virtual machine and name it at our discretion. In the third line, select exactly the virtual machine that we will subsequently use. The utility looks through the Virtualbox directory and gives us all the mounted machines, select the one we need. In the “Drice to add and boot” field, select our flash drive. Click “OK” and “Start” twice. This completes the setup and you can start the virtual machine.

Disabling User Account Control

An addition to the first method, which will allow you to enter the command line without administrator rights or even execute a command directly from the Run window. We need to open the registry editor, to do this, press the “Win ​​+ R” key combination, the “Run” window will open, enter the “regedit” command there. We move along the path HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows/CurrentVersion/Policies/System, in this folder we look for the EnableLUA line and change the value from 1 to 0. To do this, right-click on the line and in context menu select the “Change” item. Subsequently, the value can be returned back and User Account Control will return.

Conclusion

So, we used the Virtual Machine Manager Virtualbox, booting from the flash drive was completed. We looked at two methods, for VirtualBox versions lower and higher than 4.2.36. The setup process itself is simple, but you need to take into account many factors and subtleties, most of them are listed under the heading “Warnings”, the rest are included in the analysis of methods. Be careful and over time virtual machines will be your faithful companion when working with new applications and utilities. After all, it’s better to check the functionality of a dangerous or unknown program 5 times than to disable a real machine once, isn’t it?

If you have any questions, ask them in the comments!

While doing system administration, I often have to use virtual machines like Oracle WM VirtualBox And WMWare Workstation. I use VirtualBox more often due to the fact that it is simpler and lighter for single launches. There was a need to boot a virtual machine from a real USB flash drive, in in this case, to check a freshly assembled bootable flash drive. But there is one trouble - through the main interface VirtualBox programs It is impossible to boot a virtual machine from a physical USB drive, however, there is a way to solve this problem. This is the method that will be discussed in the article.

To boot a VirtualBox virtual machine from external USB disk, you need to create USB disk clone as *.vmdk file, through which the VirtualBox host will communicate with a physical external USB drive. Such a file will occupy several kilobytes, because... contains only data for communication with a USB drive.

1. Create a file that serves as a bridge between VirtualBox and a USB drive.

To create a *.vmdk file, there is a utility called vboxmanage.exe, which is included in the standard package of VirtualBox, so you do not need to download it separately.

So, to create such a file, you need to run the following command in the command prompt window, replacing the path to the VirtualBox directory with your own:

"C:\\Program Files\\Oracle\\VirtualBox\\VBoxManage.exe" internalcommands createrawvmdk -filename c:\\temp\\usb.vmdk -rawdisk \\\\.\\PhysicalDrive2 -register

There are two parameters to pay attention to here:

To find out the number of the external USB drive to which the file should be associated (usually an external USB HDD under the number 1 , if only one hard drive is installed), you can peek at it in “Control Panel → Administrative Tools → Computer Management → Disk Management”.

Now all that remains is to configure the VirtualBox host to boot from the newly created virtual disk.

2. Install a *.vmdk file in VirtualBox as a boot disk.

First you need to add the created usb.vmdk to the list hard drives in the VirtualBox virtual media manager.

Next, go to the “Properties” of the virtual machine (which must be loaded from USB external drive) and in the "Media" section install the added virtual hard disk usb.vmdk in Slot « Primary master IDE" as in the screenshot.

Done, now you can boot the virtual machine from an external USB drive.

In this post, I will tell you how to connect a USB drive to a virtual machine so that the guest system treats it as a regular hard drive.

This trick will not only allow you to boot from installation USB- which, in my opinion, is quite pointless, since an ISO image is recorded on a flash drive, which is much easier to connect to virtual computer in VirtualBox. If you connect a USB drive or flash drive to the guest system as a regular drive, you can do such interesting things as:

If you do not have the opportunity to connect a SATA drive directly to a computer - for example, to a laptop - but you really need to boot into the operating system that is deployed on it, then the trick described here will help you do this: connect the SATA drive to the computer using a USB adapter, and then connect the USB disk to the virtual machine as a regular disk, as shown in this instruction.

Regarding the second point - installing Windows on a USB drive - if you want to install Linux on a flash drive (not burn a Live image, but install a full-fledged system), then for installation it is not necessary to do the trick shown here - since Linux installs perfectly on a portable drive. But Windows prohibits installation on USB drives and flash drives.

I'll show you how to boot from USB in Windows and Linux. The principle is the same in both of these operating systems, but the commands are slightly different due to the specifics of the OS.

How to boot from USB in VirtualBox in Windows

Connect USB flash drive or disk to your computer. Then click Win+r and execute diskmgmt.msc.

Find your flash drive and remember the disk number:

For example, in my screenshot the flash drive is number 2.

Close all VirtualBox windows if they are open.

In the window that opens, enter:

Now go to the folder where you have VirtualBox installed. If this program is installed in the default directory, then the command to go to is:

Cd %programfiles%\Oracle\VirtualBox

If you chose a different location for VirtualBox, then edit the previous command accordingly.

Now in command line paste the following command in which replace # on the disk number that we looked at just above, then press Enter:

VBoxManage internalcommands createrawvmdk -filename C:\usb.vmdk -rawdisk \\.\PhysicalDrive#

For example, this is my second disk, then the command looks like this:

VBoxManage internalcommands createrawvmdk -filename C:\usb.vmdk -rawdisk \\.\PhysicalDrive2

If everything went well, the following message should appear:

RAW host disk access VMDK file C:\usb.vmdk created successfully.

Please note that you can replace C:\usb.vmdk to any file location you wish.

This command creates a virtual machine disk (VMDK) file pointing to the physical disk you selected. When you load a VMDK file as a disk in VirtualBox, then VirtualBox will actually have access to the physical disk.

Now open VirtualBox as an administrator - this is mandatory, otherwise it will not work as expected. To do this, click the button Start, dial VirtualBox and select " Run as administrator»:

VirtualBox can only access raw disk devices with administrator rights.

Now in VirtualBox, create a new virtual machine, select the appropriate operating system and when it comes to choosing a hard drive, instead of creating a new one, select Use an existing virtual hard disk:

Now open the file C:\usb.vmdk(or another one if you saved it in a different location or under a different name):

Boot your virtual machine, now it should see your USB flash drive as a regular hard drive. That is, if it is correctly written boot disk or flash drive, then the system will boot from it.

note that USB device should be first hard drive in your virtual VirtualBox machine, otherwise the download will not occur. If you connect new usb disk to an existing machine, then try changing the media order in the settings of this machine, or select the appropriate disk at the beginning of booting.

How to boot from USB in Linux in VirtualBox

To understand the principle, read the previous section about Windows. In Linux, to find out the name of the USB drive, run the command:

Sudo fdisk -l

In my case, the disk has a name /dev/sdb.

To create a virtual disk file pointing to a real disk, run a command like:

Sudo VBoxManage internalcommands createrawvmdk -filename /root/usb.vmdk -rawdisk /dev/sd#

Where instead # Enter the letter of the corresponding drive. Example for my conditions:

Sudo VBoxManage internalcommands createrawvmdk -filename /root/usb.vmdk -rawdisk /dev/sdb

In this command, you can replace /root/usb.vmdk with another location of your choice.

To run VirtualBox with administrator rights, run the command:

Sudo VirtualBox

Everything else is to create a virtual machine and select an existing hard drive virtual disk- exactly like in Windows.