Windows 7 command line USB partitions
Mar.19, 2010, under Sysadmin
There is a very annoying issue in Windows, in that it doesn’t let you have more than one partition on a USB drive. There was a workaround for this in XP, but I haven’t been able to get it working in the newer versions. In addition if you have a multi partition USB device and try to use Windows to format it via disk management, you will run into more difficulties where it can only manage the first partition. I can’t help with the first problem, but here is how you solve the second.
Bear in mind that this will delete all data on the drive, so make sure to back it up first!
We are going to use a handy commandline tool called diskpart to go through and delete the partitions on the disk one by one. Once this is done you can format the disk as normal (but only as one big partition). Here is an example where I delete two partitions on a USB disk.
C:\Windows\system32>diskpart Microsoft DiskPart version 6.1.7600 Copyright (C) 1999-2008 Microsoft Corporation. On computer: WORKSTATION DISKPART> list disk Disk ### Status Size Free Dyn Gpt -------- ------------- ------- ------- --- --- Disk 0 Online 465 GB 0 B Disk 1 Online 14 GB 1500 MB DISKPART> select disk 1 Disk 1 is now the selected disk. DISKPART> list partition Partition ### Type Size Offset ------------- ---------------- ------- ------- Partition 1 Primary 1501 MB 31 KB Partition 0 Primary 11 GB 3002 MB DISKPART> select partition 1 Partition 1 is now the selected partition. DISKPART> delete partition DiskPart successfully deleted the selected partition. DISKPART> list partition Partition ### Type Size Offset ------------- ---------------- ------- ------- Partition 1 Primary 11 GB 3002 MB DISKPART> select partition 1 Partition 1 is now the selected partition. DISKPART> delete partition DiskPart successfully deleted the selected partition.
At this point I format the partition in disk management. Going back to diskpart we can see that the new partition is recognised and is the correct size. Note that the sizes don’t add up as there was unallocated space on the disk which has been included in the new partition.
DISKPART> list partition Partition ### Type Size Offset ------------- ---------------- ------- ------- * Partition 1 Primary 14 GB 0 B DISKPART>