Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question

migrated from stackoverflow.com May 19 '10 at 9:59

This question came from our site for professional and enthusiast programmers.

    
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 '10 at 9:59
    
Thanks Pekka. I'll wait a while. –  smwikipedia May 19 '10 at 10:03
    
@Pekka - it is not programming related, and in my opinion a very good question for Super User. –  Gnoupi May 19 '10 at 16:04

4 Answers 4

up vote 5 down vote accepted

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

share|improve this answer

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.

share|improve this answer
    
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. –  smwikipedia May 19 '10 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 '10 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? –  smwikipedia May 19 '10 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 '10 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. –  smwikipedia May 20 '10 at 4:03

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.

share|improve this answer
    
Thanks petersohn. You give me much more than I expect. It's very informative. Many thanks. –  smwikipedia May 19 '10 at 13:07

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.

share|improve this answer
    
Concise and right-on-target. Many thanks. –  smwikipedia May 19 '10 at 13:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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