0

I am moving my files from one computer to another via an external hard drive formatted with NTFS. I have a folder called "library" with many PDFs. This folder contains quite a few symlinks since some PDFs (i.e., books or articles) belong to several categories (i.e., folders). The problem that I am facing is that I cannot get the files onto my new computer with the symlinks intact (i.e., without them being dereferenced). I was able to copy the folder from the old computer to the external hard drive with the symlinks intact with the command cp -a. But when I use the same command to copy the files from the hard drive to the new computer, the symlinks are dereferenced (i.e., replaced with the file they refer to). I also tried cp -r --preserve=all, with the same result. So which command do I need to use to get the symlinks from the external hard drive onto my new computer? Asked differently, why does cp -a leave the symlinks intact when copying to the external hard drive, but not in the other direction? I'm on Ubuntu 22.04, in case that is relevant.

EDIT:

I just noticed that, when I connect the hard drive to the old computer (which is running Ubuntu 16.04), the symlinks on the hard drive are displayed as links and work as such (i.e., clicking on them opens the referred-to PDF file), whereas, when I connect the hard drive to the new computer (which is running Ubuntu 22.04), the symlinks are not displayed as links (but as PDF files) and do not work (i.e., when clicking on them, Document Viewer emits the error message File type unknown (application/octet-stream) is not supported; that is, Document Viewer tries to open them as PDF files rather than following the link). Why this different behavior of the two versions of Ubuntu?

  • I am moving my files from one computer to another via an external hard drive formatted with NTFS. meeep. wrong file system for unix files. Either put all your files in an archive on that NTFS; or just use a different file system – Marcus Müller Aug 24 '23 at 16:56
  • @MarcusMüller: The hard drive is supposed to serve also as a backup accessible from other types of operating system, hence NTFS. – Wolfhart Aug 24 '23 at 17:17
  • then it's an archive. tar works, but also mksquashfs. tar being more commonly installed, and mksquashfs allowing for smaller size and for actually using the files inside without unpacking. see this: https://unix.stackexchange.com/questions/731609/difference-between-ar-tar-gzip-zip-and-when-should-i-decide-to-choose-which-o/731610#731610 You sadly have no other choice, since NTFS doesn't have the functionality you want. – Marcus Müller Aug 24 '23 at 17:27

1 Answers1

0

NTFS can't do what you want it to do.

Hence, you can't store the things directly on NTFS.

You need to use an archive where you put in the files you want to transport. then it's an archive. There's multiple options (really, realistically, two): tar works, but also mksquashfs, tar being more commonly installed, and mksquashfs allowing for smaller size and for actually using the files inside without unpacking. I wrote an answer where I compared and illustrated usage.

You sadly have no other choice, since NTFS doesn't have the functionality you want.

  • But the symlinks are there on the NTFS hard drive and work when I connect the drive to the old computer (but not when I connect it to the new computer; see the edit of my question). Do you understand why the two versions of Ubuntu behave differently in this regard? – Wolfhart Aug 24 '23 at 19:01
  • I think what you're clicking on might not be symlinks, but maybe windows links? – Marcus Müller Aug 24 '23 at 20:33
  • I am clicking on what the Ubuntu file manager shows me. Windows (the operating system) was not involved at all in this. The files are symlinks that were created in Ubuntu (from the file manager with the Make link command in the context menu of a file). – Wolfhart Aug 24 '23 at 21:18
  • interesting! Didn't know that works. Or, used to work! – Marcus Müller Aug 24 '23 at 21:47
  • So I tried mksquashfs, and it worked, thank you! – Wolfhart Aug 26 '23 at 04:35