1

My /home partition is on /dev/sda1. My / partition is on /dev/sda2.

Whenever I make a file in /home partition it shows up in / partition under the /home directory.

The Windows equivalent is to make a file on the D drive and the file is also visible on C drive.

How is this possible ?

closed as unclear what you're asking by Christopher, DopeGhoti, Rui F Ribeiro, Thomas, slm Jun 10 at 1:05

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    This is the philosophy of UNIX/Linux filesystems. And even in Windows you can mount disk D to appear as directory to disc C – Romeo Ninov May 30 at 15:34
  • Kernel will record all the mounts, when you access some path, it will calculate which filesystem you're accessing and do operation on it. See /proc/self/mountinfo – 炸鱼薯条德里克 May 30 at 22:20
  • Windows Also use similar structure, except Win32 doesn't expose the same API – 炸鱼薯条德里克 May 30 at 22:32
3

If your filesystem experience today is based in Windows, or single disk/partition systems, then you may not be used to the concept of mountpoints. (though Windows now supports mounting disks at a mount path now, too, it's not as common there as in Linux/Unix)

Your filesystem in Linux/Unix is a nested hierarchy of files. (folders are files, too..)

You start with /. The root of everything. In your case, this is on partition /dev/sda2. With /home on /dev/sda1, you end up with

  • /
    • dev/
      • pts/
      • (stuff)
    • sys/
    • home/
      • rebecca/
        • txtfile.txt
      • bob/

etc. (there are a lot more directories, this is just an example)

So, the path from / -> /home/rebecca/textfile.txt is intended to be as transparent as possible. So, while it appears that textfile.txt is in the / partition, it's actually not. It's in the /home/ partition. It's just that that partition is mounted in the / directory as /home.

Try these three commands:

  • df /
  • df /home/
  • df /home/rebecca/textfile.txt <-- use a real path to a file

The df command will show you all your filesystems, real and virtual, that are mounted on your system at the time you run the command. Using df as I have in the examples above serves to filter the output to allow you to examine fewer things at a time.


TL;DR - it's how Unix and Linux mountpoints work to make all your various disks appear together to be a single cohesive file and directory tree.

2

In a POSIX filesystem, everything exists somewhere inside of the root of the filesystem, located at /. On your root partition, which you have mounted at /, you have a directory, /home. This directory is (presumably) being used as a mount point (i. e. the location at which a mounted filesystem such as a partition resides) for the home partition. Files created there are being created in the home partition, the contents of which are visible at that partition's mount point.

Notwithstanding the issues caused by making the contents of /home disappear, if you were to:

# umount /home; mount /dev/sda1 /mnt; ls /mnt

You would see the contents of what had been in /home, now visible at /mnt.

Don't actually do this; this is a demonstrative thought-experiment.

You can see a list of which filesystems are mounted at which mount points by observing the output of the mount command when given no parameters.

1

The filesystem (partition) containing your own files can be placed anywhere in the filesystem tree, which starts as /. Typically it's placed at /home and you have a directory in it that is named as your username. For example, you might have /home/rebecca.

UNIX-based systems (including Linux-based ones) use a single rooted filesystem (/). Windows systems use a multi-rooted filesystem (C:, D:, etc.).

When you write a file to a location you usually don't need to worry about which partition it's being written to, as long as there is enough disk space to hold the file's content.

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