3

I read the manual page of the "mount" command, which reads as below:

All files accessible in a Unix system are arranged in one big tree, the file hierarchy, rooted at /. These files can be spread out over several devices. The mount command serves to attach the file system found on some device to the big file tree.

My questions are:

  • Where is this "big tree" located?

  • Suppose I have 2 disks, if I mount them onto some point in the "big tree", does Linux place some "special marks" in the mount point to indicate that these 2 "mount directories" are indeed separate disks?

2
  • Actually, on second thought, I don't think this should have been migrated from SO. It is a question about the internal structure of Linux, and neither server nor PC related really. If you don't get any feedback here, try asking again, maybe with slightly more abstract wording.
    – Pekka
    May 19, 2010 at 9:59
  • @Pekka - it is not programming related, and in my opinion a very good question for Super User.
    – Gnoupi
    May 19, 2010 at 16:04

4 Answers 4

6

You will get more information about this on Mount man pages.

Regarding the first question, How the big tree looks like :)

enter image description here

6

Where is this "big tree" located?

It is located at / :-). The "big tree" refers to the fact that linux only has a single, system-wide file hierarchy (which starts at / ). This is in contrast to e.g. MS-DOS and MS Windows, which can have several file hierarchies (one per drive letter).

Suppose I have 2 disks, if I mount them onto some point in the "big tree", does linux place some special marks" in the mount point to indicate that these 2 "mount directories" are indeed seperate disks?

No, there are no "special marks" in the mount points themselves. However, the kernel keeps track of which actual filesystem (hard drive) is mounted at which point, so it knows where to actually read data from when you access a file such as /usr/local/bla/blo/xxx. This information can be viewed by e.g. running mount, which lists all mounted filesystems, along with their current mount point in the file hierarchy.

7
  • Thanks sleske. Perhaps I didn't express it clearly. I want to know where I should store the "big tree" physically. My initial plan is to allocate a primary partition as small as possible to hold the "big tree" and allocate some more logical partitions to hold different folders, such as "/user". And then mount these logical partitions onto proper point of the "big tree". In other words, it's kind of like "a small primary partition leads several big logical partitions". How about this scheme? Thanks. May 19, 2010 at 12:59
  • @smwikipedia: That scheme is very common. Disk partitioning and allocation ranges from two big slices (for file system and swap) to multiple partitions on each local disk. Note that network pseudo-disks are also mounted in the "big tree" -- you may want to try "man hier" or "man hierarchy" for an introduction into the general layout. Basically, you can separate out any directory and below as a mount point for another disk.
    – mpez0
    May 19, 2010 at 13:18
  • Thanks mpez0. In my initial scheme, the leaves of the "big tree" could point to anywhere, but where is the "big tree" itself, physically? The "big tree" itself is nothing but a data structure. It contains physical data. Is it in memory? Or is it in the partition where the "/" is mapped to? May 19, 2010 at 13:50
  • The filesystem is a virtual graph, for which different nodes are stored on different places. When you read a directory, the system will look up where it is mounted, and act accordingly. "/" is usually stored on your hard disk. The mountpoints are in your memory. For example, "/usr" is on the same partition, then there is no mountpoints that point there, so it will read the directory contents from the disk. Now "/home" is on a different partition, so the system will find a mountpoint that points there, and read the root directory from that partition.
    – petersohn
    May 19, 2010 at 17:13
  • Thanks for your comment petersohn. In your words, you said "When you read a directory, the system will look up where it is mounted, and act accordingly". I just want to know where the "information" which is looked up by the system is stored physically? On whcih partition? The same partition as the "/"? In fact, this "information" is what I mean by the phrase "big tree" indeed. May 20, 2010 at 4:03
3

If you type in mount without arguments, it will tell you what directory is mounted and where. For example, if the answer is /dev/sda1 on / type ext3 (rw), it means that the root directory of the first partition on your first hard disk is actually the root of your "big tree".

Now let's say that you also get the line /dev/sdb1 on /home type ext3 (rw). It means that the contents of your /home directory will be the root directory of the first partition on your second hard disk. There can be other, virtual file systems that doesn't exist in any partition, but dynamically managed by the system. For example, you boot from a live CD, and mount the partition that is used as a system partition. Let's say, you type.

mkdir /media/system
mount /dev/sda1 /media/system

Now, you will see the root directory of your system (that you use regularly, not what you are booted into with the CD) in /media/system. You will also see that directories like dev are empty, because they usually contain a virtual filesystem.

If you are asking how does the system decide where this partition is, it is all written in /etc/fstab. Type man 5 fstab if you want some more information about this. Yes, I know there is a chicken-egg problem here, because the system has to find /etc/fstab (and /sbin/mount, for that matter) before mounting the directories. The answer is, I don't know, but it works pretty well.

EDIT: I may add that all partitions have a unique identifier called UUID. You can mount using this identifier by typing mount -U uuid_of_partition /media/mount_point. It is usually done this way in /etc/fstab, to avoid the problem that, for example, you change the disk order in your machine.

1
  • Thanks petersohn. You give me much more than I expect. It's very informative. Many thanks. May 19, 2010 at 13:07
2

Where is this "big tree" located?

On your computer. Seriously. All the disks added together, plus all the in-memory devices and pseudo-devices, terminals, modems, everything forms a big tree called "the file system" which is your computer.

Suppose I have 2 disks,... does linux place some "special marks" in the mount point to indicate that these 2 "mount directories" are indeed seperate disks?

Yes.

0

You must log in to answer this question.

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