Converting FileSystem To NTFS

by Jul 20, 2009

When you buy a new external USB drive, most of the time it is preformatted with the old FAT32 file system for compatibility reasons. You could reformat it with NTFS to enjoy more performance and better reliability but this will delete any data already stored on the drive.

You probably know about the convert.exe utility which can convert a file system to NTFS without data loss. This tool cannot be run automatically though because it wants a manual confirmation and asks for the drive label of the drive you want to convert.

Here is an example how PowerShell can embrace convert.exe and turn it into a more sophisticated tool that converts drives without manual confirmation. Of course, this imposes risk because converting a filesystem cannot be undone.

function ConvertTo-NTFS($letter='C:') {
if (!(Test-Path $letter)) {
Throw "Drive $letter does not exist."
}

$drive = [wmi]"Win32_LogicalDisk='$letter'"
$label = $drive.VolumeName
$filesystem = $drive.FileSystem

if ($filesystem -eq 'NTFS') {
Throw "Drive already uses NTFS filesystem"
}
"Label is $label"
$label |
convert.exe $letter /FS:NTFS /X
}

Make sure the drive you want to convert is not in use or else the conversion may be scheduled to take place at next reboot.