0

My shortlink which used to work suddenly is shown as broken after I restarted the PC having Ubuntu 22.04.2 LTS. I moved the "Documents" directory to another disk which is HDD and made a shortlink so that HDD location can be accessed by ~/Documents. Please see below:

$ ll ~/Documents 
lrwxrwxrwx 1 user user 20 Mar 26 22:36 /home/user/Documents -> /media/hdd/Documents

When I tried accessing the documents in HDD, it shows the following eror:

$ cd /media/hdd/Documents
bash: cd: /media/hdd/Documents: Too many levels of symbolic links

From GUI also, a similar error is shown:

This location could not be displayed. 
Sorry, could not display all the contents of "Documents": Error opening directory '/home/user/Documents': Too many levels of symbolic links

Suprisingly, I see an strange shortlink inside HDD, which I don't remember creating. See below, please:

$ ll /media/hdd/Documents
lrwxrwxrwx 1 user user 45 May 13 23:31 /media/hdd/Documents -> /home/user/../../../../../media/hdd/Documents

I don't know how the above shortlink created. Furthermore, there shouldn't be any shortlink inside HDD in the first place. Next, I tired updating the shortlink but no success:

$ ln -sfn /media/hdd/Documents /home/user/new_link

$ cd /home/user/new_link
bash: cd: /home/user/new_link: Too many levels of symbolic links

How to access the documents inside HDD? Additionally, the /etc/fstab is shown below:

$ cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/nvme0n1p5 during installation
UUID=fa9dfc51-436e-4717-b3be-0c0c561ad21d /               ext4    errors=remount-ro 0       1
# /boot/efi was on /dev/nvme0n1p1 during installation
UUID=BE66-E552  /boot/efi       vfat    umask=0077      0       1
/dev/disk/by-uuid/cb108681-34a7-4009-85de-4653cb4a5047 /media/hdd/ ext4 nosuid,nodev,nofail,x-gvfs-show 0 0
/swapfile none swap sw 0 0

1 Answer 1

0

Sorry to tell you but:

$ ll /media/hdd/Documents
lrwxrwxrwx 1 user user 45 May 13 23:31 /media/hdd/Documents -> /home/user/../../../../../media/hdd/Documents

DOES display the contents of "Documents" on your HDD. i.e. it is a file containing the symlink. Note that the "45" is the file size - the i.e. the number of characters in /home/user/../../../../../media/hdd/Documents.

You don't say how you moved your Documents to the HDD in the first place, but somehow you instead created a symlink. I assume you then deleted your /home/user/Documents and replaced it with the symlink to where you thought your documents now where, or did something else that isn't described in your question. The end result is you have created a symlink loop.

TL;DR: it looks to me like you've deleted your documents. Hope you have a backup.

7
  • Thank you very much. 1. I assume you then deleted your /home/user/Documents and replaced it with the symlink to where you thought your documents now where. Yes, thats right. 2. The end result is you have created a symlink loop. That is suprising to me as I did not create this symlink. Furthermore, you can see the symlink ~/Documents -> /media/hdd/Documents was created on 20th March and was working fine till today. However, after restarting the PC todday, it shows broken link.
    – ravi
    May 16 at 4:47
  • I assume it was created by whatever you used to move your Documents to the HDD - you still don't say how you did that. That link is odd either way with the all "../" in there - not something I would expect to see from a link created by a tool. May 16 at 5:19
  • you still don't say how you did that. Thank you and sorry for the delay. I replied above. I copied documents to /media/hdd/Documents, deleted the existing ~/Documents and then made a shortlink via ln -s /media/hddDocuments ~/Documents. Thats all, I did. Infact it was working before as said previously
    – ravi
    May 16 at 7:11
  • You need to provide specifics if you want to determine how you got into that state. Exactly what commands or tools did you use? But if your actual interest is in recovering your documents then that is another problem. May 16 at 8:52
  • Exactly what commands or tools did you use? Ubuntu terminal
    – ravi
    May 16 at 9:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .