Mr. Script

Build a Better NTFS Converter

Help for working through the steps.

I recently replaced the hard drive in my notebook computer. I just love getting new hardware! My new drive is faster (5,400 RPM as opposed to 4,800), larger by 10GB and quieter. I also doubled my RAM to 1GB.When my new drive arrived, I used a USB 2.0 hard drive upgrade kit to clone my existing drive to my new one. This process was, to coin a phrase, dead sexy! If you ever need to upgrade your notebook hard drive, go this route. It’s a lot easier than re-installing everything on the new drive.

My point in telling this story (and it’s equally valuable to desktop hard drive upgrades, as well) is that I was able to convert my file system to NTFS. You might say, “Well, that’s easy,” and you’d be right. Sure, I could have done it at any time, just by using CONVERT.EXE. But there are issues with converting a file system to NTFS that don’t arise when you format one from scratch. I wanted to work through those issues, and now I had a complete backup of my notebook drive, just in case. If anything went wrong, all I had to do was replace the new drive with the old one and start over. There’s tremendous freedom in having that kind of safety.

NTFS Is Good
Any administrator worth his or her salt can enumerate the benefits of NTFS. First and foremost, it’s secure. This is particularly important on notebook computers. I have documents and spreadsheets on my computer that I’d like to keep secure. With FAT32, all an intruder needs is a DOS boot disk and access to my computer to see everything. NTFS also supports encryption, compression, quotas and more. Finally, when properly tweaked, NTFS is faster.

Converting to NTFS Is Bad
As I said, there are issues that arise when converting to NTFS. Most notable among them is fragmentation of the Master File Table (MFT). The CONVERT utility creates this MFT on the drive during the conversion process. Even if you defrag your hard drive immediately prior to running CONVERT, there’s no guarantee that the MFT will occupy a contiguous area of the drive. Because the MFT is used for every file access operation (indeed, many files are stored in the MFT in their entirety), a fragmented MFT can really affect performance.

In light of these challenges, I created a process to convert a FAT or FAT32 file system to NTFS while circumventing or eliminating most of the pitfalls. And I’ve written a script to automate the entire process. This may not seem like much of a timesaver if you’re just upgrading your own computer, but if those 20 new workstations that just arrived pre-loaded with Windows XP on FAT32 hard drives need NTFS, you have two choices if you want to extract anything resembling acceptable performance and security: Run this script or rebuild them from scratch.

The Process
First, I explain each step in the process and why it’s important. Next, we look at the script. Finally, there’s an additional tweak you can use to squeeze even more performance out of your conversion.

Before we get started, one final point: This conversion method only works on Windows XP/Windows 2003 because the most important step—using a CvtArea—is only supported in the XP/Windows 2003 version of CONVERT.EXE.

1. Reserve an area for the MFT. To prevent the MFT from being created in a fragmented state, we need to set aside an area of contiguous space—referred to by CONVERT.EXE as the CvtArea—on the drive. The size of this file should be at least the total number of files and folders that exist on your drive multiplied by 1,024. (It doesn’t hurt to add some “buffer zone.”) So, if we have 9,000 files and 1,000 folders, the file would be 10,240,000 bytes in size. We use the FSUtil program to create the file.

C:\>fsutil file createnew MFTArea.txt 10240000

Note: This file must be in the root of the C: drive.

2. Ensure that the file is contiguous. SysInternals has a free utility called Contig.exe that will defragment a single file. You can download it at www.sysinternals.com/files/contig.zip.

Extract it to a folder that’s in your path, then “defrag” the MFTArea.txt file:

C:\>contig mftarea.txt

3. Run the CONVERT utility:

C:\>convert c: /FS:NTFS /CvtArea:MFTArea.txt

And now, the script:

<package>
<comment>
SmartConvert.wsf
Converts file system to NTFS using /CvtArea
flag to avoid MFT fragmentation
</comment>

  <job>
   <object id="
objFSO" progid="Scripting.FileSystemObject"/>
   <object id="
objShell" progid="WScript.Shell"/>
   <script language="
VBScript">
   Dim objDrive, objFolder, objWMI
   Dim strVolume, colOS, clsOS
   Dim iFilesFolders, iCvtArea

   'Get the drive volume info
   Set objDrive=objFSO.GetDrive("c:")
   strVolume=objDrive.VolumeName
   If objDrive.FileSystem="NTFS" Then
   WScript.Echo "File system already NTFS"
   WScript.Quit
   End If

   'Get the root folder
   set objFolder=objFSO.GetFolder("c:\")

   'Count total files and folders
   iFilesFolders=0
   WScript.Echo "Calculating size of CvtArea..."
   CountFilesAndFolders objFolder
   iCvtArea=iFilesFolders*1024

   'Add 20MB to CvtArea for buffer
   iCvtArea=iCvtArea+20480000

   'Create CvtArea file
   WScript.Echo "Creating file for CvtArea..."
   objShell.Run _
     "fsutil file createnew c:\MFTArea.txt " & iCvtArea,,True
   WScript.Echo "File: c:\MFTArea.txt created"

   'Make file contiguous
   WScript.Echo "Making CvtArea file contiguous..."
   objShell.Run "contig c:\MFTArea.txt",,True
   WScript.Echo "File Is contiguous"

   'Convert file system to NTFS
   WScript.Echo "Enter volume label when prompted"
   WScript.Echo "Volume label is: " & strVolume
   objShell.Run _
     "convert c: /FS:NTFS /CvtArea:MFTArea.txt"

   'Reboot computer to begin conversion
      Set objWMI=GetObject("winmgmts:" _
      & "{impersonationLevel=impersonate,(Shutdown)} " _
      & "!\\.\root\cimv2")
      Set colOS=objWMI.ExecQuery _
        ("Select * from Win32_OperatingSystem")
      For Each clsOS in colOS
        clsOS.Reboot()
      Next

      Sub CountFilesAndFolders (objFol)
        Dim iCount, clsFolder
        iCount=objFol.Files.Count+objFol.SubFolders.Count
        iFilesFolders=iFilesFolders + iCount
        For Each clsFolder In objFol.SubFolders
          CountFilesAndFolders (clsFolder)
        Next
     End Sub
     </script>
  </job>
</package>

The script essentially takes us through the steps for converting the drive. In its current state, it still requires a bit of user interaction—such as entering the Volume name of the drive. Still, when converting many drives at once, it can really save some time.

Making it Better
While utilizing the above method will provide much better performance than a simple “raw” conversion to NTFS, there’s still one area where we can improve things: Cluster size. The CONVERT utility automatically sets the cluster size to 512 bytes. While this cuts down on wasted disk space, it also leads to increased file fragmentation. A cluster size of 4K is generally considered optimal for most uses. Unfortunately, there isn’t a built-in or free utility that can perform this task. You’ll need to purchase a partition management tool, such as PowerQuest’s PartitionMagic, and resize the clusters to 4K (or whichever size works best in your environment).

Congratulations! You now have a finely tuned, smooth-running, secure file system.

comments powered by Disqus

Reader Comments:

Fri, Jan 13, 2006 bek georgia

this may sound insane, but I barely know how to turn on my computer but i ran across a scribbled peice of paper that had this; /fsintfs/cvtarea_______fsutil file createnew/no security mft convert file . Please help me to understand what does this mean for a cyber crash test dummy? help!

Sat, Dec 10, 2005 Anonymous Anonymous

I have problem with my Hard disk. One of my hard disk drive dosent work. when I click on it This message appears " Do you want to format?"
I have alot information on it and i caant format ii.
Also this drive file system has changed to RAW
how can I do?

Mon, Oct 31, 2005 Anonymous Anonymous

Fri, Aug 26, 2005 nano usa

hello, I have a question, how do I run the script..

Sun, Jun 26, 2005 Robert Sweden

Please help. My drive changed to Raw system from ntfs. Please help me, i have photos on the drive, when my kids where little. Hoa do i convert the drive fom Raw tp Ntfs. THX

Mon, Feb 2, 2004 John Bethesda, MD

I found the article informative, but lacking a couple of pieces of information...for example how does using fsutil and then CvtArea compare with just doing a convert and then defrag (which defrags the MFT). For optimal performance, MS indicates that the MFT should be located ~30% into the volume, suggestions ot tips for accomplishing this would have been helpful. Also, an MS rule of thumb for initial size of file for CvtArea is 1/8th the volume size. As others indicated, XP wil reclaim any unused space.

Sun, Jan 4, 2004 Anonymous Anonymous

i would just like to say that when i converted my FAT32 drive to NTFS using this method, the size of the CvtArea file ended up to being insufficient. A size of 1024 x (number-of-files plus number-of-folders) plus 20MB was not enough, and convert.exe told me that once it was too late to cancel. For my 26651 files and 1537 folders, convert.exe said i needed 65MB not 48MB (i used 52MB anyway) which the calculation came up with. I suggest you adjust the "buffer zone" to be 100MB instead of 20MB. Windows will reclaim any unused space anyway, so the bigger the better.

Sun, Dec 28, 2003 Phil Columbia, MO

Thanks for pointing out the presence of the CvtArea option in CONVERT. I was previously unaware of that.

A minor nitpick, though... Without specificly enabling encryption for files, they will not be more secure than on FAT32. ACL are enforced by Windows itself, not the filesystem. With a NTFS aware boot disk (as available at ntfs.com) or a Linux boot disk, the filesystem is laid bare, all security (except encryption) ineffective.

Just thought that I'd point this out. If physical access to the drive is possible (stolen laptop), and you're not using encryption, do not depend on NTFS security features to protect your data. This goes for any unencrypted filesystem. Encrypt those documents and spreadsheets if you want them secure.

This is very important. If you're not familiar with this, give it a try. Download that NTFS boot disk (not the XP install disk, it enforces those permissions). You wont need the admin password to mount the volume and you can read any file on the system. Any modern Linux CD should be able to do this too.

Add Your Comment Now:

Your Name:(optional)
Your Email:(optional)
Your Location:(optional)
Comment:
Please type the letters/numbers you see above

Redmond Tech Watch

Sign up for our newsletter.

I agree to this site's Privacy Policy.