0

Is it possible to create a link in an exfat partition in linux? I wanted to create a link to a file deep in some folders and "ln -s" doesn't work because exfat doesn't support symlinks. changing the filesystem is not possible.

4 Answers 4

3

Exfat does not support symlinks. You cannot create one.

3
  • I don't need a symlink. windows can create shortcuts in exfat, is there any other way in linux to create a link in linux other than symlinks? Oct 5, 2017 at 15:03
  • 4
    A symlink and shortcuts are entirely different beast to a symlink. A symlink is a construct of a filesystem, while a shortcut is a file interpreted by the GUI.
    – davidgo
    Oct 5, 2017 at 15:33
  • a Windows shortcut is like a Linux's .desktop file. The shortcut file just contains the path and doesn't point to anything and can exist even if the source file has been deleted
    – phuclv
    Oct 5, 2017 at 15:54
1

Possible workaround:

touch /shallow/file
sudo mount --bind /deep/into/directory/tree/file /shallow/file

Disadvantages:

  • Needs sudo.
  • Works on OS level, not on filesystem level. After every reboot you need to repeat mount to use this "link"; or edit your /etc/fstab to make this solution permanent.
2
  • you can add mount to the nopasswd sudo list and define mount as an alias to sudo mount. Now you don't need any password for mounting
    – phuclv
    Oct 5, 2017 at 15:55
  • @phuclv this will effectively provide everybody with root rights, as mount is an unsafe operation - you can bind-mount something you shouldn't have accessed, override uid/gid, do other nasty things.
    – toriningen
    Oct 26, 2018 at 6:28
1

I don't appear to have any problems creating a symlink with ln -s on my exFAT partition running Ubunutu Server 20.04

mdkir foo
cd foo
echo hi > bar
ln -s bar baz
echo ho > baz

cat bar

ho

ls -l

-rwxrwxr-x  1 x x    3 Apr 11 13:13 bar*
lrwxrwxr-x  1 x x    3 Apr 11 13:13 baz -> bar*
5
  • ln: failed to create symbolic link 'baz': Function not implemented
    – grabantot
    Apr 20, 2021 at 18:13
  • @grabantot my guess is it depends on ntfs-3g, I did this running stock Ubuntu 20.04 server. Looking at ntfs-3g there appears to be an implementation for symlinks and junctions jp-andre.pagesperso-orange.fr/junctions.html Under which circumstances did it fail for you?
    – CervEd
    Apr 21, 2021 at 8:18
  • It failed for exFAT on manjaro (don't have it at hand, can't get more details). You were talking about exFAT in the response, but in the comment you mention ntfs-3g - is there a mistake?
    – grabantot
    Apr 22, 2021 at 9:16
  • @grabantot ah, yes, my bad. I confused myself. In Ubuntu 20.04 there should be support for exFat in the kernel. I'll try and get some more details on my system. Might be helpful for others if you could contribute your Manjaro/kernel version
    – CervEd
    Apr 22, 2021 at 9:25
  • It is working on MacOS Monterey.
    – rodvlopes
    Feb 5 at 23:41
0

Thoughts:

  • You could try using a hard link, though I'm not sure it'll work.

  • You could create the symlink on a non exfat drive and have the target point to a file on the exfat drive, since soft links can cross drive boundaries.

  • If you have no other drive to implement the above, you could even create a small ext4fs system using "mke2fs", loop mounting it, and then linking from it to the exfat system.

  • If you create a shortcut in Windows, Linux may see it as a '.lnk' file, but you won't be able to use it like a symbolic link.

2
  • 1
    according to this exFAT supports neither softlink or hardlink
    – phuclv
    Oct 5, 2017 at 15:58
  • 1
    Linux will always see the *.lnk file as it's just a normal file like any other files. It's completely different from softlink or hardlink in Windows
    – phuclv
    Oct 5, 2017 at 15:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.