Movatterモバイル変換


[0]ホーム

URL:


Skip to main content

This browser is no longer supported.

Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.

Download Microsoft EdgeMore info about Internet Explorer and Microsoft Edge
Table of contentsExit editor mode

fsutil file

Feedback

In this article

Finds a file by user name (if Disk Quotas are enabled), queries allocated ranges for a file, sets a file's short name, sets a file's valid data length, sets zero data for a file, or creates a new file.

Syntax

fsutil file [createnew] <filename> <length>fsutil file [findbysid] <username> <directory>fsutil file [optimizemetadata] [/A] <filename>fsutil file [queryallocranges] offset=<offset> length=<length> <filename>fsutil file [queryextents] [/R] <filename> [<startingvcn> [<numvcns>]]fsutil file [queryfileid] <filename>fsutil file [queryfilenamebyid] <volume> <fileid>fsutil file [queryoptimizemetadata] <filename>fsutil file [queryvaliddata] [/R] [/D] <filename>fsutil file [seteof] <filename> <length>fsutil file [setshortname] <filename> <shortname>fsutil file [setvaliddata] <filename> <datalength>fsutil file [setzerodata] offset=<offset> length=<length> <filename>

Parameters

ParameterDescription
createnewCreates a file of the specified name and size, with content that consists of zeroes.
<length>Specifies the file's valid data length.
findbysidFinds files that belong to a specified user on NTFS volumes where Disk Quotas are enabled.
<username>Specifies the user's user name or logon name.
<directory>Specifies the full path to the directory, for example C:\users.
optimizemetadataThis performs an immediate compaction of the metadata for a given file.
/aAnalyze file metadata before and after optimization.
queryallocrangesQueries the allocated ranges for a file on an NTFS volume. Useful for determining whether a file has sparse regions.
offset=<offset>Specifies the start of the range that should be set to zeroes.
length=<length>Specifies the length of the range (in bytes).
queryextentsQueries extents for a file.
/rIf<filename> is a reparse point, open it rather than its target.
<startingvcn>Specifies first VCN to query. If omitted, start at VCN 0.
<numvcns>Number of VCNs to query. If omitted or 0, query until EOF.
queryfileidQueries the file ID of a file on an NTFS volume.
<volume>Specifies the volume as drive name followed by a colon.
queryfilenamebyidDisplays a random link name for a specified file ID on an NTFS volume. Since a file can have more than one link name pointing to that file, it is not guaranteed which file link will be provided as a result of the query for the file name.
<fileid>Specifies the ID of the file on an NTFS volume.
queryoptimizemetadataQueries the metadata state of a file.
queryvaliddataQueries the valid data length for a file.
/dDisplay detailed valid data information.
seteofSets the EOF of the given file.
setshortnameSets the short name (8.3 character-length file name) for a file on an NTFS volume.
<shortname>Specifies the file's short name.
setvaliddataSets the valid data length for a file on an NTFS volume.
<datalength>Specifies the length of the file in bytes.
setzerodataSets a range (specified byoffset andlength) of the file to zeroes, which empties the file. If the file is a sparse file, the underlying allocation units are decommitted.

Remarks

  • In NTFS, there are two important concepts of file length: the end-of-file (EOF) marker and the Valid Data Length (VDL). The EOF indicates the actual length of the file. The VDL identifies the length of valid data on disk. Any reads between VDL and EOF automatically return 0 to preserve the C2 object reuse requirement.

  • Thesetvaliddata parameter is only available for administrators because it requires the Perform volume maintenance tasks (SeManageVolumePrivilege) privilege. This feature is only required for advanced multimedia and system area network scenarios. Thesetvaliddata parameter must be a positive value that is greater than the current VDL, but less than the current file size.

    It is useful for programs to set a VDL when:

    • Writing raw clusters directly to disk through a hardware channel. This allows the program to inform the file system that this range contains valid data that can be returned to the user.

    • Creating large files when performance is an issue. This avoids the time it takes to fill the file with zeroes when the file is created or extended.

Examples

To find files that are owned byscottb on drive C, type:

fsutil file findbysid scottb c:\users

To query the allocated ranges for a file on an NTFS volume, type:

fsutil file queryallocranges offset=1024 length=64 c:\temp\sample.txt

To optimize metadata for a file, type:

fsutil file optimizemetadata C:\largefragmentedfile.txt

To query the extents for a file, type:

fsutil file queryextents C:\Temp\sample.txt

To set the EOF for a file, type:

fsutil file seteof C:\testfile.txt 1000

To set the short name for the file,longfilename.txt on drive C tolongfile.txt, type:

fsutil file setshortname c:\longfilename.txt longfile.txt

To set the valid data length to4096 bytes for a file namedtestfile.txt on an NTFS volume, type:

fsutil file setvaliddata c:\testfile.txt 4096

To set a range of a file on an NTFS volume to zeros to empty it, type:

fsutil file setzerodata offset=100 length=150 c:\temp\sample.txt

Related links


Feedback

Was this page helpful?

YesNoNo

Need help with this topic?

Want to try using Ask Learn to clarify or guide you through this topic?

Suggest a fix?

  • Last updated on

In this article

Was this page helpful?

YesNo
NoNeed help with this topic?

Want to try using Ask Learn to clarify or guide you through this topic?

Suggest a fix?