Is a file system just the layout of folders?

56

17

I have used Windows since childhood, and when I hear the phrase "Windows filesystem" I think of directories (folders) within directories, a folder called SYSTEM, a folder called PROGRAM FILES etc. Is this what the system is? Just the layout of the folders?

And then I recently started using Linux, and my reference book says in the linux filesystem everything starts at root and branches off from there. How is that really different from Windows? I mean, it seems the linux system and the windows system are just two ways of setting up a directory tree. Is this what file system means?

P_Q

Posted 2011-12-07T15:26:30.300

Reputation: 1 083

3

Have you tried to read http://en.wikipedia.org/wiki/Filesystem ?

– choroba – 2011-12-07T15:34:08.573

yes, but unfortunately I still don't get it. I mean, I understand the words, but I am missing the general idea. – P_Q – 2011-12-07T15:40:49.950

2FYI, There is no "Linux filesystem". What the book meant to say is the linux directory tree. And, yes, the directory tree is just the layout of the folders. – user606723 – 2011-12-07T17:47:52.987

2Linux lacks the concept of drives, such that everything is mounted under /. In Windows, this is not the case, as it lacks UNIX-style mounting (correct me if I'm wrong here), so everything is organized around drives. – new123456 – 2011-12-07T21:30:51.553

1@new123456 Feel corrected. Windows supports mounting (since W2k or NT), although the feature is very rarely used. – kubanczyk – 2011-12-07T23:03:29.290

1

One difference is that the word "filesystem" has three different meanings.

– JdeBP – 2011-12-07T23:27:50.083

You pretty much got it! Here is the Webopedia explanation.

– CharlieRB – 2011-12-07T15:33:16.920

1In a nutshell: "filesystem" is the arrangement of bits on the hard drive to store files. "Directory tree" is the collection of folders and files that is the aspect of a filesystem that you see. – tylerl – 2011-12-08T07:00:21.973

@new123456: Furthermore, at the Windows kernel level, everything is mounted under /, not just drives. Drive letters are just shortcuts into the object namespace, as is COM1: (shortcut to the first serial port, not a drive) – MSalters – 2011-12-09T09:38:30.170

@MSalters Nice to know. I'm assuming its virtual, so one couldn't do much (e.g. create a directory) if one were to manage to get there in the first place? That's what I mean by organized around drives. – new123456 – 2011-12-09T12:35:48.517

@new123456: Oh, you can do pretty much the same with those names. Have a peek in the Registry, \HKEY_LOCAL_MACHINES\SYSTEM\CurrentControlSet\MountedDevices\. It will list both the "raw" names (starting with \??\) and the dos names (\DosDevices\C:\) – MSalters – 2011-12-09T12:39:20.980

Want to see this question blogged? Help by answering or voting at Meta. – Tamara Wijsman – 2011-12-12T01:10:38.643

Answers

130

Just the layout of the folders?

Sounds too good to be true...

Let's take the FAT32 file system as an example. I can install Windows XP on it, but I can also use it on a memory card. On a memory card, you don't have those folders that you sum up.

So... Don't confuse the directory layout of a family of operating systems with a file system.

Is this what a file system means?

No... It refers to the underlying bits and bytes that make your directory structure work.

The underlying bits and bytes? Show me FAT32!

Let's look at what FAT32 looks like, it has:

  • Some header sectors in the beginning, like Volume ID and Reserved Sectors
  • Two File Allocation Tables, allowing us to figure out where our files are.
  • Clusters containing all our directory and file data.
  • Some very small unused space that we can't use.

A FAT table consists of a lot of entries that look like this, allowing us to determine where the directory or file is stored in the clusters space, as well as some attributes and size.

A directory entry would point to a list of directory/file entries...

In the clusters space, we can now travel our clusters to find the data we need. A cluster essentially contains data and information where the next fragments are

enter image description here

Do other file systems differ? Show me NTFS!

I'm going to show you an image so you can notice the differences, the rest is homework for the reader: More information can be found on this blog archive or Google.

The main idea is that NTFS is a huge improvement over FAT32 that is more robust/efficient. Having a better idea of (un)used space by using a bitmap to further help against fragmentation. And so on...

http://thinkdifferent.typepad.com/photos/uncategorized/04ntfsfilesystem.png

What about the file systems on Linux? Show me ext2/3!

The idea is that ext2/ext3 use super blocks and inodes; this allows for soft and hardlinks, directories that are files, files with multiple names and so on. The main gist is abstracting away to allow the file system to be capable of doing more meta-ish stuff...

http://thinkdifferent.typepad.com/photos/uncategorized/03extfilesystem.png

Tamara Wijsman

Posted 2011-12-07T15:26:30.300

Reputation: 54 163

@Shadok: I might improve the later sections later on, I'm quite busy these days though... Thanks. – Tamara Wijsman – 2011-12-07T18:45:33.150

2I would +2 this if I could. Now why can't more document and specs look more like this!? – greatwolf – 2011-12-08T01:26:41.740

Perhaps you should write a blog post about this @TomWijsman ;-) – Ivo Flipse – 2011-12-08T12:37:26.713

@IvoFlipse: A "Data Storage: How does it work?" series might be possible, here is another answer. Big &$# pictures say more than words... :)

– Tamara Wijsman – 2011-12-08T13:15:47.037

Definitely, sounds like a nice idea – Ivo Flipse – 2011-12-08T13:37:55.750

Great answer! Could you add some info about how file systems differ in behavior? For instance, I've heard some do "journaling". I've also heard that ext is less subject to fragmentation than FAT32. – Nathan Long – 2011-12-08T16:35:32.747

@NathanLong: I'll try to see what I can do, I don't have time for much research these days though. Thanks for the suggestion, I agree my answer can be improved but I don't want to make it very long as most can be read on the internet anyway... :) – Tamara Wijsman – 2011-12-08T17:22:51.967

14

The big difference between Linux and Windows, at least when it comes to their filesystems and directory trees is that in Linux "everything is a file", and everything descends from a single root. This also applies to almost all Unix-derived OSes such as BSD, OS X, Solaris, etc., but I'm going to just say "Linux" to be generic (if not entirely accurate).

But what does that mean in practice?

Windows allows for multiple named roots for their filesystems. You understand these as drive letters: C: D: E: and so on. Each one has a root (\), and a tree that descends from it. Recent versions of Windows allow for things like volume mountpoints, where a volume (what you'd consider a partition) can be mounted to an existing, empty folder. So instead of D:\ representing the root of, say, your optical (CD/DVD/BR) drive, you could mount it at C:\Optical instead. This is more similar to what Linux does. There's also an underlying, single-rooted, object namespace for everything in Windows similar to what Linux uses and is managed by the Object Manager, but most users rarely see it referenced since it's primarily for kernel use.

Linux has a single root: /. Everything descends from it, and it doesn't necessarily need to represent your hard drive. Hard Drives, Optical Drives, Memory Cards, Network Shares, Printers, Scanners, CPUs, RAM, Processes, ... everything is represented somewhere inside this single namespace, and can be access by any process with standard file management APIs, presuming you have a high enough level of access. Just because you can read or write from it doesn't mean it's a file on your hard drive in Linux. For example, devices are typically mounted into /dev, so accessing things in there often means you're talking to a device -- maybe it's the sound card, or a scanner, or a camera, etc. These are known as device files. Procfs is a special "filesystem" that's normally mounted to /proc and has a "directory" for every running process, with files in each directory relating to things like the command line used to invoke that process, memory maps, open files, etc. Sysfs is another special filesystem (mounted on /sys) used to expose a wealth of information about the running kernel objects and can also be used to fine-tune the running kernel by simply writing to a particular file.

afrazier

Posted 2011-12-07T15:26:30.300

Reputation: 21 316

2Please note that it is easy to confuse a file system with the directory lay-out from an user perspective. While the term file system is really meant to look to be about the internals of a file system; eg. the difference between FAT and NTFS, as well as the differences between ext2 and ext3... – Tamara Wijsman – 2011-12-07T16:43:02.133

4@Tom: It appears that the OP is really asking about the differences in the various object hierarchies between Linux and Windows rather than how bits are laid out on disk. udev, procfs, sysfs, tmpfs, etc. are filesystems just as much as ext2 or NTFS are in Linux, despite the fact they don't involve stuff on disk. – afrazier – 2011-12-07T17:22:38.780

That's only part of his question "Is a file system just the layout of folders?", the way you answer the question only makes it more confusing and doesn't address that question. Hence I left a notice for readers... – Tamara Wijsman – 2011-12-07T17:30:46.233

+1 for "everything is a file" in Linux. This is THE big difference between Linux and Windows for me. – Rabarberski – 2012-01-03T14:13:50.033

3

The filesystem is not only about how a directory tree is set up, but also how this information is encoded on the media, too. There are several filesystems for Linux: ext3, xfs, raiserfs, etc.

choroba

Posted 2011-12-07T15:26:30.300

Reputation: 14 741

3

You can think of file systems as different formats for storing files and folders, somewhat analogous to how MS Word and PDF are different formats for storing documents, or MP3 and WAV are different formats for storing audio.

Given a few files and folders, the file system is the format and the code that stores them to disk so they can be read back again.

And just like not all video players can play all video formats, not all operating systems can read all file systems. E.g. if you store a file from Linux on an ext3-formatted USB stick, Windows cannot read the file since it doesn't know how to handle the ext3 file system.

Common file systems include

  • FAT and NTFS (Windows, NTFS is standard on newer Windows versions)
  • ext3 and ext4 (Linux)
  • HFS plus (OS X)
  • ISO 9660 and UDF (CD, DVD and Blu-Ray)

See Wikipedia for a comparison of file systems.

j-g-faustus

Posted 2011-12-07T15:26:30.300

Reputation: 1 139