Create Bootable USB Flash Drive With DiskPart Command-Line Utility

6:44 am Windows

The instructions below will create a bootable system partition on a USB flash drive, which is exactly the same as creating such a partition on a hard drive. Specifically, I will be using Windows 7’s built-in DiskPart (Disk Partition) command-line utility to create a bootable USB flash drive containing a Windows 8.1 Setup image.

diskpart_usbIf you are interested, here’s the technical reason why our bootable USB flash drive will use the MBR layout and FAT32 format: Computers, including both Windows and Macs, boot using a standard called UEFI (Unified Extensible Firmware Interface), which is based upon the EFI specification (Extensible Firmware Interface). (When folks say EFI, they are usually referring to UEFI because all modern computers use UEFI.) UEFI is a replacement for the previous BIOS method of booting up, but UEFI still supports the older BIOS method. The BIOS boot method uses the MBR (Master Boot Record) layout. In addition to BIOS+MBR, UEFI also supports the new GPT (GUID Partition Table) layout. The UEFI specification requires bootable removable media (such as a bootable USB flash drive) to use the MBR layout and FAT32 format.

To create a bootable USB flash drive, do the following:

  1. Insert a USB flash drive with sufficient capacity. (The 64-bit Windows 8.1 Professional ISO image I had is 4.5GB in size and requires at least an 8GB USB flash drive).
  2. Launch the “diskpart” or “diskpart.exe” utility from the Windows Start/Run menu or the Command Prompt. You will be prompted with a popup message asking “Do you want to allow the following program to make changes to this computer?” Answer Yes.
  3. Run the following commands in the DiskPart utility (ignore the comment lines marked by the pound # character):
    # Show all disks (aka drives, like hard drives or removable media).
    DISKPART> list disk
    # Select a disk to operate on.
    DISKPART> select disk [number identifying USB flash drive]
    # Delete all partitions, resulting in a blank disk.
    DISKPART> clean
    # Create a primary partition (using MBR).
    DISKPART> create partition primary

    # Show all partitions (should just be the one newly-created partition).
    DISKPART> list partition

    # Select the primary partition to operate on (only 1 partition exists).
    DISKPART> select partition 1
    # Make that primary partition active (aka bootable).
    DISKPART> active
    # Format the active primary partition using FAT32.
    # To do a full format, instead of a quick format, omit the "quick" flag.
    DISKPART> format fs=fat32 quick
    # Assign a drive letter to the primary partition
    # (just in case Windows didn't already do it).
    DISKPART> assign

    # Quit DiskPart.
    DISKPART> exit
  4. Test by opening the contents of USB flash drive using Windows Explorer. If you get an inaccessible error when accessing the drive, unplug and re-plug it back into the computer. You should then be able to access it.
  5. Insert the Windows Setup DVD or mount the Windows Setup ISO file (I recommend using the free Slysoft Virtual CloneDrive utility to perform the ISO mount).
  6. Copy all the Windows Setup content to the USB flash drive by running the xcopy command from the Command Prompt:
    # Supposing USB flash drive is K: drive and Windows is L: drive,
    # copy all files and directories from the latter to the former.
    # /e = Copies directories and sub-directories, including empty ones.
    # /f = Displays full source and destination file names while copying.
    xcopy L:*.* /e/f K:

And we are done. The resulting USB flash drive should be bootable on both Windows and Macs. I tested the USB flash drive on my Macbook Pro Retina and it booted fine.

Info above derived from Install Windows 7 From a USB Flash Drive.

Leave a Comment

Your comment

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.