Ubuntu 重新启动后短链接损坏。符号链接级别过多

Ubuntu 重新启动后短链接损坏。符号链接级别过多

当我重新启动装有 Ubuntu 22.04.2 LTS 的电脑后,我以前可以正常工作的短链接突然显示为损坏。我将“Documents”目录移动到另一个磁盘(HDD)并创建了一个短链接,以便可以通过~/Documents.请看下面:

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

当我尝试访问硬盘中的文档时,显示以下错误:

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

GUI 中也显示类似的错误:

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

令人惊讶的是,我在硬盘中看到一个奇怪的短链接,我不记得创建过它。请看下面:

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

我不知道上面的短链接是如何创建的。此外,HDD内部首先不应该有任何短链接。接下来,我厌倦了更新短链接,但没有成功:

$ 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

如何访问硬盘内的文件?另外,/etc/fstab如下图所示:

$ 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

很遗憾地告诉你,但是:

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

确实显示硬盘上“文档”的内容。即它是一个包含符号链接的文件。请注意,“45”是文件大小 - 即 中的字符数/home/user/../../../../../media/hdd/Documents

您没有说明您最初是如何将文档移动到硬盘的,但不知何故您创建了一个符号链接。我假设您随后删除了 /home/user/Documents 并将其替换为您认为文档现在所在位置的符号链接,或者执行了问题中未描述的其他操作。最终结果是您创建了一个符号链接循环。

TL;DR:在我看来你已经删除了你的文档。希望你有备份。

相关内容