JSI Tip 10153. The Windows XP FSUTIL.EXE HARDLINK CREATE command.

Jerold Schulman

February 12, 2006

3 Min Read
ITPro Today logo in a gray background | ITPro Today

You can use the FSUTIL HARDLINK CREATE command to create hard links, an NTFS-based link to a given file which adds a directory entry for the hard link without duplicating the original file.

You can:

Create hard links that use the same file name as the original file but appear in different folders.

Create hard links that use different file names from the original file but appear in the same folder.

Create hard links that use different file names from the original file and appear in different folders.

Because a hard link is a directory entry for a file, an application can modify a file by using any of its hard links. Applications that use any other hard link can detect the changes. However, directory entries for hard links are updated only when a user accesses a file by using the hard link. For example, if a user opens and modifies a file by using its hard link, and the size of the original file changes, the hard link that is used to access the file also shows the new size.

NTFS updates the properties of a hard link only when a user accesses the original file by using the hard link, NOT every time a user makes a change to the original file.

Hard links do not have security descriptors; instead, the security descriptor belongs to the original file to which the hard link points. Thus, if you change the security descriptor of any hard link, you actually change the underlying file's security descriptor. All hard links that point to the file allow the newly specified access. You cannot give a file different security descriptors on a per-hard-link basis.

You cannot create a hard link on one volume that refers to a file on another volume.

To delete a file that has multiple hard links, you must delete the file and all its associated hard links.

Windows XP Help contains:

Fsutil: hardlink

A hard link is a directory entry for a file. Every file can be considered to have at least one hard link. On NTFS volumes, each file can have multiple hard links, and thus a single file can appear in many directories (or even in the same directory with different names). Because all of the links reference the same file, programs can open any of the links and modify the file. A file is deleted from the file system only after all links to it have been deleted. After you create a hard link, programs can use it like any other file name.

Syntax

fsutil hardlink create NewFileName ExistingFileName

Parameters

create
      Establishes an NTFS hard link between an existing file and a new file. An NTFS hard link is similar to a POSIX hard link.

NewFileName
      Specifies the file to which you want to create a hardlink.

ExistingFileName
      Specifies the file from which you want to create a hardlink.

NOTE:

How can I determine a drive size and free space in a Windows XP batch?

How can I display drive information from the Windows XP command-line?

A Windows XP Professional Fsutil Query does NOT work properly on a FAT or FAT32 partition?

How do I create a sparse file of a specific size in Windows XP and greater?

When you add files, via a copy or install, to a Windows 2000 SP4 partition with 512 MB of free space, or less, you receive 'There is not enough space on the disk'?

When you attempt to set the dirty bit on a mount point by using FsUtil.exe in Windows Server 2003, you receive 'Error: Access is denied'?

How can I set the shortname of a file or folder?



Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like