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?

3
  • 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 Aug 24, 2023 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, 2023 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: unix.stackexchange.com/questions/731609/… You sadly have no other choice, since NTFS doesn't have the functionality you want. Aug 24, 2023 at 17:27

1 Answer 1

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.

5
  • 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, 2023 at 19:01
  • I think what you're clicking on might not be symlinks, but maybe windows links? Aug 24, 2023 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, 2023 at 21:18
  • interesting! Didn't know that works. Or, used to work! Aug 24, 2023 at 21:47
  • So I tried mksquashfs, and it worked, thank you!
    – Wolfhart
    Aug 26, 2023 at 4:35

You must log in to answer this question.

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