How to install Windows on a USB storage

Windows on USB HDD

In this manual, I will show a trick with which you can get a portable Windows on an external USB drive.

This drive is not tied to a computer and should boot on any other laptop or desktop PC. The main thing that it should be not quite an old machine (EFI support is needed - this is the firmware, which now (the last 7+ years already) is replacing the BIOS). In general, in most cases should work.

On a USB drive we will install Windows 10.

If you are not sure to choose a USB flash drive or an external USB HDD/SSD drive, then I recommend an HDD/SSD drive. In my opinion, the speed of the flash drive is not enough, although I did not check it - I simply do not have a flash drive of sufficient size. An HDD is suitable, although it would be better with an SSD. USB 2.0 will do, although USB 3.0 is also better. In this manual I use HDD from an old laptop placed in a SATA-USB 2.0 adapter. The system boots more slowly than with an SSD inside a computer, but the speed of the disk almost does not affect the subsequent work - everything is quite comfortable, just like on a regular computer with an HDD.

If you try to install Windows on USB, the system will inform you that USB drives are not supported. At the same time, there are no obstacles for booting an already installed system from a USB disk. Therefore, we will use one interesting loophole. In VirtualBox, a USB flash drive or USB drive can be connected in such a way that for a virtual computer it would seem like a regular SATA drive. In this state, we will install Windows 10. And then it will be possible to boot from this USB disk as from the most ordinary disk on a real (physical) computer.

So, we will do the installation in VirtualBox and this gives another advantage: we can’t do any harm to the host system (your real computer). That is, we cannot wipe disks accidentally during installation and do not break things in another way. By the way, if you use a regular SATA disk via a USB adapter, then this disk can be removed from the USB adapter and connected to the desktop computer as a usual system disk. That is, we install it in a virtual machine - we use it everywhere.

I will show how to install Windows 10 on a USB drive from Windows and Linux. The principle is the same in both these operating systems, but the commands differ slightly due to the specifics of the OSes. Yes, we will need the command line, since the VirtualBox feature we will use is advanced and its mention in the graphical interface is completely absent.

How to install Windows on a USB drive from Windows

We need to find out the system number of the USB drive on which we will do the installation.

Plug the USB flash drive or HDD/SSD drive to the computer.

Then press Win+r and execute diskmgmt.msc.

Find your USB flash drive and remember the disk number:

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

Close all VirtualBox windows if they are open.

Next, we need to open a command prompt as administrator. To do this, press Win+x and select “Windows PowerShell (Admin)”.

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

cd $Env:programfiles\Oracle\VirtualBox

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

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

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

For example, it is the second disk in my OS, 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.

Note that you can replace C:\ usb.vmdk with any file location you want.

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

Now open VirtualBox as administrator - this is a must, otherwise it will not work as it should. To do this, click the Start button, type in “VirtualBox” and select “Run as administrator”:

VirtualBox can only access raw disk devices with administrator privileges.

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

Click “Add”:

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

Choose it:

Press “Create” button:

After creating a virtual machine, if you want to install Windows 10, open its Settings, go to the SystemMotherboard tab and tick Enable EFI (special OSes only):

Start your virtual machine, select the bootable ISO image with the Windows 10 system and start the normal installation.

Now I will show you how to do the same actions in Linux, and then we will return to installing and running a portable USB disk with Windows on a real computer. If you are not using Linux, just skip the next section.

How to install Windows on a USB disk from Linux

To understand the principle, read the previous section on Windows.

To do without root rights in Linux, you need to add the user (yourself) to the “disk” group:

sudo usermod -a -G disk $USER

Then reboot.

If you do not add yourself to the “disk” group, then you will need to run VirtualBox as root or with sudo, otherwise you will encounter an error:

VD: error VERR_ACCESS_DENIED opening image file '/home/mial/VirtualBox VMs/usb.vmdk' (VERR_ACCESS_DENIED).

On Linux, to find out the name of the USB drive, run the command:

sudo fdisk -l

In my case, the disk name is /dev/sdb.

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

VBoxManage internalcommands createrawvmdk -filename '~/VirtualBox VMs/usb.vmdk' -rawdisk /dev/sdX

Where, instead of X, write the letter of the corresponding drive. An example for my conditions:

sudo VBoxManage internalcommands createrawvmdk -filename '~/VirtualBox VMs/usb.vmdk' -rawdisk /dev/sdb

In this command, you can replace '~/VirtualBox VMs/usb.vmdk' with a different location of your choice.

Everything else – creating a virtual machine and choosing an existing virtual disk as a hard disk – just like in Windows.

Note that the usb.vmdk file is a simple text file that you can move to any location and even edit.

Instead of a name like /dev/sdX, you can use a by-id based persistent name, for example:

VBoxManage internalcommands createrawvmdk -filename flash.vmdk -rawdisk '/dev/disk/by-id/usb-Samsung_Flash_Drive_0325121050019952-0:0'

This will allow you to avoid an unavailable disk error if its name changes. See the article “Persistent names for block devices” for details.

How to install Windows on a USB drive

I found an external HDD USB drive and will do the installation on it (and not on the USB flash drive, which is in the screenshots).

When starting the virtual machine, select the installation ISO image of Windows.

At the very beginning, press any button to boot from CD/DVD.

Next comes the usual installation process.

When you come to the choice of type of installation, click on ‘Custom’:

The next step is disk partitioning. You may have a blank disk or, like me, it may already have something installed:

For example, I have a test system there that I don’t need. Then I delete all sections. It turned out like this:

You can, at your request, somehow mark the disk in a special way. If you want to leave the entire disk under the Windows operating system, then simply click the Next button and the system will create 4 or 5 partitions for it during the installation.

Then again, as with the most usual installation, wait for the files to be copied and perform the initial setup.

As with the installation on a regular computer, the system will reboot several times - no action is required from you. Installation is complete (the system is not full screen, as it is running in VirtualBox, and I did not install the VirtualBox guest additions):

How to run Windows from a USB drive

Check in the EFI (BIOS) settings that the Security Boot and Fast Boot are disabled. Then select USB drive as the first download source. Or at the very beginning of the boot you can hold down the ESC key (on your motherboard model there may be another key, for example, Delete or some of the function keys, for example, F12, F9, etc.).

Wait for the download options to appear. As I said, my disk is connected via a SATA-USB adapter, the system sees it as a Mass Storage Device):

Windows booted from the usual disk:

You can enlarge the photo and see that the system sees only its own disk on which it is installed. This is an external USB drive at about 750 gigabytes. The system does not see other disks of the laptop, since they have the ext4 and ext2 file systems.

The first download may take longer than usual, on the screen may appear the words “Devices are being prepared” - the system saw new devices and is configured to work with them. You may need to install the necessary drivers - everything is like on a regular Windows computer.

Why Windows does not boot from USB

In Windows, there are no artificial restrictions on booting from USB (although there are restrictions on installation). Therefore, if the system does not boot, then it is most likely due to the features of your BIOS or its settings. For example, it may be that your computer does not have EFI support, or the Security Boot and Fast Boot are enabled.

Also try using other USB sockets. Strictly avoid USB hubs!

How to Boot into VirtualBox from USB on Windows

We prepared our portable USB disk with Windows for booting on the physical computer, the laptop. But nothing prevents us from booting from it in VirtualBox. If you have already taken steps to connect USB to VirtualBox as a normal disk and created a virtual machine with the appropriate settings, then just plug your USB with Windows and your system will boot from USB!

Plug a USB flash drive or disk to your computer.

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

Please note that the USB device must be the first hard drive in your VirtualBox virtual machine, otherwise it will not boot. If you are connecting a new USB disk to an existing machine, then try changing the order of the media in the settings of this machine, or select the appropriate disk at the beginning of the boot.

Buy SATA-USB adapter online

If you like this guide and you need an external USB drive, an external USB SSD drive, a SATA-USB adapter or a USB flash drive with a very large amount of memory and at the same time you love online shopping, then look at the links below, you might find something appropriate:

By the way, in the next guide we will install Linux on a USB flash drive or USB HDD drive. There are pitfalls, so do not miss!

In this post I will tell you how to connect a USB disk (or USB flash drive) to a virtual machine so that the guest system treats it like a regular hard disk.

This trick will allow you not only to boot from the installation USB – which is rather pointless. If you connect a USB disk or flash drive to the guest system as a regular disk, you can do such interesting things as:

  • boot from physical SATA disk via USB adapter
  • install Windows on a USB disk or flash drive

If you do not have the ability to connect a SATA disk 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: plug the SATA disk to the computer via a USB adapter, and then connect the USB disk to the virtual machine as a regular disk, as shown in this guide.

Regarding the second point – installing Windows on a USB drive – if you want to install Linux on a USB flash drive (not to write a Live image, but to install a full-fledged system), then you do not have to do the trick shown here to install it – since Linux is perfectly installed on a portable media. But in Windows there is a prohibition for installation on USB disks and flash drives.

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

Recommended for you:

Leave a Reply

Your email address will not be published. Required fields are marked *