softlink vs hardlink

Difference between softlink and hardlink on a ext2 fs.

    The ext2 filesystem has a table called MFT(Master File Table).
        This is the table that holds inode(hexadecimal short addresses, that point(mapped) to a block of HD memory.)
        This is also the table that is created during FS creation, unless am mistake, it is also modified during tune2fs modifying block sizes.
    
    Anyway, to get to the point, softlinking to a file maps an unassigned inode to the existing files inode.
    On the other hand Hardlinking just creates a pointer to that inode in the hardlink directory’s entry.

    A simple look:
        Here’s a file i created with touch and it’s inode:
             ls -li test_link
             29886232 -rw-r–r– 2 root root 0 Oct 11 21:16 test_link
        
        Here’s the output for a  symlink:
            ls -li link1
            29886233 lrwxrwxrwx 1 root root 9 Oct 11 21:16 link1 -> test_link

        Here’s the output for a hardlink:
            ls -li link2
            29886232 -rw-r–r– 2 root root 0 Oct 11 21:16 link2

If you look at the first column of the output, then you’ll see that it is the same for hardlink and the file.
This is the actual inode value in MFT.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s