It covers the main differences between ext3 and ext4 with a focus on filesystem consistency. This article was the initial motivation of this blog series, because many engineers are unaware that the standard option of ext4 (delalloc) is dangerous for their data!
This blog article details how a brutal interruption of a write operation can corrupt a whole filesystem and how a journal provides a protection against such incomplete writes.
This article aims to give a clear representation of the relation between filenames and inodes, to explain what is an inode and which differences exist between a hard link and a symbolic link.
2.1 Filename as Hardlink to Inode
On ext3 and ext4 (and some other filesystems) a file is stored
It explains how files are split into blocks and how the filesystem acts as an abstraction layer between files (seen by applications) and blocks (physically written on disks). It also says why disks are called block devices.
1.1 Splitting Up Files Into Blocks
A block device is a storage media, like a hard disk. You can use ‘blkid’ and ‘fdisk -l’ to show a list of block devices attached to your system.
In the following example, ‘sda’ is a disk with 2 partitions ‘sda1′ and ‘sda2′, and ‘sr0′ is a compact disc.
A filesystem can be created on a partition and also on a whole partitionless disk, as both partition and disk are valid block devices.
blkid /dev/sda1: UUID="5b0e4487-b5aa-4186-81fd-f561308f4cf1" TYPE="swap" /dev/sda2: UUID="ec851750-9854-4227-8898-d5695dbd297e" TYPE="ext3" /dev/sr0: LABEL="VBOXADDITIONS_4.2.16_86992" TYPE="iso9660" fdisk -l Disk /dev/sda: 12.9 GB, 12884901888 bytes 255 heads, 63 sectors/track, 1566 cylinders, total 25165824 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x000be060 Device Boot Start End Blocks Id System /dev/sda1 2048 786431 392192 82 Linux swap / Solaris /dev/sda2 * 786432 25165823 12189696 83 Linux
In order to use the hardware efficiently and to increase the addressing limit the disk read and write operations are not processing the data byte by byte. Instead these operations are using a larger unit called a block (also called a sector), which is usually 512 Bytes.