Yesterday I moved my home directory from the root partition to another partition following the steps here. Basically copied all files to the new partition and added a new fstab entry with the partition UUID and /home mount point, and restarted the system.

Everything worked as expected, but my question is, what happen to the old folder and files? /home now points to a new partition and it seems the old files just "disappear".



The new filesystem (/home) is mounted over the directory (/home) on the original filesystem. So the files are still there, but they are hidden from simple access.

To avoid this, you would need to add some steps to your process.

Namely, rename the /home directory after creating a copy of the content. Then, create a new empty directory /home as the new mount point. Then when you mount the /home filesystem it's being mounted over an empty directory and you can still get to the /oldhome directory (or whatever you called it).

  • I think the process should work, but as I have already done the previous one, I'll mark zagrimsan's answer as correct.
    – Andrés
    Jan 14 '16 at 14:19
  • @Andrés not a problem, we're both saying the same thing - filesystems mount over directories, obscuring the entire file and directory structure under the point they're mounted. It's a common point of confusion for people new to filesystem mount points. Jan 14 '16 at 14:59
  • The two answers are essentially the same but I'm up-voting this one because it takes the extra precaution of making a backup of the data before deleting it. I understand the data has already been copied to the new device but the copy could be used to run a checksum test or whatever.
    – Stephen C
    Jun 23 '17 at 20:46

If you copied the files to the new partition but didn't delete them from the root partition, the old ones are masked or hidden by mounting the new partition on top of them. In that case, you should still have the same amount of root partition being in use, no space being freed. Unless we both missed that part, deleting the old copies is not included in the instructions you linked.

I'm quoting here a good answer on the subject:

When you mount a filesystem on a directory /mount-point, you can no longer access files under /mount-point directly. They still exist, but /mount-point now refers to the root of the mounted filesystem, not to the directory that served as a mount point, so the contents of this directory cannot be accessed, at least in this way.

The most straight-forward way to straighten this out is, of course, by umounting the new /home (in order this to succeed, no files from /home must be in use, meaning only root can be logged in), then you'll see the old files (which occupy root partition) and can delete them to free space in the root partition (but do double-check that the new partition is not mounted before really deleting anything). You should probably delete everything under the old /home, not just the contents within the user directories.

  • This is exactly what happened, thank you! May I ask you to add a reference to further reading about this masked files behavior? I didn't really know this could be done.
    – Andrés
    Jan 14 '16 at 14:16
  • @Andrés, I added some information on the "hiding" of files and a link to further explanation.
    – zagrimsan
    Jan 15 '16 at 16:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.