Post Reply 
NTFS Junctions
Author Message
ZiNgA BuRgA
Smart Alternative

Posts: 17,022.2988
Threads: 1,174
Joined: 19th Jan 2007
Reputation: -1.71391
E-Pigs: 446.1274
Offline
Post: #1
NTFS Junctions
An interesting feature in Windows XP (probably in 2000 as well) that many people probably don't know of, is NTFS junctions (and for those that do know about them, most probably don't use them).  MS finally added support for symbolic links in Vista, though not everyone uses Vista at the moment.  On the other hand, Linux has had symbolic links for ages.

What are Junction points?
In a nutshell, it's basically a folder alias.  For example, if you have a directory at C:\mydir, you could create a junction (assuming D: is an NTFS drive) at D:\link which directly links to C:\mydir.

How is it different from shortcuts?
Whilst it may look like a shortcut, it's actually a bit different.  A shortcut is actually just a file (with a .lnk extension (which is usually hidden)) which tells explorer (note, not any other application) to automatically redirect you to that location.  Note that it's a redirection, not an alias.  And being a file, you can actually open the shortcut in a hex editor and view the contents of this ~1KB file.
A junction point, on the other hand, being an alias, acts as the linked folder.  For example, if you have a subfolder C:\mydir\subdir, the directory D:\link\subdir will exist.  If you save a file as D:\link\subdir\myfile.txt, the file C:\mydir\subdir\myfile.txt will exist.

Junctions vs Symbolic links
Basically, junctions can only link folders, whereas symbolic links can link files.  In XP, you can perform hard links for files, however it'll only work if the link and the file are on the same drive.  But junction points are usually enough for most purposes.

How to make Junctions
Before wee continue:
Be careful when dealing with junctions, primarily with regards to delete operations (also be aware of rename/move operations).  Avoid simply deleting a junction point - many applications won't be able to tell it's a junction point, so it will clear everything inside your juction along with the junction (even if that's what you want to do MS recommends to avoid doing this).  Also, deleting the source folder of a junction could leave you with a hanging link, which may or may not be hard to deal with.  Similarly, if you move/rename the source directory, a similar thing could happen.
When removing a junction, please do it the proper way (will show how).  If you want to remove the source folder, remove the junction first, before removing the folder.

Now here's the tool I used to create junctions - it's a command line app, but simple enough to use (there are probably GUI apps around if you look for it):
http://technet.microsoft.com/en-us/sysin...96768.aspx

To create a junction, the following command will do the job:

Code:
junction mylink target

for example

Code:
junction D:\link C:\mydir


To remove:

Code:
junction -d mylink

ie

Code:
junction -d D:\link





Uses for Junction points
Right now, it may seem junction points are an interesting thing, but doesn't have much practical use.  I'll admit it's not something you'll probably use on a daily basis, but it does have some interesting applications - here's some ideas:

  • Quick fix for out of space partition - let's say you have a system partition C: and a file storage partition D:.  You're low on space on C:, but have plenty on D:.  However, you need to install an application, which will write a lot of stuff to C:.  Instead of resizing partitions, or trying to clear out C:, a quick fix is to move some of your apps installed on C: to D:, and then make junction points to link the applications back to C: - your apps will still work fine (since they'll appear to exist on the C: drive), and you'll have more space on your C: drive.
  • Reducing fragmentation on "read-only" drives - like in my partitioning guidelines thread, I mentioned keeping the number of write operations to a system partition down to lessen/prevent fragmentation (and make your system drive perform optimally).  This is especially more important if you're using an SSD, where writes are slow and wear down the drive.  The simplest solution in this case is to simply junction the places where stuff is written to another partition/drive.  For example, the Documents and Settings folder.
  • Manual Preloading - junctioning can be used to perform this.  Essentially, you load your commonly used apps directly into RAM (like Superfetch, but this is better since you have full control over what is loaded).  I'll talk more about this in another thread.
  • Tidiness? - if you like storing all your files on one drive/partition, and your apps on another, you may face some problems of apps saving stuff in their installation directory (ie games which save stuff to their /save folder).  If you want to have the save files together with your other files (perhaps if you only back up your files partition - this ensures that all your files are backed up) then a junction point is a solution.

Tip: I typically stick a different folder icon for junctioned folders to indicate that the folder is a junction point and not just a folder, so I don't accidentally delete it some time later.


Fun with Junctions
Well, not really - unfortunately, Windows is smart enough to put some limits on things.  One thing you can do is make a folder, then inside the folder, create a link back to its parent.  This will give the effect of being able to constantly enter the same folder.  Unfortunately, Windows limits the depth of this, but you could use this with folders with plenty of subfolders, to make searching incredibly slow (if your school admin likes searching your folder for stuff, perhaps).
Alternatively, if you can, stick a junction in your folder to C:\Windows, and watch him wonder why you can stick ~1GB of data on your 20MB drive and why he can't delete your stuff...
19/12/2008 04:39 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Mc Cabe
Storm Trooper

Posts: 1,218.1771
Threads: 177
Joined: 14th Aug 2007
Reputation: 1.43435
E-Pigs: 38.5281
Offline
Post: #2
RE: NTFS Junctions
Another immensely informative thread. Thanks zinga! :)

umm?
19/12/2008 05:22 AM
Visit this user's website Find all posts by this user Quote this message in a reply
feinicks
One day... we Fly...

Posts: 6,124.6050
Threads: 531
Joined: 27th Mar 2008
Reputation: 2.35695
E-Pigs: 210817.3958
Offline
Post: #3
RE: NTFS Junctions
A guy who were learning RHCE (thts Red Hat {Linux certification}) with me found this linking immensely interesting... according to him, this would definitely be included in the list of why Windows fails.

◄◄••• 天使たちの夢か? •••►►

[Image: ewualizer.gif]
My works!
(This post was last modified: 19/12/2008 07:37 AM by feinicks.)
19/12/2008 05:42 AM
Find all posts by this user Quote this message in a reply
boogschd
boogyman
Worlds End

Posts: 4,954.3196
Threads: 90
Joined: 29th Nov 2007
Reputation: 4.19708
E-Pigs: 43.6852
Offline
Post: #4
RE: NTFS Junctions
i got lost...

/re-reads

by the way thanks for the new info burger man :p
(This post was last modified: 19/12/2008 07:21 AM by boogschd.)
19/12/2008 07:21 AM
Visit this user's website Find all posts by this user Quote this message in a reply
SchmilK
Noob

Posts: 4,698.2833
Threads: 359
Joined: 16th Apr 2007
Reputation: 0.38918
E-Pigs: 82.0546
Offline
Post: #5
RE: NTFS Junctions
i read the title too fast and thought this was an article about need for speed.  

:palmface:

limneosgreen Wrote:Take my advice, don't try to install custom themes ... it's possible to brick ur psp.. why just don't change wallpaper
19/12/2008 08:23 AM
Find all posts by this user Quote this message in a reply
boogschd
boogyman
Worlds End

Posts: 4,954.3196
Threads: 90
Joined: 29th Nov 2007
Reputation: 4.19708
E-Pigs: 43.6852
Offline
Post: #6
RE: NTFS Junctions
LOL

NFS:Junctions....

interesting title :p
19/12/2008 08:26 AM
Visit this user's website Find all posts by this user Quote this message in a reply
roberth
Resident Full Stop Abuser.....

Posts: 4,580.2098
Threads: 200
Joined: 18th Jun 2007
Reputation: -5.5814
E-Pigs: 43.8419
Offline
Post: #7
RE: NTFS Junctions
So, this could be used if you wanted to keep apps/games etc on different partitions?

(This post was last modified: 19/12/2008 09:36 AM by roberth.)
19/12/2008 09:36 AM
Find all posts by this user Quote this message in a reply
YoYoBallz
L4YoY0s

Posts: 6,057.4567
Threads: 644
Joined: 3rd Mar 2007
Reputation: 15.01961
E-Pigs: 13327.7533
Offline
Post: #8
RE: NTFS Junctions
Very useful info, thanks Zinga

<Myth0s> i love boys
-------------------------------------------------------------------
I Go To Earth When Mars Is Boring.
-------------------------------------------------------------------
¿ʞɔпɟ əɥʇ ʇɐɥʍ I was first EPerson to have upside down title.
-------------------------------------------------------------------
19/12/2008 11:39 AM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA
Smart Alternative

Posts: 17,022.2988
Threads: 1,174
Joined: 19th Jan 2007
Reputation: -1.71391
E-Pigs: 446.1274
Offline
Post: #9
RE: NTFS Junctions
roberth Wrote:So, this could be used if you wanted to keep apps/games etc on different partitions?
Yeah, in fact, I keep all my apps on a separate partition, but some badly coded apps hard-code to install to the C:\Program Files folder - junctions get around that.

Thanks for the comments guys - actually, this was meant for another thread I'm going to write up (junctions really aren't that useful).
19/12/2008 10:20 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Kaiser
The Average Lucky Bastard

Posts: 2,512.2567
Threads: 296
Joined: 13th Apr 2007
Reputation: 0.38918
E-Pigs: 43.7138
Offline
Post: #10
RE: NTFS Junctions
SchmilK Wrote:i read the title too fast and thought this was an article about need for speed.  

:palmface:

same happened to me, until i saw zinga made the thread.

COLEGIOOOOOOOOOOOOOOOOOOOOOOO!!!!!!!!!!!!!!!!!!!!!!
FEEL THE POWER   \(m)/ (@_@) \(m)/
Vi Veri Veniversum Vivus Vici
19/12/2008 10:25 PM
Find all posts by this user Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)

 Quick Theme: