IceWalkers.com - Linux Software downloads and news
Name : Password :
Linux SoftwareLinux RPMLinux HowtosLink UsAboutAdvertise

From Power Up To Bash Prompt

Search Howtos :Match :
Next Previous Contents

7. The Filesystem

In this section, I will be using the word ``filesystem'' in two different ways. There are filesystems on disk partitions and other devices, and there is the filesystem as it is presented to you by a running Linux system. In Linux, you ``mount'' a disk filesystem onto the system's filesystem.

In the previous section I mentioned that init scripts check and mount the filesystems. The commands that do this are fsck and mount respectively.

A hard disk is just a big space that you can write ones and zeros on. A filesystem imposes some structure on this, and makes it look like files within directories within directories... Each file is represented by an inode, which says who's file it is, when it was created and where to find its contents. Directories are also represented by inodes, but these say where to find the inodes of the files that are in the directory. If the system wants to read /home/greg/bigboobs.jpeg, it first finds the inode for the root directory / in the ``superblock'', then finds the inode for the directory home in the contents of /, then finds the inode for the directory greg in the contents of /home, then the inode for bigboobs.jpeg which will tell it which disk blocks to read.

If we add some data to the end of a file, it could happen that the data is written before the inode is updated to say that the new blocks belong to the file, or vice versa. If the power cuts out at this point, the filesystem will be broken. It is this kind of thing that fsck attempts to detect and repair.

The mount command takes a filesystem on a device, and adds it to the heirarchy that you see when you use your system. Usually, the kernel mounts its root file system read-only. The mount command is used to remount it read-write after fsck has checked that it is ok.

Linux supports other kinds of filesystem too: msdos, vfat, minix and so on. The details of the specific kind of filesystem are abstracted away by the virtual file system (VFS). I won't go into any detail on this though. There is a discussion of it in ``The Linux Kernel'' (see section The Linux Kernel for a url)

A completely different kind of filesystem gets mounted on /proc. It is really a representation of things in the kernel. There is a directory there for each process running on the system, with the process number as the directory name. There are also files such as interrupts, and meminfo which tell you about how the hardware is being used. You can learn a lot by exploring /proc.

7.1 Configuration

There are parameters to the command mke2fs which creates ext2 filesystems. These control the size of blocks, the number of inodes and so on. Check the mke2fs man page for details.

What gets mounted where on your filesystem is controlled by the /etc/fstab file. It also has a man page.

7.2 Exercises

Make a very small filesystem, and view it with a hex viewer. Identify inodes, superblocks and file contents.

I believe there are tools that give you a graphical view of a filesystem. Find one, try it out, and email me the url and a review!

Check out the ext2 filesystem code in the Kernel.

7.3 More Information

  • Chapter 9 of the LDP book ``The Linux Kernel'' is an excellent description of filesystems. You can find it at the Australian LDP mirror
  • The mount command is part of the util-linux package, there is a link to it in Building a Minimal Linux System from Source Code
  • man pages for mount, fstab, fsck, mke2fs and proc
  • The file Documentation/proc.txt in the Linux source code explains the /proc filesystem.
  • EXT2 File System Utilities ext2fsprogs home page ext2fsprogs Australian mirror. There is also a Ext2fs-overview document here, although it is out of date, and not as readable as chapter 9 of ``The Linux Kernel''
  • Unix File System Standard Another link to the Unix File System Standard. This describes what should go where in a Unix file system, and why. It also has minimum requirements for the contents of /bin, /sbin and so on. This is a good reference if your goal is to make a minimal yet complete system.


Next Previous Contents
Search Howtos :Match :
Xine 1.1.6
Free video player
Glade 3.5.5
User interface builder for GTK+ and Gnome
Evolution 2.25.4
GNOME mailer, calendar, contact manager and communications tool
GEdit 2.25.4
Small but powerful text editor
Mutt 1.5.19
Small but very powerful text-based mail client.
Galculator 1.3.2
GTK 2 based scientific calculator
BlueFish 1.3.1
GTK HTML editor
Samba 3.3.0rc2
Provides file and print services to SMB/CIFS clients
WebGUI 7.5.38
A fully featured content management system.
Brasero 0.9.0
Application to burn CD/DVD
Free IT Magazines, White Papers, eBooks, and more !
Dr. Dobb's Journal

Dr. Dobb's Journal enables programmers to write the most efficient and sophisticated programs and help in daily programming quandaries.

The 7 Things that IT Security Professionals MUST KNOW!

Gain key insight into security problem and find the safest means to protect your technological assets.

Database Trends and Applications

Provides timely coverage of the technology, intelligence and insight needed to plan, implement and manage information-rich projects.

Linux Software Map
Find Linux RPM
Best Rated Linux Software
Most Rated Linux Software
Linux Distributions
Linux Howtos
Quick Survey

Please take our survey and help us improve our website to serve you better.

Thank you.
Linux Software
Linux / IT Resources
Site Resources
Google
Privacy Policy
Contact Us
Submit Software
Advertising info