File System Operations
We're done with functional descriptions and checklists. It's now time to get some real work done. The next few topics contain operating procedures for the following:
- File compression
- Reparse points
- Defragmentation
- NTFS conversion
- Writing to CD-R/RW and DVD-RAM Devices
File Compression Operations
No controls are available in the UI or Registry hacks to change the compression mechanism. The only setting is to turn the compression bit on or off. This can be done using Explorer or a command-line utility called COMPACT. Procedure 15.4 shows how to turn compression on using Explorer.Procedure 15.4 Enabling Compression
- Open Explorer and navigate to the file or folder you want to compress.
- Right-click the icon and select PROPERTIES from the flyout menu. The Properties window opens (see Figure 15.17).
Figure 15.17. Properties window showing information about a big file in an uncompressed state.
- In the Attributes field, click Advanced. The Advanced Attributes window opens. This window controls the various attribute bits in the MFT record. See the sidebar, "Using Advanced File Attributes," for more information.
Using Advanced File Attributes
The Advanced Attributes window for a file or folder, as shown in Figure 15.18, has several options that affect file storage. This is what they do:- The Archive bit comes from classic NT and DOS. It signals that the file was changed but not backed up.
- The Index bit is new to Windows Server 2003 and indicates that the Content Indexing Service , or CISVC, should scan the file. This service began life as an add-on indexer for Internet Information Server and has now burrowed its way into the operating system. Fortunately, this option is turned off by default.
- The Compress attribute causes the system to compress the file.
- The Encrypt attribute causes the system to encrypt the file.
Figure 15.18. Advanced Attributes window showing status of file attributes such as compression and encryption.
The Compress and Encrypt attributes are mutually exclusive. This happens for two reasons:- Encrypted files have very few similar characters, so Microsoft does not consider them good candidates for compression.
- The system cannot restore compressed encrypted files from tape. The Restore process recovers a compressed file from tape by reading the header to find the starting cluster on the drive where the file was originally located. The Restore process, running in the context of a Backup Operator, cannot read the encrypted file to find the destination cluster.
- Select Compress Contents to Save Space and then click OK to save the change and close the window.
- Click OK to apply the change and close the Properties window. Depending on the size of the file, it may take a while to compress.
- Close the Properties window and then open it again. The Size on Disk value shows you the new compressed size.
If you prefer command-line tools, use the COMPACT utility to compress and decompress files. To set the compression bit, run compact /c. To reset the bit, run compact /u.If you want to set the compression bit on a directory and compress all the files in that directory and its subdirectories, run compact /c /s.To list files and their compression information, run compact with no switches. For example, this is a list of the standard BMP files that come with Windows Server 2003 in their compressed state:
C:>\TestDir\compact
Listing C:\TestDirNew files added to this directory will not be compressed.
1272 : 1024 = 1.2 to 1 C Blue Lace 16.bmp
17062 : 17062 = 1.0 to 1 C Coffee Bean.bmp
16730 : 15872 = 1.1 to 1 C FeatherTexture.bmp
17336 : 13312 = 1.3 to 1 C Gone Fishing.bmp
Of 4 files within 1 directories
4 are compressed and 0 are not compressed.
46,310 total bytes of data are stored in 32,430 bytes.
The compression ratio is 1.2 to 1.
Reparse Point Operations
You can create reparse points, also called mount points , using the Disk Management console or from the command line using LINKD. After it is created, you can manage and delete the reparse points using the Fsutil utility.Using the Disk Management console, you can only mount an entire file system. LINKD makes it possible to mount a particular folder. You cannot mount a network file share or a device accessed via a UNC name.
Creating a Mount Point Using the Disk Management Console
Procedure 15.5 describes how to use the Disk Management console to create a mount point for another volume.Procedure 15.5 Creating a Mount Point Using the Disk Management Console
- Create an empty folder on an NTFS volume to act as a mount point. The folder can be in any subdirectory. If the folder has existing files or directory entries, it cannot be used as a mount point.
- Open the Computer Management console using START | PROGRAMS | ADMINISTRATIVE TOOLS | COMPUTER MANAGEMENT .
- Expand the tree to STORAGE | DISK MANAGEMENT .
- Right-click the bar representing the CD-ROM drive and select CHANGE DRIVE LETTER AND PATH from the flyout menu. The Change Drive Letter and Path window opens (see Figure 15.19).
Figure 15.19. Change Drive Letter and Path window.
- Click Add. The Add New Drive Letter or Path window opens.
- Select the Mount This Volume at an Empty Folder Which Supports Drive Paths radio button and click Browse. The Browse for Drive Path window opens.
- Navigate to the NTFS volume where you created the folder for the mount point. You can also click New Folder to create a folder on any NTFS volume. Long names are permitted.
- Click OK to accept the new folder and close the window.
- At the Add New Drive Letter or Path window, click OK to mount the drive. The Disk Management console does not show that a volume is mounted on another volume.
Creating a Mount Point Using LINKD
The normal volume mounting process as described in the last section is limited to mounting an entire volume at a mount point. The Windows Server 2003 Resource Kit contains a utility called LINKD that can mount a folder to an empty folder as well as a volume or device. The syntax for LINKD is as follows:
linkd <empty_folder > <source_folder >
For example, to mount the C:\Windows folder at D:\test (an empty folder), enter the following:
linkd d:\test_dir c:\winnt
You cannot use LINKD to mount a folder on a network drive. Deleting the folder deletes only the link. The folder icons do not show a special mounted icon such as that used by regular volume mount points.
Managing Reparse Points Using Fsutil
The Fsutil console has a reparse point namespace for use in managing mount points and other junctions. For example, to check the contents of the reparse point entry in the mount point record, enter fsutil reparsepoint query <name >. Here is a sample listing:
C:\>fsutil reparsepoint query mountpointname
Reparse Tag Value : 0xa0000003
Tag value: Microsoft
Tag value: Name Surrogate
Tag value: Mount Point
GUID : {000E0000-0010-0006-5C00-3F003F005C00}
Data Length : 0x00000020
Reparse Data :
0000: 48 00 3a 00 5c 00 00 00 48 00 3a 00 5c 00 00 00 H.:.\...H.:.\...
0010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
You can use Fsutil to delete the reparse point without touching the files behind it. Enter fsutil reparsepoint delete <name >. Unfortunately, there is no "create" command for Fsutil. You'll need to use LINKD from the Resource Kit.
Defragmentation Operations
There are two ways to initiate a defragmentation run for a volume. You can use the GUI-based console, Dfrg.msc, or you can use a new command-line utility, DEFRAG. The two interfaces execute the same code, so the choice is purely one of convenience. One advantage of the command-line version is that you can schedule it to run via the Task Scheduler.The topics in this section give the procedures for cleaning up a disk prior to defragging, how to defrag a volume using the GUI, and how to schedule a defrag using the command line.
Cleaning up a Volume Prior to Defragmenting
Have you ever used the services of a housekeeper? What's the first thing you did before the housekeeper paid that first visit? You cleaned house, right? After all, you don't want a total stranger to think you're a slob, do you? The same rule applies to preparing a volume for defragmenting. It doesn't make sense to have lots of useless files on the disk that waste the defragger's time. So, do two things prior to defragging:
- Run CHKDSK /f on every volume you plan on defragging. If this means restarting to get AUTOCHK to run on the system/boot partition, it's worth doing. I have yet to see an instance where a system crashed or went blue-screen during defrag following a good CHKDSK.
- Get rid of deadweight files. Windows Server 2003 has a utility for this called Disk Cleanup . It comes in the form of an executable, Clnmgr.exe. Disk Cleanup scans a drive and identifies old Indexing catalogs, Temporary Internet files, temporary and superceded offline files, ActiveX and Java applet downloads, and Recycle Bin contents that can be deleted without causing problems.
Disk Cleanup is a quick and effective way to remove unwanted files. Run the utility as described in Procedure 15.6.Procedure 15.6 Using Disk Cleanup
- Launch Disk Cleanup using START | PROGRAMS | ACCESSORIES | SYSTEM TOOLS | DISK CLEANUP . The Disk Cleanup window opens.
- Specify the drive letter for the volume you want to clean. The utility searches for files that are candidates for removal. If the disk has a mount point, the search includes the mounted volume. When finished, Disk Cleanup offers the results in a menu of options (see Figure 15.20).
Figure 15.20. Disk Cleanup window showing menu options.
Choosing to delete Temporary Internet Files does not delete cookies. It does clear cached web pages, so you may experience delays when accessing web sites the next time you run Internet Explorer.Choosing to delete Temporary Off-Line Files is acceptable even if the user is offline or forgot to synchronize. Disk Cleanup only deletes offline files that are marked as synchronized with the source file. - Click the options you want to use and then click OK to make the changes and delete the files. When Disk Cleanup finishes, it closes down without a final message.
Defragmenting an NTFS Volume Using the MMC Console
You can open the Disk Defragmenter console in several ways:
- Directly from the START menu: Start | Programs | Accessories | System Tools | Disk Defragmenter.
- From the Computer Management console: by expanding the tree to STORAGE | DISK DEFRAGMENTER .
- From Explorer or My Computer: by right-clicking a drive icon, opening the Properties window, and selecting TOOLS | DEFRAGMENT NOW .
- From the Run window: by entering dfrg.msc .
After you open the Disk Defragmenter console, you can run a fragmentation analysis of a volume or you can jump right in and defragment the volume. Start with an analysis (see Procedure 15.7). Don't be surprised to see lots and lots of files scattered all over the drive while the analysis tool reports that the volume does not require defragging. An NTFS volume is considered fragmented only when non-resident data attributes are split across multiple runs. The automatic system tune-up will move commonly-used files to strategic locations automatically.Procedure 15.7 Performing a Defragmentation Analysis
- Highlight the volume and click Analyze. The system looks for fragments and gives you a visual display and text report. Figure 15.21 shows an example.
Figure 15.21. Disk Defragmenter window showing results of disk analysis.
- Click View Report. The listing contains statistics for volume use, volume fragmentation, file fragmentation, pagefile fragmentation, directory fragmentation, and MFT fragmentation. Of this list, the defragger can correct file and directory fragmentation only. Expect to find nearly all the Registry hives near the top of the list for fragmentation.
- Click Defragment. You can do this from the Report window or the main window. The system performs another analysis and then begins defragging. If it is a big volume with lots of fragmented files, the defragger may stay busy for hours. If you are defragging a server, you should do this after working hours. Not only is performance miserable, locked user files impedes the defragger from doing a thorough job. Times vary depending on I/O speed, CPU speed, and bus speed.
- Following completion, Disk Defragmenter displays a new graphical fragmentation analysis and a new report. You may need to defrag several times if you have a heavily fragmented volume.
Defragmenting Using the DEFRAG Command-Line Utility
Windows Server 2003 corrects a deficiency in Windows defragmentation by supplying a command-line version of the defrag utility that can be scheduled using the Task Scheduler. The switches are for analyze only (-a) and verbose reporting (-v):
C:\>defrag d: -a -v
Windows Disk Defragmenter
Copyright 2001 Microsoft Corp. and Executive Software International, Inc.
Analysis Report
Volume size = 1.95 GB
Cluster size = 2 KB
Used space = 1.87 GB
Free space = 89 MB
Percent free space = 4 %
Volume fragmentation
Total fragmentation = 28 %
File fragmentation = 56 %
Free space fragmentation = 0 %
File fragmentation
Total files = 3,516
Average file size = 658 KB
Total fragmented files = 40
Total excess fragments = 753
Average fragments per file = 1.21
Pagefile fragmentation
Pagefile size = 0 bytes
Total fragments = 0
Folder fragmentation
Total folders = 283
Fragmented folders = 21
Excess folder fragments = 72
Master File Table (MFT) fragmentation
Total MFT size = 16 MB
MFT record count = 3,820
Percent MFT in use = 24
Total MFT fragments = 2
If you have less than 15 percent free space on a drive, DEFRAG will give an error message and refuse to start. You can force the engine to use the MFT buffer area with the -f switch. The defragmentation will run a little more slowly, but it should succeed.
NTFS Conversion Operations
In spite of all the protections built into the conversion program, there is still the potential for wrecking your file system, so prudence dictates that you get a good backup before converting.There are no conversion options in the Disk Management console. Conversion is done using a command-line utility called CONVERT. The syntax is as follows:
convert volume_name /fs:ntfs
You can specify a volume name, drive letter, or mount point as the conversion target. If you specify a drive letter, you are prompted for the volume name just to verify that you have the right volume. Run VOL if you need to verify the volume name.The default cluster size is 512 bytes to make the most effective use of the volume during conversion. You cannot change the cluster size later without reformatting the volume.The system must be able to get an exclusive lock on all files to do the conversion. If it cannot get exclusive access, you are asked whether you want to do the conversion at the next restart. If you answer Yes, the following entry is made to the Registry:
Key: HKLM | System | CurrentControlSet | Control | SessionManager
Value: BootExecute
Data: AUTOCHK autoconv \??\c: /FS:ntfs
The \??\c: entry is the symbolic link in the Windows Server 2003 object namespace that represents the volume. If you change your mind and decide that you don't want to convert, you can edit this value to remove the autoconv entry and everything after it.
CD-RW and DVD-RAM Operations
The secret to having a pleasant experience with the CD writing features in Windows Server 2003 and XP is to tell yourself over and over, "This is not a CD copier. This is not a CD copier."The reason for this mantra is that, although Microsoft licensed the code from Roxio (maker of Easy CD Creator), they did not license the packet writing engine that makes feats like CD duplication possible. Windows Server 2003 and XP use standard ISO9660/Joliet for structuring the disk contents, meaning that it treats the CD like a standard file repository.If you want the features that come with a packet-engine CD writer, here are a few products to look at. Be sure to get the latest version to be confident that the product will run satisfactorily under Windows Server 2003:
- Roxio (www.roxio.com).
Their flagship product is Easy CD Creator Platinum. (Roxio is a spinoff of Adaptec.) - CD Speed 2000 (www.cdspeed2000.com).
Their product is Nero CD Burner. This is a popular program both for its price (very low) and features that simplify building audio CDs from ripped MP3s. - Golden Hawk Technologies (www.goldenhawk.com).
This is a German company with a product called CDRWIN, which has long held a niche for folks who want the fastest burner with minimal features. The documentation and interface could use some work, but it is solid technology.
You'll need to use one of these third-party products if you have a CD-R or CD-RW unit that is not fully MMC2-compliant. Look for the "Ready for Windows XP" logo or check the Hardware Compatibility List to make sure your unit will work with Windows Server 2003.
CD Writing Functional Description
To transfer files to a CD-R or CD-RW drive, drag and drop the files using Explorer onto the drive icon. This copies them into a temporary folder. From there, you instruct the system to burn the files to the CD. This can be done in one of several ways:
- Right-click the drive icon in My Computers and select Write These Files To CD.
- Double-click the drive icon to view the files that are already on the disk and those that are waiting to get burned to the disk. Under CD Writing Tasks in the side taskbar, select Write These Files To CD. If you do not see this taskbar, use TOOLS | FOLDER OPTIONS to enable the Show Common Tasks In Folders option.
- Eject the CD, either manually or from the flyout menu of the CD icon. This initializes a wizard that prompts you to either burn the files, save the temporary files, or forget about the whole thing and delete the temporary files.
Roxio DirectCDRoxio has a product called DirectCD that burns directly from the files on a drive to CD-R, CD-RW, and DVD-RAM media. Ordinarily, the disk is formatted using a proprietary format that permits file compression. Only the Roxio driver can read this disk. Roxio has an option to use a non-proprietary format for this operation that does not include file compression. |
DVD-RAM Support
Windows Server 2003 and XP can read DVD-RAM disks formatted with Universal Disk Format (UDF) up through version 2.01 but it will not write to UDF disks.The only writable format supported by Windows Server 2003 for DVD-RAM drives is FAT32. NTFS is not supported due to the continual writes to the file system journal.As of this writing, Windows 2000 does not support reading DVD-RAM disks formatted with FAT32. You would need to install a third-party application to transport media between platforms.To write files to a DVD-RAM device, you can use drag-and-drop or COPY/XCOPY from the command line or any other application that uses standard Win32 API file system calls. The system treats DVD-RAM as regular, albeit very slow, spinning media.File writes to a DVD-RAM drive are buffered both in the file system driver and at the device. If you eject the media from the drive, either from the device or by selecting the option from the flyout menu, the file system will flush the cache to the buffer at the drive before releasing the device. The device will flush the buffer to the drive before letting the media spin down. Depending on how much information is in the cache and the speed of your unit, this operation might take a while.If your current DVD-RAM device appears as two drive letters, this means the driver supplied by the vendor uses a special format that combines a FAT piece with a UDF piece. Windows Server 2003 interprets the report from such a driver as two different interfaces. You should not try to write to either of these two logical drives. Only use the software provided by the vendor.If you need software that can read and write DVD-RAM drives in UDF format, try visiting the Software Architects web site at www.softarch.com. They are technology pioneers for UDF and do a good job of keeping up with various platforms.