Skip to content

Instantly share code, notes, and snippets.

@redxef
Last active September 10, 2017 17:26
Show Gist options
  • Save redxef/756a64ae35234b15f47c15fdfc89d5c3 to your computer and use it in GitHub Desktop.
Save redxef/756a64ae35234b15f47c15fdfc89d5c3 to your computer and use it in GitHub Desktop.
This document contains instructions on how to install windows on an external drive, when no other windows version is available. This document is not complete and may contain errors.

HOWTO install Windows 7/8/10 on external drive:

Requirements:

  1. VirtualBox https://www.virtualbox.org/wiki/Downloads
  2. A destination Drive/USB-Stick/wherever you want to intall windows on
  3. The Windows iso image https://www.microsoft.com/de-de/software-download/

Steps

  1. Boot into Windows:
  • Install VirtualBox (take care to also install the Extension Pack if you need USB support or other functionality) https://www.virtualbox.org/wiki/Downloads
  • Create a new VirtualBox System (give it enough ram and vram)
  • Attach the downloaded ISO and boot
  • At language selection window press: shift + F10 (maybe you also need to press the fn key) -> this will open an elevated command prompt.
  1. Partition the target device
  2. Open diskpart: diskpart
  3. List all disks and find the correct one: list disk
  4. Select the disk: select disk <your disk number>
  5. Clean the disk: clean
  6. Convert to GPT partition table: convert GPT
  7. Create an EFI partition with 500MiB: create partition efi size=500
  8. Create the OS partition, using all other available space: create partition primary
  9. List all partitons and identify the ids of the EFI and OS partitions: list partition
  10. Select the EFI partition: select partition <efi partnumber>
  11. Format the partition: format fs=fat32
  12. Mount it (note the drive letter): assign
  13. Select the OS partition: select partition <os partnumber>
  14. Format it: format fs=ntfs quick
  15. Mount it: assign
  16. Exit: exit
  17. Install Windows onto the drive: dism /apply-image /imagefile:<ISO mount letter>:\sources\install.wim /index:2 /ApplyDir:<OS part drive letter>:1
  18. Navigate to the directory containing bcdboot.exe: cd path\to\container
  19. Make the disk bootable: bcdboot <OS drive letter>:\Windows /s <EFI drive letter>: /f UEFI2
  20. Profit!

1: Note that the 2 after install.wim stands for the flavor to install, in the Windows 10 ISO this is for Windows HOME. If you are unsure, input a 0 and read through the list provided by imagex. Then rerun the command with the correct number. Also, when booting into the install ISO, the iso drive letter is not the boot drive letter. To get that one run:

  • diskpart
  • list volume

And identify the correct drive letter.

2: This is a install for UEFI bootloades, if you have only a BIOS installed, you can change UEFI to BIOS. If you want both, then use ALL

Creating a Windows install USB-Stick

There are countless other tutorials on how to do this, one of which is to just dd the image onto the USB-Key, while other special cases exist, where macOS users first need to convert the iso to an img and the copy the file to the Key. I found both to be failing me, so I did it manually. The following instructions are written for macOS, if you are under linux, I am assuming, that you are experienced enough to follow the steps without specific code examples. You need dd, gdisk, diskutil, mount and newfs_msdos. All those commands, expect for gdisk are preinstalled under macOS.

  1. Get the device name of the USB you want to make bootable. The most foolproof way of locating the device is by not inserting it into the computer and doing a quick list of connected devices:
    diskutil list
    Now insert the USB-Key and execute the command again, the newly listed device is yours (Remember the location, ex. /dev/sdb or /dev/disk2).
  2. Open the device (you might need sudo):gdisk /dev/disk<devnumber>
  3. delete all partitions1: d
  4. Create a new partition, which is at least as big as the Windows ISO and is an EFI partition: n, <enter>, <enter>, <enter>, ef00
  5. Write out the changes and exit: w, q
  6. Create a EFI filesystem: newfs_msdos -v EFI /dev/disk<devnumber>s<partnumber>2
  7. Mount the Volume: mkdir /Volumes/EFI, mount -t msdos /dev/disk<devnumber>s<partnumber>
  8. Copy the ISO contents to the USB (this might take a while): rsync -r path/to/iso /Volumes/EFI/
  9. Profit, you now should be able to boot the device using UEFI boot loader

1: Typing p prints the layout of the disk.

2: The partition number should be 1.

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