Friday, December 10, 2010

File Systems

First I'd like to thank Henry for sending me the ebook for I could not have finished this blag post without it and that's it.

The partitioning and file systems is the current chapter. Beginning talks of the basics such as logical partitions and swap. According to the book fdisk is the most popular partitioning tool and I can't disagree.

To edit the device that you want you would use fdisk /dev/device_here. It shows how to partition a machine and it's funny how at the end of that it says "This works only on a machine that you are destructively partitioning for an installation". Whoops! Anyways...

fdisk -l lists your partition tables. Here's an part of an output from a computer of mine.

Device Boot Start End Blocks Id System
/dev/sda1 * 1 8486 68160928+ 7 HPFS/NTFS
Partition 1 does not end on cylinder boundary.
/dev/sda2 8486 60801 420223041+ f W95 Ext'd (LBA)
/dev/sda5 8486 34692 210500608+ 7 HPFS/NTFS
/dev/sda6 34692 34756 512000 83 Linux
/dev/sda7 34756 60801 209207296 8e Linux LVM

It's actually very screwey but as you can tell sda1 is the boot partition and it's windows, sda2 is a second windows partition, sda5 is a logical partition (always starts at 5) I thought I deleted long ago... and the last one as you can tell is the Fedora partition.

Last part I got to was superblocks and inodes. A superblock is basically a block of data (36 bytes) containing the file system size, location, number of inodes, and disk usage. There are many of them throughout the device occuring every 8192 blocks. They are important because if part of a disk is corrupted and a superblock is part of it you still have other ones to fall back on.

Inodes are assigned to a file when it's created. They are pointers to disk bocks, groups of eight, and the indoe is assigned to the block group in front of it. There are only a limited amount of indoes with only three sizes available when you create a file system.


Smaller means more inodes. You could run out of inodes and still have hard drive space but you wouldn't be able to use it. So when you are creating the file system you can use mkfs with one of three switches.

news-Indoes are 4KB per block
largefile-1MB per block
largefile4-4MB per block

largefile4 should only be used for databases.

My journey ends around the mkfs command which is what you use to make the file system and there are many file systems to choose from. That's all for now.


  1. Now this is *cool*! Unlike the previous topic (control of modems) this one is very important. It may even be worth taking a little time to investigate other file systems (FAT, for example, and the database like file system that Haiku-OS uses). What is defragmenting, for example, and why does this need to be done on FAT systems. What is the relationship between inodes and fragmentation?