3

On my network, I have a disk on my other computer running Ubuntu (both computers with 18.10) mounted to /home/username/Storage via nfs in fstab. That fstab line looks like,

192.168.2.33:/otherhome/otherusername /home/username/Storage nfs rsize=8192,wsize=8192,timeo=14,intr

On that other computer, I have a file that I want to symlink so I can open it from an icon on my current desktop. So I do ln -s /home/username/Storage/file /home/username/Desktop. It works fine until I reboot. Then it says the link is broken, although it lists the correct target if I right-click and look at the properties.

Is there a way to keep a symlink to a file on a mounted network disk after reboot? Am I doing it wrong?

ticotexas
  • 719
  • 1
    Try ls -Ld /home/username/Desktop/file. If it says ls: cannot access /home/username/Desktop/file: No such file or directory, the link is broken. Otherwise I think the desktop is not updating when the drive is mounted. Try clicking the desktop then pressing F5 or Ctrl+R to refresh it, or try logging out and back in. – wjandrea Jan 19 '19 at 23:17
  • @wjandrea Thanks, you were right. F5 worked. Is there a way to have the desktop refresh automatically after the drive is mounted? – ticotexas Jan 20 '19 at 18:07
  • 1
    My research didn't turn up much. My only recommendation is to edit the question title to clarify the issue, cause it seems like the symlink is actually surviving, but the desktop thinks its broken, maybe because the mount is slower than the desktop on startup. – wjandrea Jan 21 '19 at 17:03
  • @wjandrea as requested ;-) – Rinzwind Jan 21 '19 at 17:36
  • 1
    refreshing desktop: https://askubuntu.com/questions/518971/command-line-command-to-refresh-gui-desktop-like-when-pressing-f5 you need to kill nautilus. – Rinzwind Jan 21 '19 at 17:43

1 Answers1

1

Is there a way to keep a symlink to a file on a mounted network disk after reboot? Am I doing it wrong?

Nope. You can re-create the link on reboot if you want. But the more logical method would be to use the bind option from mount. From man page:

Bind mount operation
   Remount part of the file hierarchy somewhere else.  The call is:

          mount --bind olddir newdir

   or by using this fstab entry:

          /olddir /newdir none bind

   After this call the same contents are accessible in two places.
Rinzwind
  • 299,756
  • Are you suggesting to bind the network drive already mounted to a duplicate/redundant location and then symlinking the file there? Wouldn't that be the same as what I'm doing? I don't think you can bind a file, can you? – ticotexas Jan 22 '19 at 01:30
  • You bind a directory not a file. "and then symlinking the file there" No symlinking needed; you use the "newdir" as the location you want to see on the desktop.So you get an directory icon on your desktop. – Rinzwind Jan 22 '19 at 07:51