Hardware

Configure a USB flash drive for Windows 7 installation: Revisited

Using a USB Flash drive as a Windows 7 installation platform is a great idea, but when Greg Shultz proposed it, there were some questions raised.

In my August 18th blog post, "Configure a USB Flash Drive to Be a Windows 7 Installation Platform," I showed you how to use the DiskPart utility to configure a bootable USB flash drive that you can then use to install the Microsoft Windows 7 operating system.

As I mentioned in that blog post, this technique is very cool for two reasons: First, a flash drive is much more responsive than an optical drive, since it doesn't rely on physically moving components, so the installation procedure will be faster. Second, it provides an easy way to install Microsoft Windows 7 on a system that doesn't have a DVD drive, such as a netbook.

In the Discussion Thread stemming from that blog post, I was asked several questions that prompted me to revisit this technique.

  • First, h3driver asked if the preparation phase of the technique could be done from the GUI Disk Management Console rather than from the Command Prompt with the DiskPart command.
  • Second, odedszpiro asked me why I chose to use FAT32 as opposed to NTFS to format the USB flash drive.
  • Third, inertman echoed the question about using the Disk Management Console but also asked why I didn't use the new exFAT file system to format the USB flash drive. I've also heard from some folks who have been asking about solutions to problems with the DiskPart command. To all, I say great questions!

In this edition of the Windows Vista and Windows 7 Report, I'll explore these question and answers in more detail.

This blog post is also available in PDF format in a free TechRepublic download.

Disk Management Console

Conceivably, the idea of using Vista's Disk Management Console makes sense -- you could just point and click to prepare the USB flash drive. However, that doesn't seem to be the case.

In fact, every piece of documentation from Microsoft that I have seen about formatting a bootable USB flash drive specifically describes the procedure using the Vista DiskPart command. Microsoft even describes the DiskPart command as enabling a superset of the actions that are supported by the Disk Management snap-in. As such, it may not be possible.

In experimenting with this, I have not been able to successfully prepare a bootable USB flash drive from the Disk Management Console. Something always seems to go wrong. However, using the DiskPart command with its very specific command structure, I have always been able to prepare a bootable USB flash drive. Since I know using the DiskPart command works, that is the procedure I described in my article.

Now, that being said, I'm open to the possibility that I may be wrong about the Disk Management Console and would ask that anyone who has been able to successfully prepare a bootable USB flash drive from the Disk Management Console, please let us know how you went about it.

FAT32 vs. NTFS

When it comes to choosing between FAT32 and NTFS when formatting USB flash drives, I think that FAT32 is the best way to go. The reason that FAT32 is better in this situation is that people tend to pull USB flash drives out of the port when they are finished using them rather than using the Safely Remove Hardware method and FAT32 is more forgiving of this type of termination than NTFS is. If you yank out an NTFS drive that has not yet completed working with the files on the USB flash drive, you could very well end up with corrupted data.

Another reason against using NTFS for USB flash drives is that NTFS is a more feature-rich file system and as such has more overhead, making it perform a bit slower on USB flash drives than FAT32.

However, as long as you take these drawbacks into consideration, there is no reason that you can't use NTFS to format a bootable USB flash drive to use as a Windows 7 installation platform.

FAT32 vs. exFAT

When it comes to choosing between FAT32 and exFAT when formatting a bootable USB flash drive, you have to use FAT32. At this point in time, exFAT for Windows XP/Vista/7 does not support booting from the file system.

As you may know, with Vista SP1, Microsoft added the exFAT file system to the operating system and then shortly afterward released an exFAT patch for Windows XP. As the successor to the FAT32 file system, exFAT is designed for Windows Embedded CE 6.0 to allow it to support larger drives and file sizes than FAT32, which was released with Windows 95 OSR2 -- back when today's standard hard disk and file sizes were unfathomable. (Windows CE devices can boot from exFAT drives using a special boot loader in the BIOS.)

When Microsoft ported exFAT over to Vista, the idea was to improve support for flash-based media by allowing the operating system to be able to support larger-sized drives and larger file sizes.

More specifically, Microsoft describes the exFAT system as offering the following advantages:

  • Enables the file system to handle media capacity of 32GB and larger.
  • Handles more than 1,000 files in a single directory.
  • Speeds up storage allocation processes.
  • Removes the previous file-size limit of 4GB.
  • Supports interoperability with future desktop operating systems.

Therefore, if you have a large USB flash drive that you are going to be using for data transfer and storage, using exFAT instead of FAT32 would be a good way improve performance and to take advantage of a new technology, but not if you are using the USB flash drive as a bootable device.

DiskPart problems/solutions

To set the stage for this section, let me begin by listing the set of DiskPart commands that you will use to prepare the USB flash drive:

  1. DiskPart
  2. List Disk
  3. Select Disk #
  4. Clean
  5. Create Partition Primary
  6. Active
  7. Format fs=FAT32 quick
  8. Assign

I've heard from a number of folks who have been following the set of instructions for using the DiskPart command and gotten to the Create Partition Primary command and encountered the error message:

There is insufficient free space to create a partition at the specified size and offset. Specify different size and offset values or don't specify either to create the maximum sized partition.

While the first part of this error message is on target, the second part tends to lead you off in another direction. The reason that there is insufficient free space to create a partition is that the existing partition is still there because, for some reason or another, the Clean command did not do its job. So, the solution to this error is to simply type the Clean command again. If that still doesn't work, try the Clean All command. Once you do, you can then type the Create Partition Primary command again.

I've also heard from several folks that after creating the primary partition, attempting to issue the next command brought up the error message:

There is no partition selected. Please select a partition and try again.

In this case, the solution appears to be adding the Select Partition 1 command to the list of steps. Since the partition was just created, we know that it is partition 1. As such, the set of DiskPart commands becomes:

  1. DiskPart
  2. List Disk
  3. Select Disk #
  4. Clean
  5. Create Partition Primary
  6. Select Partition 1
  7. Active
  8. Format fs=FAT32 quick
  9. Assign

Not XP

In my original version of the article, I failed to mention that you must use the DiskPart command in Windows Vista or Windows 7 in order to perform the operation. The DiskPart command in XP cannot be used to set up a partition on the USB drive. While I did add this correction the article within 24 hours of it being published thanks to peter.j.boyles, I just thought I would reiterate it here.

A DiskPart script

Several of you responded to my inquiry in the discussion area, and as such, I am working on a DiskPart script to automate the procedure of configuring a USB flash drive to be a Windows 7 installation platform. Stay tuned.

What's your take?

If you have any questions or comments concerning this topic, please take a moment to drop by the TechRepublic Community Forums and let us hear from you

TechRepublic's Windows Vista and Windows 7 Report newsletter, delivered every Friday, offers tips, news, and scuttlebutt on Vista and Windows 7, including a look at new features in the latest version of the Windows OS. Automatically sign up today!

About

Greg Shultz is a freelance Technical Writer. Previously, he has worked as Documentation Specialist in the software industry, a Technical Support Specialist in educational industry, and a Technical Journalist in the computer publishing industry.

24 comments
Pretty Funked Up
Pretty Funked Up

Fix for...

There is insufficient free space to create a partition at the specified size and offset. Specify different size and offset values or don't specify either to create the maximum sized partition.

Before you begin insert the stick and goto disk management console. remove the letter assigned to the stick.

Remove the stick, close windows and start procedure from the beginning again.

jds48
jds48

From what I see on the net you need a way for DiskPart to first "See" the flash drive before you can do anything. I've not found a way to address this. Apparently there is a new "removable" bit set on flash drives. My Win7 Pro diskpart sees the partition as type removable but does not list the drive its on. I suspect many will have this same issue.

JLuke24
JLuke24

First create script below, call it what ever... ---Start--- @ECHO OFF rem ========================================== :MAIN TITLE MAIN MENU cls mode con: cols=86 lines=15 @echo. @echo. @echo. @echo (D)iskpart USB Drive - Set USB FLASH DRIVE bootable (FAT32) @echo (E)xit @echo. Set /P letter="Enter the letter in parenthesis above: " if /I %letter%== D goto diskpart32 if /I %letter%== E goto END goto MAIN rem ============================================ :DISKPART32 TITLE DISKPART FAT32 cls start /wait DISKPART /s D:\command\fat32.txt goto END :END exit ---END---- Next, create a text document, in this case FAT32.txt and place the following inside: ---Start--- select disk 1 clean create partition primary select partition 1 active format fs=FAT32 assign exit ---end--- There you have it...scripted DISKPART, assuming Disk 1 is your USB drive. You can check by doing DISKPART > LIST DISK Enjoy everyone JL

steve6375
steve6375

If you are using XP then this won't work, as stated above. Download release version of RMPrepUSB 1.9.75 from http://www.boot-land.net/forums/index.php?showtopic=7739 (or latest Beta from the last post in this thread). This will wipe, partition and format and make WinPE v2 bootable any USB drive and you can tick a box to copy the Install DVD contents to the USB drive too. One click on the Prepare button and it's done!

steve6375
steve6375

DiskPart scripts are VERY unreliable. Diskpart often does not do what you tell it and the command fails. Try scripting and put it in a loop. It will fail every so often. I think the OS puts a 'lock' on the drive at intervals and it you happen to try to run diskpart at that same time it will fail. Diskpart really needs a 'retry' option built in as the error handling is really clumsy. You can detect a fail but it is difficult to know where it failed. I ALWAYS repeat any DISKPART script at least twice if it starts with a CLEAN or FORMAT. I have learnt the hard way!

EdGallagherMVP
EdGallagherMVP

FAT32 is less forgiving than NTFS for disconnection during disk writes. FAT32 uses 2 copies of the File Allocation Table, originally to provide redundancy for the file system structure within the partition. The problem with having only 2 copies is that if one is damaged, how do you know which one has the correct information? NTFS uses a transactional file system involving the Master File Table that finishes changes to the disk before a "commit" of those changes is issued, making the already written changes to the drive "active". This allows a roll back to the previous state of the file system before the uncommitted file transactions occured.

MeadowsPV
MeadowsPV

All tasks were performed in Windows XP Pro and Boot to USB verified on a Dell Precision 650. This works for either Vista Bootable USB install or Win7 Bootable Install - You still have to have valid OS keys ====================== FORMAT USB FLASH DRIVE TO NTFS ====================== Microsoft Windows XP [Version 5.1.2600] (C) Copyright 1985-2001 Microsoft Corp. C:\Documents and Settings\User>format /? Formats a disk for use with Windows XP. FORMAT volume [/FS:file-system] [/V:label] [/Q] [/A:size] [/C] [/X] FORMAT volume [/V:label] [/Q] [/F:size] FORMAT volume [/V:label] [/Q] [/T:tracks /N:sectors] FORMAT volume [/V:label] [/Q] FORMAT volume [/Q] volume Specifies the drive letter (followed by a colon), mount point, or volume name. /FS:filesystem Specifies the type of the file system (FAT, FAT32, or NTFS). /V:label Specifies the volume label. /Q Performs a quick format. /C NTFS only: Files created on the new volume will be compressed by default. /X Forces the volume to dismount first if necessary. All opened handles to the volume would no longer be valid. /A:size Overrides the default allocation unit size. Default settings are strongly recommended for general use. NTFS supports 512, 1024, 2048, 4096, 8192, 16K, 32K, 64K. FAT supports 512, 1024, 2048, 4096, 8192, 16K, 32K, 64K, (128K, 256K for sector size > 512 bytes). FAT32 supports 512, 1024, 2048, 4096, 8192, 16K, 32K, 64K, (128K, 256K for sector size > 512 bytes). Note that the FAT and FAT32 files systems impose the following restrictions on the number of clusters on a volume: FAT: Number of clusters format F: /fs:ntfs Insert new disk for drive F: and press ENTER when ready... NTFS file system is not supported on this device optimized for removal. To change the way this device is optimized, select the Policies tab in the device's property sheet. = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = [ Go to the Device Manager ( Start -> Run C:\WINDOWS\system32\devmgmt.msc ) 1: Select the USB Drive in the list 2: Double-Left Mouse Click to open " USB Flash Memory USB Flash Device Properties" 3: Select the Policies tab 4: Select the 'radio button' - Optomise for performance [ Note that you must software eject the device before physical device removal ] 5: Select the OK button and close the Device Manager. = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = [ Now format the Flash Drive to NTFS as shown below ] C:\Documents and Settings\User>format F: /fs:ntfs Insert new disk for drive F: and press ENTER when ready... The type of the file system is FAT32. The new file system is NTFS. Verifying 3820M Volume label (ENTER for none)? vista Creating file system structures. Format complete. 3911792 KB total disk space. 3889848 KB are available. C:\Documents and Settings\User>format F: /fs:NTFS Insert new disk for drive F: and press ENTER when ready... The type of the file system is NTFS. Verifying 3820M Volume label (ENTER for none)? VISTA [ [ or Win7 ] ] Creating file system structures. Format complete. 3911792 KB total disk space. 3889848 KB are available. C:\Documents and Settings\User> ================================================ [Bootsect.exe updates the master boot code for hard disk partitions in order to switch between BOOTMGR and NTLDR. You can use this tool to restore the boot sector on your computer.] F:\boot\bootsect.exe /nt60 H: [I just used the folder path of my extracted Vista ISO as shown below] C:\Documents and Settings\User>"M:\Vista Ultimate x86\Vista.x86\BOOT\BOOTSECT.EXE" bootsect {/help|/nt60|/nt52} {SYS|ALL|:} [/force] Boot sector restoration tool Bootsect.exe updates the master boot code for hard disk partitions in order to switch between BOOTMGR and NTLDR. You can use this tool to restore the boot sector on your computer. Run "bootsect /help" for detailed usage instructions. - - - - - - - - - - - - - - - - - - [Results should look like the following] C:\Documents and Settings\User>M:\Vista Ultimate x86\Vista.x86\BOOT\BOOTSECT.EXE" /nt60 f: Target volumes will be updated with BOOTMGR compatible bootcode. F: (\\?\Volume{75a194b7-89ef-11de-9c47-000d5698d782}) Successfully updated NTFS filesystem bootcode. Bootcode was successfully updated on all targeted volumes. C:\Documents and Settings\User> - - - - - - - - - - - - - - - - - - Copy the Extracted files from the ISO image to the USB Flash drive Software eject the USB Flash drive. The Now bootable install for Vista is available for use. - - - - - - - - - - - - - - - - - -

goodpurb
goodpurb

Can you use diskpart in Windows 7 RC to prepare the flash disk? Harry

keithsheard
keithsheard

From this excellent guide I use the bootable flash drive to restore Windows Home Server Backup to a netbook. It took awhile to get the drivers organised correctly.

Mark W. Kaelin
Mark W. Kaelin

Have you tried to install Windows 7 from a USB flash drive as described by Greg's original post? How did it work?

steve6375
steve6375

On systems with SATA disks when booting under WinPE v2 or V3, the disk numbering can be random. Disk 1 is not always the same disk each time you boot! If you have two SATA disks trying booting to Vista 10 times and looking at their numbering in Disk Manager (or diskpart). So doing a CLEAN on disk 1 may have unexpected results! Not all systems seem to be affected but many Intel systems/BIOSes are, setting HDD mode to Legacy or Native can change the behaviour. This is a known issue in WinPE and is why in WinPE v3 MS introduced the SELECT DISK SYSTEM and SELECT DISK NEXT commands.

phased.nio
phased.nio

Actually all I did for XP was "bootsect /nt52 (drive letter)" using the Win7 Source. Worked great.

Jacky Howe
Jacky Howe

syntax at the end of the .cmd file. It should let you know if a problem has occured. I've been using W7 and I have tried several times on different USB drives to get an error message. I haven't had any problems so far. I've even had the drive open in explorer when running the batch. Contents of USBdrv.txt sel dis 1 cle cre par pri for FS=Fat32 quick act ass Command to run the .cmd which is placed in the root directory. diskpart /s c:\USBdrv.txt pause Output with a pause to check for errors: C:\>diskpart /s c:\USBdrv.txt Microsoft DiskPart version 6.1.7100 Copyright (C) 1999-2008 Microsoft Corporation. On computer: W7RC Disk 1 is now the selected disk. DiskPart succeeded in cleaning the disk. DiskPart succeeded in creating the specified partition. 100 percent completed DiskPart successfully formatted the volume. DiskPart marked the current partition as active. DiskPart successfully assigned the drive letter or mount point. C:\>pause Press any key to continue . . . I notice that if you run the command a couple of times on the same disk that "assign" will keep incrementing the drive letters before going back to the original. If you don't use the assign syntax it will allocate the original drive letter when you select Computer.

bsculley
bsculley

Further to the discussion of using NTFS on a USB Flash Drive, I have been unable to successfully format a 64GB flash drive to NTFS using Vista. THe format always fails. I can format the device to FAT32 and exFAT, but not NTFS. I have used all available utilities to attempt this. The error is always vague and uninformative: "Format failed". Anybody know how to do this? please let me know.

steve6375
steve6375

I though NTFS uses file journalling - every access to any file means a USB write occurs. This means rapid wear of USB devices as Flash memory only has a finite number of read-erase-write cycles before it wears out?

keithsheard
keithsheard

Yes Windows7 function works well the same I guess as Vista.

MeadowsPV
MeadowsPV

Short answer = yes. look at my other post. Works with either ISO - Vista or Win7. Regards.

bb05056
bb05056

Followed Greg's instructions to the letter and successfully installed 32 & 64 bit Win 7 RC versions on 2 notebooks, a Dell Inspiron and an Advent. Installation process was exactly like CD/DVD only quicker. Prior to installing, I also copied my usual software installation files on to the USB stick(Adobe Reader, Anti Virus, etc), saved time on downloading and CD changes.

heindelb
heindelb

Just download Unetbootin and point it to the iso. Works great

Arcboss
Arcboss

I have an installation flash drive for win 7 using Fat 32 and an installation drive for XP Pro using NTFS. Both will autorun in Vista and both will boot in Vista and XP. I have used Boot IT! for the drives (both are Lexars) to flip the removable media bit. (Both drives worked the same before and after the flip, but now show up as fixed drives). The Utility does not work on SanDisk.

Greg Shultz
Greg Shultz

...a different flash drive? While I recommend using FAT32, NTFS should work fine...

filker0
filker0

There are cases where a network install is not possible, or at least desired. I have a policy at home that when installing any OS that automatically connects to the network, I unplug it from the network until the OS is installed, proper IP settings are configured, and an anti-virus is set up and configured. You don't have to use USB or any other locally mounted media for installation, and it's good to have the Unetbootin option (along with others), but don't criticize others for persuing other options.

iravgupta
iravgupta

Why go through all these hassles when unetbootin can handle everything for you, sounds highly inefficient. But then, Greg Shultz posts have mostlybeen about working with whats there in the OS by default and not 3rd party code. I respect and value his perspective, but in this case, it is just the case of pushing it too far.

Editor's Picks