Home | Blog | Software | Reviews and Features | Forum | Help | Donate | About us
topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • December 11, 2016, 04:04:17 AM
  • Proudly celebrating 10 years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Last post Author Topic: soft and hard links in ntfs  (Read 21074 times)

nudone

  • Cody's Creator
  • Columnist
  • Joined in 2005
  • ***
  • Posts: 4,117
    • View Profile
    • Donate to Member
soft and hard links in ntfs
« on: June 14, 2006, 12:43:55 AM »
i found a link on shellextension city for this little app, 'NTFS Links' http://alax.info/blog/ntfslinks

can someone just explain why i'd want a hard or soft link and not just a shortcut?

i'm not trying to say hard and soft links are a waste of time - i just feel like i'm missing out on something that could be useful but i can't understand their purpose.

thanks.

Gothi[c]

  • DC Server Admin
  • Charter Honorary Member
  • Joined in 2006
  • ***
  • Posts: 858
    • View Profile
    • linkerror
    • Donate to Member
Re: soft and hard links in ntfs
« Reply #1 on: June 14, 2006, 12:48:05 AM »
You can't "cd" to a shortcut, for example.
You can't "type" a shortcut in commandprompt and get your original file, for example.
Shortcut generally only work with thingies you click on.

nudone

  • Cody's Creator
  • Columnist
  • Joined in 2005
  • ***
  • Posts: 4,117
    • View Profile
    • Donate to Member
Re: soft and hard links in ntfs
« Reply #2 on: June 14, 2006, 01:15:21 AM »
right, so as i don't ever use the command prompt (unless i really have to) i've no real use for hard/soft links.

thanks for putting my mind at rest, Gothi[c]

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Donate to Member
Re: soft and hard links in ntfs
« Reply #3 on: June 14, 2006, 05:12:20 AM »
I'm not sure about this, please correct me if i'm wrong.
I belive a hard link also allows you to have a a better organization, I mean, you can have like the root of D:\ with files from the whole filesystem.
It'd make it easier to install stuff, as to install something in a deep place, you could only have a hard like like "d:\place", and you wouldn't have to be browsing for it, as it would be resolved if you'd just type in "d:\place" in the destination box.

Gothic if i'm wrong, please correct me, as i haven't tried hard links myself, because i didn't give myself the work. (but if i'm right, i might rethink this ;))

db90h

  • Coding Snacks Author
  • Charter Member
  • Joined in 2005
  • ***
  • default avatar
  • Posts: 481
  • Software Engineer
    • View Profile
    • Bitsum - Take control of your PC
    • Read more about this member.
    • Donate to Member
Re: soft and hard links in ntfs
« Reply #4 on: June 14, 2006, 05:25:40 AM »
Yep, they can be used for better organization, or anything else. Without 'hard links', my life would have ended long ago. I'd still be typing long path names, navigating to deep folders, or changing hard coded path configurations right this minute if it weren't for hard links!

Hard links are technically NTFS reparse points.You could think of them as a pointer to (or alias for) another filesystem object, but really they are true alternate mount points for those filesystem objects.

Volumes can be mounted to a folder, like "c:\dev" holds my D: drive. This is a mount type reparse point.
Folders and files can be linked, like "c:\downloads" may reference "f:\this\folder\holds\downloads". This is a junction type reparse point.
Files can be linked in much the same way. This is a junction type reparse point.

Without a program like NTFSLink, if I were to delete c:\downloads in explorer, it would delete f:\this\folder\holds\downloads as well. NTFSLink intercepts deletion operations so that you won't accidentally delete the 'backing' files when you just want to remove a link. This is the #1 problem with reparse points. A soft link, like a shortcut, however can be deleted without deleting the backing folder.

So the way the file system treats the types of links is fundamentally different, particularly in delete, rename, and other operations. A normal file system operation on a soft link (shortcut) acts only on itself, while a hard link acts on the target.

NTFSLink is a great program to adds safe and effective support for junction type reparse points (mount type reparse points are already supported in disk manager). I actually went to code a program to create NTFS reparse junctions (SHJunction I called it), but stopped development when I found NTFSLink. I did release an early version of it, then killed myself when I discovered NTFSLink.

« Last Edit: June 14, 2006, 05:31:13 AM by db90h »

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Donate to Member
Re: soft and hard links in ntfs
« Reply #5 on: June 14, 2006, 05:37:17 AM »
I just found yet another usefulness about it.
Instead of duplicating stuff, you can just create a hard link (or would it be a soft link? i still don't get the difference).
The computer acts in a different way than with a shortcut. This is important. when you make a hard link, you get a "duplicate" of the directory you link to. Not like a shortcut that would take you to the other directory. BUT, it's not a really duplicate, if you change something in one of them, the other one also reflects it.

What i really mean is that in windows explorer, if you create a hard link, and then open it, it won't change directories to the destination, the directory will actually be in the place of the shortcut. I think this is the most usefull part of it. (actually, db also mentioned this, by saying it creates mount points, but i like to repeat what other people say)

I installed the program and played a bit with it. It's most useful, now i only need to format my other disk in ntfs :(
(as i'm extremelly dumb, last time i installed linux, i formated my "archive" volume as fat32, so that i could read from it while in linux. but never really had an use for it)

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Donate to Member
Re: soft and hard links in ntfs
« Reply #6 on: June 14, 2006, 05:52:01 AM »
I forgot to mention. Here's an useful real context of the usefulness of this tool.

I have a tree structure to organize my university classes. A bit like this:

-IST
  -2005/2006
    -1st semester
      -one class
      -another class
    -2nd semester
      -one class
      -another class
  -2006/2007
    -1st semester
      -one class
      -another class
    -2nd semester
      -one class
      -another class
  -e-books

See the e-books directory? That's where i store the e-books i have for each of the classes. But i also like to have them in the class directory itself, so that i can connect each e-book to each class. To avoid having repetition of the files, i can just create a hard link for each one in each of the directories. This could be done with shortcuts, but it'd be displayed as a shortcut, the advantage of hard links is that it looks like the real file is there.

The difference is that i could create a hardlink for e-books in each of the other directories, and when i opened it in explorer, it'd look like the directory is actually there, inside each of the class directories. And if any change is made to it, the e-books directory is changed too! :D
   

Carol Haynes

  • Waffles for England (patent pending)
  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 7,986
    • View Profile
    • Dales Computer Services
    • Donate to Member
Re: soft and hard links in ntfs
« Reply #7 on: June 14, 2006, 05:53:47 AM »
You can also map spare drive letters to folders ... which is similar

app103

  • That scary taskbar girl
  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 5,666
    • View Profile
    • App's Apps
    • Read more about this member.
    • Donate to Member
Re: soft and hard links in ntfs
« Reply #8 on: June 14, 2006, 05:55:49 AM »
Mounting partitions as hard links on your C drive, and making them seem like folders, also prevents you from running out of drive letters.

There are only 26 letters in the alphabet and you can eventually run out, but no limit to how many drives that can be mounted as folders with hard links. :D

Rover

  • Master of Smilies
  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 630
    • View Profile
    • Donate to Member
Re: soft and hard links in ntfs
« Reply #9 on: June 14, 2006, 07:30:28 AM »
Hard link vs. soft link:  Under windows they're called hard links, it's the approx. equivalent of a soft link in *nix.
Consider:
c:\some_file
c:\stuff_I_Link\some_file (created as a link to c:\some_file)

Under Windows, if I delete either file, the other remains.  It's just another location in the NTFS structure.
Under *nix, (soft links) the link is always a link.  If I delete \stuff_I_Link\some_file, just the link will go.  If I delete \some_file, the link will remain, but will be "broken".  It will appear in the directory, pointing to nothing.

A *nix HARD link, is different.  It links the files in a way such that if you delete one, you delete both.  They are much less used. :)

One reason you might want to use NTFS hard links is in a network environment.  Say have a java application that many people use.  For some reason, your (stupid) java developers require that a .jar file be in the user's home directory.  So you either have #users*jar files running around, or you create an NTFS hard link to the jar file in everyones directory.  The effect is this, everyone can see the required file in the right place.  The file takes up the space only 1 time.

How's that?  ;)
Insert Brilliant Sig line here

kimmchii

  • Honorary Member
  • Joined in 2005
  • **
  • Posts: 360
    • View Profile
    • Donate to Member
Re: soft and hard links in ntfs
« Reply #10 on: June 14, 2006, 07:52:20 AM »
this thread is getting more confuse. :down:
If you find a good solution and become attached to it, the solution may become your next problem.
~Robert Anthony

f0dder

  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 9,029
  • [Well, THAT escalated quickly!]
    • View Profile
    • f0dder's place
    • Read more about this member.
    • Donate to Member
Re: soft and hard links in ntfs
« Reply #11 on: June 14, 2006, 12:34:37 PM »
Rover: don't you actually mean that NTFS hardlinks are the equivalent of *u*x hardlinks? :) (if not using a protective program such as NTFSlink).

Btw., it was my impression that *u*x used reference counting for hardlinks, so that the data went pop only when you deleted the last filesystem entry referencing it?

jgpaiva: you don't need to format, check out the windows built-in tool "convert"... run it from a cmd.exe box.
- carpe noctem

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Donate to Member
Re: soft and hard links in ntfs
« Reply #12 on: June 14, 2006, 02:30:57 PM »
[/offtopic]I never got it, why do people say *nix, of *u*x, or something else instead of unix?[/offtopic]

jgpaiva: you don't need to format, check out the windows built-in tool "convert"... run it from a cmd.exe box.
Ok, that was a great tip! I had totally forgotten about that utility! Just used it, and it was just perfect. Thanks!  :Thmbsup: :Thmbsup:

mwb1100

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,522
    • View Profile
    • Donate to Member
Re: soft and hard links in ntfs
« Reply #13 on: June 14, 2006, 03:48:36 PM »
Here is a website that has good information on NTFS support for hard and soft links (Microsoft calls NTFS soft links 'Junctions' or 'reparse points'):

http://www.elsdoerfer.info/ntfslink/

It also has a Windows Explorer shell extension for dealing with these objects (I have not used the extension, so this post is no endorsement, just info).

Another clarification, the NTFS soft links (Junctions) are handled at a lower level than the 'Shortcuts' that the shell provides. A few differences:

  • shell shortcuts are files that contain the link infomration.  The shell and any application that uses shell APIs can handle these links transparently.  Other applications (like the command line) just see them as files.
  • Junctions are handled at the file system level, so every application handles them transparently, unless the application is specifically using file system APIs to identify junctions and handle them specially.  For example, the shell extension mentioned above and some back up applications wil handle junctions specially (to avoid backing up data twice, or endless loops of directory traversal).
  • Junctions support soft links for directories only - regular files are not supported.
  • shell shortcuts work on any file system; Junctions are only for NTFS

Rover

  • Master of Smilies
  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 630
    • View Profile
    • Donate to Member
Re: soft and hard links in ntfs
« Reply #14 on: June 14, 2006, 09:40:34 PM »
[/offtopic]I never got it, why do people say *nix, of *u*x, or something else instead of unix?[/offtopic]

*nix, is short for Unix and/or Linux (including BSD, AT&T Unix, and Solaris).
In other words, very generic unix and not vendor specific.
Insert Brilliant Sig line here
« Last Edit: June 15, 2006, 07:24:09 AM by Rover »

Rover

  • Master of Smilies
  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 630
    • View Profile
    • Donate to Member
Re: soft and hard links in ntfs
« Reply #15 on: June 14, 2006, 09:48:10 PM »
Rover: don't you actually mean that NTFS hardlinks are the equivalent of *u*x hardlinks? :) (if not using a protective program such as NTFSlink).

Btw., it was my impression that *u*x used reference counting for hardlinks, so that the data went pop only when you deleted the last filesystem entry referencing it?
 
Glad I check my stuff before I told you how wrong you are...cause you're not  :o  :huh:
Somewhere I got it in my head wrong.  *nix hard links work just the the NTFS counter parts.... or visa versa.  ;D

So, yeah, f0dder, what you said.
Insert Brilliant Sig line here

f0dder

  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 9,029
  • [Well, THAT escalated quickly!]
    • View Profile
    • f0dder's place
    • Read more about this member.
    • Donate to Member
Re: soft and hard links in ntfs
« Reply #16 on: June 15, 2006, 07:01:31 AM »
[/offtopic]I never got it, why do people say *nix, of *u*x, or something else instead of unix?[/offtopic]

*nix, is short for Unix and/or Linux (including BSD, AT&T Unix, and Solaris).
In other words, very generic unix and not vendor specific.


I've always though saying *nix when you mean "possibly linux" is a bit silly - linux would be "*nux". *u*x fits both "unix" and "linux"  :P

Both are a bit silly anyway, since there's other unix-like systems than linux, whose name isn't matched in *u*x. And setting up a regular expression that also matches BSD and VMS and friends, without being a simple alternation...

*big grin*  8)
- carpe noctem
« Last Edit: June 15, 2006, 07:03:05 AM by f0dder »

nudone

  • Cody's Creator
  • Columnist
  • Joined in 2005
  • ***
  • Posts: 4,117
    • View Profile
    • Donate to Member
Re: soft and hard links in ntfs
« Reply #17 on: June 15, 2006, 07:05:00 AM »
how do you pronounce *u*x ?

f0dder

  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 9,029
  • [Well, THAT escalated quickly!]
    • View Profile
    • f0dder's place
    • Read more about this member.
    • Donate to Member
Re: soft and hard links in ntfs
« Reply #18 on: June 15, 2006, 07:08:39 AM »
how do you pronounce *u*x ?
UGHz!

Kinda the sound you're making at 4 in the morning when the shizzle isn't doing as you want it to  8)
- carpe noctem

imtrobin

  • Charter Member
  • Joined in 2005
  • ***
  • default avatar
  • Posts: 125
    • View Profile
    • Donate to Member
Re: soft and hard links in ntfs
« Reply #19 on: June 16, 2006, 12:40:04 AM »
Hardlinks are only useful for files in the same partition. If they are on different partition, the file is still copied on both sides.

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Donate to Member
Re: soft and hard links in ntfs
« Reply #20 on: December 02, 2006, 07:46:51 PM »
Just keeping this thread updated...
Curt mentioned (in this thread) HardlinkShellExtension which looks like a pretty darn good app for creating hardlinks and such. It's got lots of updates and it's freeware :D

Hirudin

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 543
    • View Profile
    • Donate to Member
Re: soft and hard links in ntfs
« Reply #21 on: May 10, 2007, 03:56:00 PM »
Whoa! This creates a whole new world of file management I'd never known about before!
I am still a little fuzzy as to what each of these links do and/or how they differ: Soft Link, Junction, Symbolic Link. I think I've got a pretty good grasp on shortcuts though!

As for *x: I'd say it should be written as: *n*x
Seems to work the best for
*n*x
Linux
 Unix
I just don't like the fact that 1 of the asterisks must represent no characters if you use *u*x...
       * u* x
L  i  n  u  x
         Unix
^ is not very elegant
« Last Edit: May 10, 2007, 05:04:59 PM by Hirudin »

Hirudin

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 543
    • View Profile
    • Donate to Member
Re: soft and hard links in ntfs
« Reply #22 on: May 10, 2007, 06:46:21 PM »
OK, here's a visual representation of what I think Shortcuts (duh), Symbolic Links, and Hard Links (AKA Junctions) are... If it's not clear, the large gold/orange filled circle represents the hard drive, the blue ring is to represent the actual file.
The circle segment around the icon is to show that the file appears to be exactly the same.
Shortcut.pngSymlink.pngHrdlink.png
* Links Visualization 1.3.rar (60.34 kB - downloaded 168 times.) < This is the Paint.net file (with layers) that I used to create the images in case anyone wants to show what a Soft Link is/does...
[edit]Oh I see, both traditional shortcuts and symlinks ARE soft links...[/edit]

[modified]
- Added limitations to Hard Link image, updated rar to new "version 1.1".
- Changed Hard Link image a lil', updated rar file to 1.2.
- 1.3 (didn't mean to make so many changes...), changed icon on link of H.L.
[/modified]
« Last Edit: May 20, 2007, 08:18:04 AM by Hirudin »

cthorpe

  • Discount Coordinator
  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 728
  • c++thorpe
    • View Profile
    • Donate to Member
Re: soft and hard links in ntfs
« Reply #23 on: May 10, 2007, 07:09:55 PM »
I use links (junctions) extensively on my machine (probably 8-10 exist at this time).  I run FirstDefence-ISR and have my machine in a frozen state.  That means that when I reboot, everything reverts to that frozen state.  Installed programs disappear, registry settings vanish, and program configuration changes are undone.  Some programs, such as my broswer, have settings that I want to retain after rebooting.  Many times, I can tell the program to store its config info on a second partition that is not frozen.  Some programs, however, don't have that option.  I use links to get around that.

Let me illustrate with a made up program:

I have a program called Browser.  Browser does not let me change where it stores its bookmarks, cookies, history, saved passwords, etc.  It saves everything in Local Settings under Documents and Settings\My Username in a folder called Browserconfig.  Every time I reboot my computer, all of those things I just mentioned are gone.  What I can do, is exit Browser, move the entire Browserconfig folder to my D drive, and then create a ntfs link in Documents and Settings\My Username\Local Settings.  That link will look like Browserconfig to Browser, and all of my settings will be saved there, but they are actually being saved to my D drive.  I then freeze the system with that ntfs link in place, and my problem is solved.


Oh, and I use sysinternal's junction program to create links.

http://www.microsoft...ndDisk/Junction.mspx
« Last Edit: May 10, 2007, 07:38:10 PM by cthorpe »

umeca74

  • Member
  • Joined in 2006
  • **
  • default avatar
  • Posts: 47
    • View Profile
    • Donate to Member
Re: soft and hard links in ntfs
« Reply #24 on: May 29, 2007, 02:57:59 AM »
the various link flavors are useful but each comes with its own problems and limitations

  • shortcuts get in trouble if the real file is moved. Windows XP introduced the Distributed Link Tracking service that helps albeit introducing some extra overhead for all file operations
  • hard links are limited to files in the same partition. Also some programs (eg visual studio) destroy hard links when they save, so you have to watch out!
  • folder junctions can span partitions but only on the local hard disks, no networks. Be careful when you delete folder junctions, you may lose all the target folders. xplorer2 has a J attribute to identify junctions. Some people introduce a coloring rule on this attribute to make junctions stand out and prevent such accidents
  • vista's symbolic links... well i don't know much about them yet :)

xplorer2 can do most link types with its Edit | Paste special submenu. Vista symbolic links in a future version :)

hth
nikos