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.
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?