Flash drives are one of the most commonly used devices nowadays. You use them in the form of pen drives and SD (and microSD) cards. The ease of use and portability of these devices makes them indispensable for every person who uses computers. However, these devices may also give you nightmares if you tinker with them without being cautious. Some of the most common problems faced by flash drive users are : 1) Flash drive suddenly becomes “read-only” and 2) “Unallocated” space on a flash drive. Here, we shall discuss how to recover unallocated space on a flash drive using diskpart.
Recover unallocated space
Yesterday, I was trying to create a bootable USB drive (Ubuntu 14.04) using my 4 GB (3.68 GB) Sandisk pen drive. I was using PowerISO for this purpose.
However, it didn’t actually make the pen drive bootable. Rather, it messed up my pen drive badly. You can see what happened to my pen drive in the image below.
As you can see in the image above, my pen drive is showing 16.0 KB free of 2.25 MB, which is ridiculous because it is 3.68 pen drive and even after storing all the files contained in the Ubuntu 14.04 disk image, it would still have around 2.5 GB of blank space. On top of it, the pen drive contains only 2.24 MB of data (which means the data contained in the .iso file has not been written to the drive). Apparently, PowerISO isn’t suitable for creating a bootable USB drive for Ubuntu. However, my pen drive appears to have been ruined and that’s all I care about.
Now, I thought I could fix the problem (whatever it was) using the Disk Management utility (diskmgmt.msc). But what appeared in the Disk Management window was more annoying.
As you can see in the image above, there are three blocks in the Disk 1 i.e. my pen drive. The first block represents 949 MB of unallocated space (the space that was supposed to hold the contents of the Ubuntu 14.04 image file). Next to it is a 2 MB partition followed by another block of unallocated space (2.77 GB). You might be tempted to think that fixing the unallocated space problem would be as easy as right-clicking the blocks and choosing some option from the menu that would fix everything. It isn’t that easy. :'(
To fix the problem, I had to use the diskpart utility (diskpart.exe). The process was quite simple. The steps required to recover unallocated space are listed below :
<1> Start the Command Prompt with Administrator privileges
<2> Type diskpart and press ENTER
<3> Type list disk and press ENTER
<4> Type select disk 1 and press ENTER
<5> Type clean and press ENTER
<6> Type create partition primary and press ENTER
<7> Type exit and press ENTER
<8> Format the pen drive using the Disk Management utility
<9> DONE !!!
As you can in the images above, the unallocated space on the pen drive has been recovered. The above process also applies to hard disks (in case you face similar problems). If you need to recover unallocated space on your usb flash drive (pen drive or SD/microSD card) and the above process doesn’t help you, let me know.