Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have 2 questions.

  1. During Linux installation we specify memory space for 2 mount points - root and swap. Are there any other mount points created without the users notice?
  2. Is this statement correct: "mounting comes into the picture only when dealing with different partitions. i.e, you cannot mount, say, /proc unless it's a different partition"?
share|improve this question

migrated from stackoverflow.com Apr 26 '11 at 12:14

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

1  
+1 for question title! If all newbies asked so innocently... –  Caleb Apr 26 '11 at 12:41
    
Haha, exactly my thoughts too! +1. –  boehj Apr 26 '11 at 13:22
2  
@John: Asking two questions in one is not recommended. Since there are now answers that cover both questions, I guess we'll let it slide, but please ask separate questions separately next time. Your difficulty finding a good title (no, your title wasn't a good summary of your question) was due to trying to combine multiple questions into one. –  Gilles Apr 26 '11 at 22:50

2 Answers 2

up vote 23 down vote accepted

There are misconceptions behind your questions.

  1. Swap is not mounted.
  2. Mounting isn't limited to partitions.

Partitions

A partition is a slice¹ of disk space that's devoted to a particular purpose. Here are some common purposes for partitions.

  • A filesystem, i.e. files organized as a directory tree and stored in a format such as ext2, ext3, FFS, FAT, NTFS, …
  • Swap space, i.e. disk space used for paging (and storing hibernation images).
  • Direct application access. Some databases store their data directly on a partition rather than on a filesystem to gain a little performance. (A filesystem is a kind of database anyway.)
  • A container for other partitions. For example, a PC extended partition, or a disk slice containing BSD partitions, or an LVM physical volume (containing eventually logical volumes which can themselves be considered partitions), …

Filesystems

Filesystems present information in a hierarchical structure. Here are some common kinds of filesystems:

  • Disk-backed filesystems, such as ext2, ext3, FFS, FAT, NTFS, …
    • The backing need not be directly on a disk partition, as seen above. For example, this could be an LVM logical volume, or a loop mount.
  • Memory-backed filesystems, such as Solaris and Linux's tmpfs.
  • Filesystems that present information from the kernel, such as proc and sysfs on Linux.
  • Network filesystems, such as NFS, Samba, …
  • Application-backed filesystems, of which FUSE has a large collection. Application-backed filesystems can do just about anything: make an FTP server appear as a filesystem, give an alternate view of a filesystem where file names are case-insensitive or converted to a different encoding, show archive contents as if they were directories, …

Mounting

Unix presents files in a single hierarchy, usually called “the filesystem” (but in this answer I'll not use the word “filesystem” in this sense to keep confusion down). Individual filesystems must be grafted onto that hierarchy in order to access them.³

You make a filesystem accessible by mounting it. Mounting associates the root directory of the filesystem you're mounting with a existing directory in the file hierarchy. A directory that has such an association is known as a mount point.

  • For example, the root filesystem is mounted at boot time (before the kernel starts any process²) to the / directory.
  • The proc filesystem over which some unix variants such as Solaris and Linux expose information about processes is mounted on /proc, so that /proc/42/environ designates the file /42/environ on the proc filesystem, which (on Linux, at least) contains a read-only view of the environment of process number 42.
  • If you have a separate filesystem e.g. for /home, then /home/john/myfile.txt designates the file whose path is /john/myfile.txt from the root of the home filesystem.

Under Linux, it's possible for the same filesystem to be accessible through more than one path, thanks to bind mounts.

A typical Linux filesystems has many mounted filesystems. (This is an example; different distributions, versions and setups will lead to different filesystems being mounted.)

  • /: the root filesystem, mounted before the kernel loads the first process. The bootloader tells the kernel what to use as the root filesystem (it's usually a disk partition but could be something else such as an NFS export).
  • /proc: the proc filessytem, with process and kernel information.
  • /sys: the sysfs filesystem, with information about hardware devices.
  • /dev: an in-memory filesystem where device files are automatically created by udev based on available hardware.
  • /dev/pts: a special-purpose filesystem containing device files for running terminal emulators.
  • /dev/shm: an in-memory filesystem used for internal purposes by the system's standard library.
  • Depending on what system components you have running, you may see other special-purpose filesystems such as binfmt_misc (used by the foreign executable file format kernel subsystem), fusectl (used by FUSE), nfsd (used by the kernel NFS server), …
  • Any filesystem explicitly mentioned in /etc/fstab (and not marked noauto) is mounted as part of the boot process.
  • Any filesystem automatically mounted by HAL (or equivalent functionality) following the insertion of a removable device such as a USB key.
  • Any filesystem explicitly mounted with the mount command.

¹ Informally speaking here.
² Initrd and such are beyond the scope of this answer.
³ This is unlike Windows, which has a separate hierarchy for each filesystem, e.g. c: or \\hostname\sharename.

share|improve this answer
3  
+10 Gilles where DO you get the time? My only comment is that I have to give people some slack on the swap issue because it's bloody confusing to have my swap partition listed in /etc/fstab when it's not to be mounted. –  Caleb Apr 26 '11 at 23:05
    
definitely a silly question... but can't stop myself. You said "Mounting associates a directory with the root of the filesystem." So where is "/" directory located? –  John May 1 '11 at 8:35
1  
@John: Not a silly question at all, the words “filesystem” and “root” have two different meanings here: there are individual filesystems (each with their root), and there's the whole directory hierarchy (with its root, the / directory). I've reworded this part of my answer, hopefully it should be clearer now. –  Gilles May 1 '11 at 11:17
    
That answer is so incredibly helpful - it's encyclopaedic. I, too, wish I could do a +10 here. Awesome answer. –  boehj May 1 '11 at 12:31
  1. Every linux distro has its own default partition arrangement; some of them use dozens of partitions, some just a single one. 3 and 4 are quite common arrangements (/boot, /, swap and /home). Some older layouts often had /var on a separate partition and extreme systems hnd everything in /var/* and /opt/* on separate partitions! The best generalization I can make in answer to your question is that nothing in the unix world is done without the users notice or ability to change it!
  2. You can mount things that are not partitions. For example /proc is not usually a partition, it is a pseudo filesystem provided by the kernel that allows you to read and write data about running processes as if they were files. You can also mount files (like ISO's) as if they were drives using a loopback device, bind mount folders to other places, and do various other ninja tricks.
share|improve this answer
1  
All of the partitions that are automatically mounted on boot are in /etc/fstab. If you add a partition there, it'll be there on the next boot. –  ultrasawblade Apr 26 '11 at 19:58

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.