Friday, April 26, 2013

NTFS drive formatted by Linux missing a drive letter in Windows.

With Windows 7 having long proven itself a stable and family-friendly OS, I decided to simplify my life, ditch Ubuntu Linux on the desktop after nearly 10 years and go back to Windows.  I had a couple of external hard drives that I'd used GParted to partition and format to NTFS for cross-platform compatibility.  Or so I thought.

I copied several gigabytes of data to one of these NTFS-formatted USB drives, blew away Ubuntu and installed Windows 7 Home Premium SP1 with all the current patches. When I reattached the USB drive, Windows recognized the hardware and it showed Online in Disk Management but a drive letter was not assigned and all options to assign one were grayed out. I could not open or access any data on the drive. A minor panic ensued.

I downloaded VMware Player and a Ubuntu LiveCD. Booted it, attached the drive and Linux could still read it. Whew! I tried to transfer the data via the network from the Linux VM to the Windows host but it gave me fits.  I needed to get the drive mounted in Windows.

Long story short, I discovered that GParted had formatted the drive as NTFS but left the partition ID as "83" which is "Linux".  This obviously confused the hell out of Windows.  I could verify this using the following Linux command:
sudo sfdisk --print-id /dev/sda 1
The output shows me the partition ID of /dev/sda1:
I needed to change the partition ID to "07" which is NTFS (and some relatives).  To do this, I made sure the drive was unmounted and issued the following Linux command:
sudo sfdisk --change-id /dev/sda 1 07
This changes the ID of /dev/sda1 from 83 to 07.  Output:
I disconnected the drive from the VM and....Voila! The drive now mounts successfully, drive letter and all, in Windows.