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
Exfat does not support symlinks. You cannot create one.
-
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
-
4A 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.– davidgoOct 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– phuclvOct 5, 2017 at 15:54
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.
-
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– phuclvOct 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. Oct 26, 2018 at 6:28
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*
-
ln: failed to create symbolic link 'baz': Function not implemented
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?– CervEdApr 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 aboutexFAT
in the response, but in the comment you mentionntfs-3g
- is there a mistake? 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– CervEdApr 22, 2021 at 9:25 -
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.
-
1
-
1Linux 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– phuclvOct 5, 2017 at 15:59