0

There is an existing directory called /home containing some files. I have mounted a partition on this directory using /etc/fstab

UUID=10CD7304CE71E381   /home      ntfs    defaults        0       2

Nothing wrong so far.

How do I access the original content of /home without unmounting anything. Obviously, I cannot unmount the mounted /home partition.

0

Simple answer: use a live system.

If another partition has been mounted on your root's /home, indeed you cannot simply unmount it, or even re-bind the mount. However, a live system has it's own /home/ arranged for and doesn't use the partition that normally provides your root filesystem. So on the live system, simply mount your root filesystem and you can access the original /home directory from there.

Finding a live system shouldn't be difficult, because there are quite a few distributions that provide a live CD image that you can burn on CD, or put on a USB drive to boot from there. Some of the distributions that offer this are Debian, Knoppix and MX Linux.

| improve this answer | |
0

On Linux, you can do it by unmounting that directory in a separate mount namespace with its mount propagation flag set to private:

# truncate -s 3G blob
# mkfs.ext4 blob
...

# mkdir dir
# echo below > dir/file

# mount blob dir
# echo above > dir/file

# cat dir/file
above

# unshare --mount --fork --propagation private sh -c 'umount dir; cat dir/file'
below

# cat dir/file
above

# unshare --mount --fork --propagation private sh -c '
   umount dir
   for f in dir/file /dev/fd/7; do
       realpath --relative-to=. "$f"; cat "$f"
   done
' 7<dir/file
dir/file
below
dir/file
above

Note: the --propagation private flag is the default, at least with recent versions of unshare(1): I have added it just for emphasis.

| improve this answer | |

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.