29

I am new to Linux so pardon me for the possible confusion you may encounter in this question.

From what I understand, filesystem specifies how a partition stores/manages file, with standards such as ext2, ext3, reiserfs, xfs, etc. Occasionally I see people seem to refer to each "directory" as

    /boot filesystem
    /usr/bin filesystem
    /root filesystem
    /bin filesystem

Why would we refer to these as filesystems?

If each of them is a partition, that confuses me because as far as I know, /usr and /usr/bin tend to be in the same partition, but I saw people refers to both /usr filesystem and /usr/bin filesystem.

If filesystem here is equivalent to Window's directory, it's not clear to me as apparently filesystem is something more than just directories. Also, as far as I know, Linux does not have directory concept; all are files.

  • I've never seen an instance of "the /root filesystem". Whatever filesystem is mounted at "/" is "the root filesystem". Some other likely mount-points on a modern Linux distro would be "/boot", "/home", and "/mnt/xx" or "/media/xx" for various values of "xx". Kernel 2.x+ (?) distros will have "/proc" and "/sys", Systemd has mountpoints "/var/run/nnnn" for various numeric UIDs nnnn. Older Unix installations might mount "/usr" via NFS, but that's unlikely on a personal Linux distro. "/bin" and "/usr/bin" would not normally be separate mountpoints. – david Dec 17 '15 at 14:27
  • There is a /root , isn't there ? Do you mean it nevers stays in a separate filesystem ? – Kenny Dec 17 '15 at 14:37
  • Right. "/root" is the standard home-directory for the user "root", but it's typically just another directory on the root filesystem. – david Dec 17 '15 at 14:40
  • This topic has been discussed extensively on Ask Ubuntu, which, IMNSHO, is silly, since, AFAIK, the concepts aren't any different on Ubuntu that they are on any other form of Unix or Linux.  For example, What is “mount”? was asked just a few days ago. – Scott Dec 19 '15 at 10:40
  • I'm quite impressed with the questions. Coming from little knowledge you could already comprehend quite a lot at this time and that you've missed the conclusion that "/root filesystem" may refer to the filesystem the partition has that is mounted at /root, I think that's dismissable considering the complexity of the situation. – erikbwork Apr 1 '17 at 15:58
12

As I wrote in https://superuser.com/a/293160/38062:

The problem here is the word "filesystem". In the POSIX/Unix/Linux worlds, it is used to mean several different things.

  1. The "filesystem" is sometimes the entire system of files, rooted at / and as presented to applications softwares by the operating system kernel. With this meaning, people talk of POSIX operating systems having a "single filesystem tree", for example.
  2. A "filesystem" is sometimes one (or more) slice(s) of a (or several) DASD(s) — one or more collections of contiguous disc sectors formatted as a single volume with a given format — as demarcated by some disc partitioning scheme. With this meaning, people talk of, say, "formatting my /usr filesystem". "/usr" here is the (expected) mountpoint of the volume, or (in some partitioning schemes) its identifying label.
  3. A "filesystem" is sometimes an abstract joinable tree of files and directories, presented by a filesystem driver (i.e. the VFS layer) to the rest of the system. With this meaning, people talk of, say, "mounting the proc filesystem on /proc" or "using a tmpfs filesystem for /tmp".

You're seeing meaning #1 when you see "/usr/bin filesystem". It's a filesystem tree rooted at the directory /usr/bin. Yes, Linux very much does have the concept of directories.

Meaning #2 and meaning #3 are what you're mis-reading it as. People are not talking about /usr/bin as an on-disc data set, demarcated by disc slicing/partitioning. Nor are they talking about /usr/bin as a particular type of filesystem driver, or a particular disc volume format.

Further reading

  • Ramesh Bangia (2010). "file system". Dictionary of Information Technology. Laxmi Publications, Ltd. ISBN 9789380298153. p. 224.
  • File System. "Base Definitions". The Open Group Base Specifications. Issue 7 IEEE 1003.1. The Open Group. 2013.
  • Binh Nguyen (2004-08-16). "filesystem". The Linux Dictionary. Version 0.16. p. 616.
7

Of course Linux uses concept of directories. The concept of directories is the same as in Windows.

Concept of filesystems is also very similar to what is used in Windows. Windows usually use NTFS or FAT - Linux usually uses ext2, ext3, ext4 and so on, that's all the difference.

What is different, is that in Linux the files/directories from all the available partiotions are organized into a single tree. In Windows you refer to different partitions using a letter, f.e. "a:", "c:", in Linux full path to any available file starts with "/" - the root directory. For example, there is a separate partition on you hdd with files recuired to boot the system: you run 'mount' command with apropriate arguments and contents of this partition becomes available at "/boot/" path. So, f.e. "/boot" and "/home" paths may refer to data on different partitions, these partitions may have different filesystems. Probably caused your misunderstanding.

Directories which are physically located on same partition would always "have same filesystem". When someone talks about the filesystem of some directory, it's actually about the filesystem of the partition where this directory is located.

(Minor and probably not important correction: sometimes the filesystem is virtual and there is no any corresponding partition. For example "/proc" contains something, which looks very much like files, but these "files" are virtual, they do not reside on any hard drive and contain information about running processes. And there is a special "procfs" filesystem which provides usual file-like interface to this data)

  • You mentioned "filesystem of a directory", does it cascade to all of its subdirectories. Is it possible one directory and its subdirectories to have different filesystem ? For example /a and /a/b, with /b is another partition with its own filesystem F2 mounted to a having filesystem F1 ? – Kenny Dec 17 '15 at 15:07
  • As for whether directories located on the same partition are in fact part of the same filesystem can get a bit fuzzy for some very-modern filesystems such as ZFS or btrfs; you can have a ZFS volume with several filesystems sharing it, with their own entirely distinct mountpoints. – Charles Duffy Dec 17 '15 at 23:11
  • @Kenny Yes, you are right. Live example: I insert a compact disk into cd-drive. My linux mounts the CD at "/mount/cdrom". "/mount" directory (and any files I create in it) is located on my hard drive. But "/mount/cdrom" contents is already on CD. – lesnik Dec 18 '15 at 6:28
6

A disk is divided into one or more partitions. For Windows, there is usually just one, maybe with a recovery partition hiding somewhere. A partition is a logically contiguous area of the disk, e.g. "sectors 1 through 10,000,000".

On a partition can be built a filesystem. For Windows, this is NTFS or FAT; for Linux this is one of the ext versions or various other options.

Inside a filesystem are files and directories. Linux has directories, I've no idea how you got the idea that it didn't.

How does an operating system present multiple partitions on multiple disks to the user? On Windows, this is done with drive letters: C:, D: etc. On Linux, there are no drive letters and everything is done with mount points: at a particular directory, reroute access to a different filesystem.(+) Often if you insert a CD or USB stick it will appear somewhere under /media or /mnt.

/usr and /usr/bin will usually be on the same filesystem but are not required to be. People may mean "the filesystem that happens to contain the /usr/bin directory" when they use that phrasing.

(+) You can do this with NTFS junction points too, but people rarely do. Until they run out of drive letters.

  • Correct me if I am wrong : On Linux, 1 physical disk can be divided into multiple partitions, each one having its own filesystem ? Analogous to the way a harddisk on Windows contains several partitions, one can be FAT and the other NTFS ? – Kenny Dec 17 '15 at 14:45
  • 1
    Yes, you're correct: but it's not analogous, it's exactly the same underlying mechanism. Dual-boot machines might have NTFS and ext3 partitions on the same disk, and each operating systems's disk manager sees the same set of partitions. It's just that Windows can't see mount the ext3 partitions to see the files. – pjc50 Dec 17 '15 at 15:32
3

It’s possible to keep an entire Linux system on one partition, with all the subdirectories being on one filesystem.

It’s also possible to spread it over several partitions, with certain directory subtrees being on different filesystems. For example, it’s common to put /home, /tmp, /usr, and /var on separate filesystems. To address one of your questions, sometimes /usr/bin will be on its own filesystem too.

There are advantages to this scheme. For example, if /var fills up with a lot of emails, the rest of the system is not affected. Likewise, if one filesystem is corrupted due to a crash or something, other filesystems are still good and it’s easier to recover the system.

When the system boots, at first only the root filesystem is available. Programs kept there are run during the boot process. One of these programs, mount, is run several times, using data from the file /etc/fstab, the filesystem table. To take one example: originally, /home is just an ordinary directory in the root filesystem. Then we run this command as root:

mount /dev/sda7 /home

This tells the system that the filesystem on the partition /dev/sda7 should be mounted on the directory /home. So now, everything in that filesystem is considered to be under /home.

You can see what’s currently mounted by running df.

3

We sometimes refer to those as filesystems, because sometimes those directories are mount points. So much for the only question you asked ...

filesystem can refer to two different things ... or actually two very different aspects of the same thing:

  1. The logical structure used to organise data on a storage medium.
  2. The methodology used by the OS to offer processes unified access to data.

The concept of files and directories is a metaphor. To a computer there is only data and all media is nothing but devices that can hold data. Some devices allow reading and writing data (e.g. HDD), other devices only allow reading data (e.g. CD-ROM) and there are even devices that allow only writing data (e.g. printer). We use the file and directory metaphor to structure data, so that we can access small chunks of data, rather than everything at the same time.

The filesystems we put on storage media, e.g. ext4, xfs, fat do the structuring part. We use them to put labels on chunks of data (files) and to have a consistent structured list of all the labels (directories). The structured list is actually a tree. The most important aspect is that a tree has exactly one beginning, its root. Maintaining this structure and ensuring the data is and remains accessible is quite the task, which is why there is not just one flavour of filesystem.

The other aspect of filesystems is, that it is the job of the OS to make the data stored on storage devices accessible to all the programs. This is accomplished by two things:

  1. The OS offers precisely one (programming) interface for accessing and interacting with files and directories. For programs/processes it does not matter whether the filesystem on the storage device is ext2, xfs, fat, or whatever. Progams/processes access files and directories in a uniform way.

  2. The OS organises all the storage media, i.e. their filesystems, in one superordinate structure. Programs access files and directories through this superordinate structure and need not interact with the storage devices directly. That way the programs need not care about on which device the data actually resides. This superordinate structure is often refered to as the kernel's "virtual filesystem".

Adding the filesystem of a storage device to the virtual filesystem is called "mounting" a filesystem. When your Linux is starting up the kernel creates the virtual filesystem (VFS). Right after creation it is empty and consists only of its entry point, a.k.a. its root, transcribed /. Then the kernel mounts a filesystem at the root of the VFS. This is either a ramdisk or immediately a filesystem on a partition on a hard drive. As it is added at the root of the VFS this partition is often refered to as the root filesystem.

Now here comes the part where the lines blur and we see that filesystems on storage devices and the kernel's VFS are actually two aspects of the same OS task: With the mounting of a root filesystem, the VFS contains many files and directories, all of which exist on the root partition. However, every directory can become a "mount point". A mount point is where the VFS puts the entry point to a filesystem on a storage device. This means that whenever we mount a filesystem on a directory, we tell the VFS that instead of accessing the data stored in that directory, we would rather access the data on a different storage device. Mount points are usually empty directories, so that we don't make data unaccessible by mounting other filesystems on top.

When you install your OS it is up to you whether you want to put all data on one filesystem which then becomes your root filesystem, or you want to split your data between multiple filesystems. The latter requires your OS to mount all the individual filesystems, to make all data accessible. How you split things up is a question of how you design your system. This is why sometimes the directories you know from your installation are refered to as filesystems.

For the computers we usually have at home splitting your installation into multiple filesystems is not necessary anymore. Still there can be good reasons for doing so, but this is out of scope of this posting.

To keep the remainder of this posting short: Partitions are another means of structuring data on storage devices. With partitions one carves out contiguous storage space from a physical storage device and offers these as individual storage devices to the OS (on which one can put filesystems to mount into the VFS). One reason for doing this can be that one has only one hard drive, but wants to employ many different filesystems. The partition on which the root filesystem lives is often refered to as the root partition.

1

You're doing a little bit of confusion. Filesystem indicates a mechanism by which the files are located and organized on a storage device or on a mass memory, like a hard drive or a CD-ROM and, in some cases, also on the RAM.

Even windows uses filesystems such as NTFS or, earlier, FAT.

Your example shows a common practice for linux and unix systems, to have their own system composed of different filesystems mounted on directories named mount point. This allows, in case of problems, to limit the damage to one or more but not to all filesystems.

So, FS is not equivalent to directory, and also in linux there are directories, that are a special kind of file

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.