Random Wisdom

Tag: filesystem

Create links with absolute paths in Linux

by on Jan.16, 2010, under How To ..., Linux, Software

The default behaviour of the linking command (ln) is a little strange under certain circumstances. Since it creates the links using the literal value of the target, symbolic links created using relative path structures can often fail. Consider the following:

$ ln -s targetfile ../src/targetfile_link

Without a doubt, ‘targetfile_link’ will be a broken symlink since it links to a target that it assumes is in the same directory:

$ cd ../src && ls -l targetfile_link
lrwxrwxrwx 1 mafgani mafgani 5 2010-01-16 18:19 targetfile_link -> targetfile

This is quite unfortunate since it clearly clashes with the way that the linking mechanism should work intuitively.

The solution is to force ln into automatically appending the absolute path to the target files. This can be achieved by using a simple shell script that acts as a wrapper for the real linking command:


# Step through the supplied arguments and append the absolute
# path to targets that exist
for ARG in $@
  if [ -e $ARG ]; then
    LNARGS="${LNARGS} ${PWD}/${ARG}";
    LNARGS="${LNARGS} ${ARG}";

# Execute the actual link command with the modified args
exec /bin/ln ${LNARGS};

There are two known caveats:

  • The link is ‘sub-optimal’ if created from within the destination directory (the absolute path contains ‘../’s). It will still work however.
  • The links will always be absolute. If that is undesirable, save the script as ‘absln’ or something other than ‘ln’.

Using ‘absln’ instead of ‘ln’ in the previously described scenario now produces a working symlink:

$ absln -s targetfile ../src/targetfile_link
$ cd ../src/ && ls -l targetfile_link
lrwxrwxrwx 1 mafgani mafgani 16 2010-01-16 19:13 targetfile_link -> /tmp/files/targetfile
1 Comment :, , , , , more...

Cross-platform filesystem access

by on Nov.21, 2006, under How To ..., Linux, Software

Looks like the ntfs-3g driver has already gained a lot of popularity and is quite easy to use:

NTFS-3G Read/Write Driver

The driver itself is supposedly available from the Fedora Extras repository for FC6 onwards. Completely safe read/write access to NTFS drives from Linux — now that’s a dream come true!

In the meanwhile, it looks like there’s also a windows Ext2 file-system driver that allows full read/write access to Ext2/3 volumes:

Ext2 Installable File System For Windows

Of course, one of the drawbacks here is that the Ext3 volume is mounted as Ext2 — so there is no journaling support. In case of a ‘dirty’ unmount e2fsck will have to be run. The other drawback is the fact that is won’t work with LVM.

So, these drivers really open up a lot of choices. But I guess the best option is to have the shared drive as NTFS since the ntfs-3g driver takes care of journaling.

Leave a Comment :, , , , , more...

Finally, NTFS write support!

by on Jul.16, 2006, under Linux

Slashdot ran a story yesterday about the new fully open source NTFS driver that has full read and write support for NTFS volumes. Although still in BETA phase it looks really promising. Too bad it doesn’t work on 64-bit systems yet. I’m definitely keeping my eyes peeled for this one ..

More details and download links here:

[announcement] ntfs-3g: open source read-write driver

Leave a Comment :, , more...