Junction Points
In WindowsВ Vista and Windows ServerВ 2008, the default locations for user data and system data have changed. For example, user data that was previously stored in the %SystemDrive%\Documents and Settings directory is now stored in the %SystemDrive%\Users directory. For backward compatibility, the old locations have junction points that point to the new locations. For example, C:\Documents and Settings is now a junction point that points to C:\Users. Backup applications must be capable of backing up and restoring junction points.
These junction points can be identified as follows:
- They have the FILE_ATTRIBUTE_REPARSE_POINT, FILE_ATTRIBUTE_HIDDEN, and FILE_ATTRIBUTE_SYSTEM file attributes set.
- They also have their access control lists (ACLs) set to deny read access to everyone.
Applications that call out a specific path can traverse these junction points if they have the required permissions. However, attempts to enumerate the contents of the junction points will result in failures. It is important that backup applications do not traverse these junction points, or attempt to backup data under them, for two reasons:
- Doing so can cause the backup application to back up the same data more than once.
- It can also lead to cycles (circular references).
Per-User Junctions and System Junctions
The junction points that are used to provide file and registry virtualization in WindowsВ Vista and Windows ServerВ 2008 can be divided into two classes: per-user junctions and system junctions.
Per-user junctions are created inside each individual user’s profile to provide backward compatibility for user applications. The junction point at C:\Users\username\My Documents that points to C:\Users\username\Documents is an example of a per-user junction. Per-user junctions are created by the Profile service when the user’s profile is created.
The other junctions are system junctions that do not reside under the Users\username directory. Examples of system junctions include:
- Documents and Settings
- Junctions within the All Users, Public, and Default User profiles
System junctions are created by userenv.dll when it is invoked by Windows Welcome (also called the machine out-of-box-experience, or mOOBE).
If the user changes the system language to a language other than English, the per-user and system junction points will be created with localized names.
Junction v1.07
By Mark Russinovich
Published: July 4, 2016
Download Junction (504 KB)
Introduction
Windows 2000 and higher supports directory symbolic links, where a directory serves as a symbolic link to another directory on the computer. For example, if the directory D:\SYMLINK specified C:\WINNT\SYSTEM32 as its target, then an application accessing D:\SYMLINK\DRIVERS would in reality be accessing C:\WINNT\SYSTEM32\DRIVERS. Directory symbolic links are known as NTFS junctions in Windows. Unfortunately, Windows comes with no tools for creating junctions—you have to purchase the Win2K Resource Kit, which comes with the linkd program for creating junctions. I therefore decided to write my own junction-creating tool: Junction. Junction not only allows you to create NTFS junctions, it allows you to see if files or directories are actually reparse points. Reparse points are the mechanism on which NTFS junctions are based, and they are used by Windows’ Remote Storage Service (RSS), as well as volume mount points.
Windows does not support junctions to directories on remote shares.
Using Junction
Use junction to list junctions:
Usage: [-s]
Parameter | Description |
---|---|
-s | Recurse subdirectories |
Examples
To determine if a file is a junction, specify the file name:
junction c:\test
To list junctions beneath a directory, include the –s switch:
junction -s c:\
To create a junction c:\Program-Files for «c:\Program Files»:
C:\>md Program-Files
C:\>junction c:\Program-Files «c:\Program Files»
To delete a junction, use the –d switch:
junction -d c:\Program-Files
Return codes
0 — on success
-1 — on failed creation of new junction
0 — on failed deletion of junction (e.g. if file not found)
0 — on the check if a file is a junction fails (e.g. if file not found)
Download Junction (504 KB)
Runs on:
- Client: Windows Vista and higher
- Server: Windows Server 2008 and higher
- Nano Server: 2016 and higher
—>
Junction point in windows
This forum has migrated to Microsoft Q&A. Visit Microsoft Q&A to post new questions.
Answered by:
Question
dir /aL /s > c:\JunctionPoints.txt
gives me a list of all my junction points:
06/29/2010 09:33 AM Application Data [C:\Users\john.curtiss\AppData\Roaming]
06/29/2010 09:33 AM Cookies [C:\Users\john.curtiss\AppData\Roaming\Microsoft\Windows\Cookies]
06/29/2010 09:33 AM Local Settings [C:\Users\john.curtiss\AppData\Local]
06/29/2010 09:33 AM My Documents [C:\Users\john.curtiss\Documents]
. etc
i’m trying to find examples for syntax of the linkd command. it seems too simple.
if i cut and paste one of those paths:
linkd «C:\Users\john.curtiss\AppData\Roaming» tells me that directory «is not linked to another directory.» but in the output above, it’s listed as a target of «application data.»
linkd «C:\Users\john.curtiss\Application Data» tells me «Could not open: c:\users\john.curtiss\Application Data».
isn’t one of those commands supposed to work? and by «work,» i mean «display the path to the other»?
help for linkd, «source» section emphasized:
C:\Users>»C:\junctionscript\linkd.exe» /?
Links an NTFS directory to a target valid object name in Windows 2000.
LINKD Source [/D] Destination
Source — Displays the Windows 2000 name targeted by Source
Source Destination — Links source directory to Destination directory or a
Windows 2000 device or any valid Windows 2000 name
Source /D — Deletes Source, regardless of whether a link exists at
source
Hard Links and Junctions
There are three types of file links supported in the NTFS file system: hard links, junctions, and symbolic links. This topic is an overview of hard links and junctions. For information about symbolic links, see Creating Symbolic Links.
Hard Links
A hard link is the file system representation of a file by which more than one path references a single file in the same volume. To create a hard link, use the CreateHardLink function. Any changes to that file are instantly visible to applications that access it through the hard links that reference it. However, the directory entry size and attribute information is updated only for the link through which the change was made. Note that the attributes on the file are reflected in every hard link to that file, and changes to that file’s attributes propagate to all the hard links. For example if you reset the READONLY attribute on a hard link to delete that particular hard link, and there are multiple hard links to the actual file, then you will need to reset the READONLY bit on the file from one of the remaining hard links to bring the file and all remaining hard links back to the READONLY state.
For example, in a system where C: and D: are local drives and Z: is a network drive mapped to \\fred\share, the following references are permitted as a hard link:
- C:\dira\ethel.txt linked to C:\dirb\dirc\lucy.txt
- D:\dir1\tinker.txt to D:\dir2\dirx\bell.txt
- C:\diry\bob.bak linked to C:\dir2\mina.txt
The following are not:
- C:\dira linked to C:\dirb
- C:\dira\ethel.txt linked to D:\dirb\lucy.txt
- C:\dira\ethel.txt linked to Z:\dirb\lucy.txt
To delete a hard link, use the DeleteFile function. You can delete hard links in any order regardless of the order in which they are created.
Junctions
A junction (also called a soft link) differs from a hard link in that the storage objects it references are separate directories, and a junction can link directories located on different local volumes on the same computer. Otherwise, junctions operate identically to hard links. Junctions are implemented through reparse points.
Assuming the same conditions in the Hard Links section, the following references are permitted as junctions:
- C:\dira linked to C:\dirb\dirc
- C:\dirx linked to D:\diry
NTFS junction point
NTFS junction point
NTFS Junction Point — нововведение в файловой системе NTFS 5.0, т. н. точка соединения NTFS. Суть заключается в том, что указанный логический диск будет отображаться как папка в другом логическом диске. Эта возможность позволяет создавать некоторые эффекты с файловой системой (например, хранить 2 профиля одного и того же пользователя и переключаться между ними без особых проблем).
Данную функцию можно настроить в оснастке «Управление дисками»: правой кнопкой на подключаемом диске, пункт «Изменить букву диска или путь к диску…», далее в списке будут отображены все возможные пути к диску, по умолчанию диск доступен по своей букве («Х:» — где Х буква диска). Менять пути к диску можно соответствующими кнопками под списком.
Для доступа к такой папке не нужны никакие дополнительные настройки приложений, то есть доступ осуществляется введением адреса папки. Таким образом исчезает ограничение на 26 локальных томов на одном компьютере (количество букв английского алфавита для именования дисков), так как том может существовать без присвоения ему имени.
Также можно создавать NTFS Directory Junctions (реализованные через точки соединения NTFS) и, таким образом, эмулировать жёсткие ссылки на каталоги:
mklink /J новый_NTFS_junction целевой_(существующий)_каталог
Компоненты Microsoft Windows | |
---|---|
Основные |