1

On 7/17/17 @bingbomboom asked this question about creating a permanent /etc/fstab entry for an external drive. My head spun thinking about this next question. Instead of hijacking its thread, I'm starting fresh. I'm not focusing on re-establishing connectivity for the external drive—I'm wondering about what happens to existing files on the internal drive.

Suppose I have an internal drive on an iMac for my Documents with a file int.txt. I have an external drive with a file ext.txt, at its root. Both files are accessible.

If I mount the external drive's root at my internal drive's Documents location, what happens to int.txt? It's an interesting grey area to me that makes my head spin. The file int.txt used to be in the Documents folder, but if I point to Documents to see what's there, MacOS now logically points to the root of the external drive and my brain tells me int.txt will disappear and I'll only be able to see ext.txt.

Meanwhile, I can't imagine int.txt quietly disappears as in it gets deleted, so it has to be safe, somewhere, but… where?

Does it go into some form of digital limbo? How do I access it now?

Then, when I unmount the directory, will int.txt still be there?

Something tells me that a particular instance of the ls or cp or mv commands invoke the file's physical location and not its logical location, and that that logical vs. physical difference is the additional awareness that will stop my head from spinning.

I'm just looking for someone smarter than me to set me straight. Thanks.

2
  • How deep into Unix file handling do you want to go? At a surface level things are very simple and I’ve answered that. The only wrinkle is if you want to consider what happens if a program has a file open and then you use another process to change the file (say rm or mount over the directory).
    – bmike
    Commented Mar 17 at 16:20
  • 1
    What happens to int.txt depends on whether the union option is specified when mounting. When I tested with the union option using APFS volumes, I was able to read and remove int.txt, but was not able to write to int.txt. Attempting a write resulted in the creation of a new int.txt file on the external drive. This new file then masked the int.txt file on the internal drive. Commented Mar 17 at 19:38

1 Answer 1

1

When you mount a new file system over an existing path everything on the previous path still exists, but is not accessible until you remove the mount.

I’m not entirely sure what your deeper question or missing part is, but the mounting process is clear and basic. As an analogy, think of a paper chessboard and post it notes that cover 4 squares. You can write whatever you want on the board. For those four squares (Documents in your case), when you mount the post it note on top, you can’t directly see or access the old scribbling until you remove the post it note. Whatever is on the note or gets written on the post it note stays on that note and doesn’t change what’s underneath.

You must log in to answer this question.

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