Study guide
7.1 Linux File Systems: ext2/ext3/ext4 Inode Architecture, Superblocks & Journaling Forensics
Computer Hacking Forensic Investigator CHFI 312-49
Track your progress as you read
Finished sections get a check mark.
1 Chapter 1: Foundations of Digital Forensics & Cybercrime Investigation
1.1 Cybercrime Classifications, Forensic Science Principles & Legal Admissibility 1.2 RFC 3227 Order of Volatility, Live vs. Dead Acquisition & Forensic Readiness 1.3 Indicators of Compromise (IoCs), Cyber Attribution & Threat Intelligence 1.4 AI-Assisted Forensics, GitOps, Automation/Orchestration & Forensics-as-a-Service (FaaS)
2 Chapter 2: Modern Forensic Environments & Emerging Threats
2.1 Fileless Malware, In-Memory Execution & Living-off-the-Land (LotL) 2.2 IoT & Operational Technology (OT/SCADA) Forensic Fundamentals 2.3 Dark Web, Tor Network, Onion Routing & Hidden Services Forensics 2.4 Blockchain Transactions, Cryptocurrency Tracing & Digital Asset Investigations
3 Chapter 3: Legal Frameworks, Search Warrants & Evidence Rules
3.1 Federal Rules of Evidence (FRE 702, 901, 902, 1001-1003) & Daubert/Frye Standards 3.2 Fourth Amendment, Warrant Exceptions, Workplace Search & Consent Protocols 3.3 International Standards: ISO/IEC 27037, ACPO Principles & ENFSI Guidelines 3.4 Cybercrime Statutes, Privacy Compliance, CAN-SPAM & International Cooperation
4 Chapter 4: eDiscovery, Chain of Custody & Professional Ethics
4.1 Electronic Discovery Reference Model (EDRM) & Legal Spoliation Holds 4.2 Chain of Custody Documentation, Evidence Packaging & Tamper-Evident Handling 4.3 Expert Witness Testimony, Report Writing Standards & EC-Council Code of Ethics
5 Chapter 5: Storage Architecture, Boot Sequences & Media Forensics
5.1 Storage Media Architecture: Sectors, Clusters, RAM/File Slack & Unallocated Space 5.2 Partition Tables & Boot Structures: MBR, GPT, VBR, BIOS vs. UEFI Secure Boot 5.3 RAID Reconstruction (RAID 0, 1, 5, 6, 10) & SSD Forensic Challenges (TRIM, Wear Leveling)
6 Chapter 6: Windows File Systems: NTFS & FAT
6.1 NTFS Architecture: Master File Table ($MFT) Record Structure & Attribute Headers 6.2 NTFS Artifacts: Alternate Data Streams (ADS), Volume Shadow Copies (VSS) & $LogFile 6.3 FAT12/16/32 and exFAT Architecture, Directory Entries & File Deletion Mechanics
7 Chapter 7: Non-Windows File Systems & File Signatures
7.1 Linux File Systems: ext2/ext3/ext4 Inode Architecture, Superblocks & Journaling Forensics 7.2 macOS File Systems: HFS+ and Apple File System (APFS) Architecture & Snapshots 7.3 File Signatures, Magic Bytes, Hex Headers/Footers & File Carving Techniques
8 Chapter 8: Investigation Lifecycle, Lab Setup & First Response
8.1 Forensic Laboratory Accreditation: ISO/IEC 17025 Standards & Hardware/Software Controls 8.2 First Responder Duties: Crime Scene Containment, Electronic Triage & Volatile Triage 8.3 Physical Evidence Packaging, Anti-Static/Faraday Protection & Transport Security
9 Chapter 9: Forensic Acquisition & Verification Methodology
9.1 Hardware and Software Write-Blockers: Operational Validation & Bridge Verification 9.2 Bit-Stream Disk Imaging, Physical vs. Logical vs. Targeted Acquisition Methodology 9.3 Forensic Image Formats (RAW/DD, E01, AFF) & Cryptographic Hashing Verification (MD5, SHA-256)
10 Chapter 10: Anti-Forensics Techniques & Countermeasures
10.1 Steganography Detection: Spatial/Frequency Domain Steganalysis & Hidden Carrier Extraction 10.2 Timestomping Countermeasures: Comparing $STANDARD_INFORMATION vs $FILE_NAME Timestamps 10.3 Secure Wiping, Degaussing, File Shredding Countermeasures & Residual Artifact Recovery
11 Chapter 11: Windows Operating System Forensics
11.1 Windows Registry Forensics: SYSTEM, SOFTWARE, SAM & NTUSER.DAT Hive Analysis 11.2 Execution Artifacts: Prefetch (.pf), Shimcache (AppCompatCache), Amcache.hve & UserAssist 11.3 User Activity Artifacts: ShellBags, LNK Shortcut Files, Jump Lists & Recycle Bin ($I/$R) 11.4 Windows Event Log Forensics: Security Audit IDs (4624, 4625, 4688, 4720, 7045) & EVTX Parsing
12 Chapter 12: Memory Forensics & Malware Analysis
12.1 Volatile Memory Acquisition: RAM Capture, Crash Dumps, Hiberfil.sys & Pagefile.sys 12.2 Memory Analysis with Volatility 3: pslist, pstree, malfind, netscan & Vadinfo 12.3 Static Malware Triage: Strings, PE Headers, Import Tables, Hashes & YARA Rule Matching 12.4 Dynamic Malware Analysis: Sandboxing, Process Monitor (Procmon), Regshot & Network Callouts 12.5 .NET Managed Malware Analysis & the GOOTLOADER Fileless Infection Chain
13 Chapter 13: Network, Web Application & Email Forensics
13.1 Network Forensics: PCAP Analysis, Protocol Dissection, Snort/Suricata & Flow Analysis 13.2 Web Server Forensics: Apache/IIS Access Logs, SQL Injection, XSS & Web Shell Detection 13.3 Email Forensics: RFC 5322 Headers, Authentication (SPF, DKIM, DMARC) & Mbox/PST Extraction 13.4 SIEM Event Correlation, Cross-Source Timeline Analysis & Super-Timeline Construction 13.5 Investigating Directory Traversal, Command Injection, Parameter Tampering, XXE, Cookie Poisoning & Brute Force 13.6 Network Device & Service Log Forensics: Firewall, IDS, Honeypot, Router, DHCP, Switch, VPN, DNS & SSH 13.7 Wireless Network Forensics: Rogue APs, Evil Twins, MAC Spoofing, Deauthentication & Jamming
14 Chapter 14: Mobile, Cloud & IoT Forensics
14.1 Mobile Device Forensics: Manual, Logical, File System & Physical Extraction (Android/iOS) 14.2 Mobile Artifact Analysis: Call Logs, SMS/Chat SQLite Databases, Location Data & Plists 14.3 Cloud Forensics: AWS CloudTrail, Azure Activity Logs & Multi-Tenant Evidence Collection 14.4 IoT Forensics: UART/JTAG Physical Interfaces, Firmware Extraction & Sensor Telemetry
15 Chapter 15: Commercial & Open-Source Forensic Suites
15.1 Commercial Forensic Platforms: EnCase Forensic, FTK (Forensic Toolkit) & FTK Imager 15.2 Open-Source Forensic Platforms: Autopsy, The Sleuth Kit (TSK) & SIFT/CAINE Workstations 15.3 Specialized DFIR Utilities: Eric Zimmerman Tools (EZ Tools) & Sysinternals Forensic Suite
16 Chapter 16: Analysis Toolkits, Python Scripting & Tool Validation
16.1 Reverse Engineering & Password Cracking: Ghidra, IDA Pro, Hashcat & John the Ripper 16.2 Python for Digital Forensics: Parsing Raw Artifacts, Custom Scapy Scripts & Evidence Automation 16.3 Forensic Tool Testing & Validation: NIST CFTT Methodology, ISO/IEC 17025 Standards & Daubert Compliance
17 Chapter 17: Database Forensics & Web Application Firewalls
17.1 MySQL Forensics: Internal Architecture, Data Directory, Information Schema & Utility Programs 17.2 SQL Server Forensics: SSMS, ApexSQL, SQLCMD Transaction-Log Collection, Plan Cache & Trace Files 17.3 Web Application Firewall (WAF) Architecture, Audit Logs, Benefits & Limitations
18 Chapter 18: Social, Virtualized, Multimedia & Browser Investigations
18.1 Social Media, Social Engineering, Insider Threat & Identity Theft Forensics 18.2 Virtualization, Container & Microservices Forensics, Bluetooth and Electron Chat Applications 18.3 Multimedia Forensics: Image, Audio & Video Authentication, EXIF, PRNU and Deepfake Detection 18.4 Browser Artifact Recovery, Private Browsing, USB Enumeration, Partition Recovery & Packer Unpacking Tools
7.1 Linux File Systems: ext2/ext3/ext4 Inode Architecture, Superblocks & Journaling Forensics
Key Takeaways Explain This Topic AI
Linux extended file systems (ext2, ext3, ext4) divide storage partitions into Block Groups, anchored by a 1024-byte Superblock with the 2-byte magic identifier 0xEF53 at offset 0x38, backed up across sparse groups (1, 3, 5, 7, and powers of 3, 5, 7).
While ext2 and ext3 utilize 128-byte inodes with 15 indirect block pointers (direct [0-11], single, double, and triple indirect), ext4 adopts 256-byte inodes by default, introducing nanosecond-resolution timestamps (including birth time i_crtime) and an extent tree architecture starting with magic signature 0xF30A.
The Linux Journaling Block Device (JBD2) operates under three modes: data=journal (highest forensic fidelity; records both metadata and file data payloads), data=ordered (default; flushes data to disk before metadata commits), and data=writeback (metadata journaled without ordering guarantees).
During file deletion in ext4, the kernel zeroes out the inode extent header (0xF30A) and extent descriptors, clears the inode allocation bitmap, and unlinks directory entries, rendering traditional metadata-based pointer recovery impossible and requiring JBD2 journal carving or raw unallocated carving.
The Sleuth Kit (TSK) command suite—including fsstat, istat, fls -p, icat, jls, and jcat—provides essential command-line capabilities for inspecting superblock geometry, analyzing raw inode attributes, traversing directory slack, and carving journal transactions.
Last updated: September 2026
7.1 Linux File Systems: ext2/ext3/ext4 Inode Architecture, Superblocks & Journaling Forensics
Quick Answer: The Linux extended file system family ( ext2, ext3, ext4 ) organizes disk partitions into Block Groups to minimize drive head movement and fragmentation. Every file system is governed by a Superblock located at byte offset 1024 (holding the magic number 0xEF53 at offset 0x38 ), replicated across select block groups for redundancy. In ext2/ext3, file metadata is stored in 128-byte inodes using 15 direct and indirect block pointers. In ext4, the default inode size expands to 256 bytes , introducing nanosecond timestamps ( i_crtime /creation time) and an extent tree structure (magic 0xF30A ) that maps up to 128 MB of contiguous blocks per extent. Journaling (ext3/ext4) uses the JBD2 subsystem across three modes: data=journal (both metadata and data logged), data=ordered (default, metadata logged after data write), and data=writeback (metadata logged without ordering). Deletion in ext4 wipes the extent records inside the inode, making journal parsing ( jls / jcat / ext4magic ) and raw carving vital for evidence recovery.
Extended File Systems Evolution (ext2, ext3, ext4)
The Second, Third, and Fourth Extended File Systems represent the dominant non-Windows storage architectures encountered during Linux endpoint and server forensic investigations.
- Attribute / Feature ext2 (Second Extended) ext3 (Third Extended) ext4 (Fourth Extended)
- Introduction Year 1993 2001 2008
- Default Inode Size 128 bytes 128 bytes 256 bytes (supports 128 bytes)
- Max File Size 2 TiB (4 KB blocks) 2 TiB (4 KB blocks) 16 TiB (4 KB blocks)
- Max Volume Size 16 TiB (4 KB blocks) 16 TiB (4 KB blocks) 1 EiB (Exabyte)
- Block Addressing Direct/Indirect Pointers Direct/Indirect Pointers Extents ( struct ext4_extent )
- Journaling Engine None JBD (Journaling Block Device) JBD2 (supports 64-bit blocks)
- Timestamp Precision 1 second (32-bit Unix epoch) 1 second (32-bit Unix epoch) Nanosecond (extra 128B space)
- Birth Time ( crtime ) Not supported Not supported Supported ( i_crtime in 256B inode)
- Deletion Behavior Preserves block pointers Preserves block pointers Zeroes extent tree ( i_block wiped)
- Block Group Geometry and Physical Volume Layout
To prevent the severe disk fragmentation common in older monolithic Unix file systems, ext2/3/4 partitions are segmented into self-contained units known as Block Groups . Each block group manages its own data blocks, allocation tracking, and metadata structures. +---------------------------------------------------------------------------------------------------+
- | EXT4 FILE SYSTEM LAYOUT |
- +---------------------------------------------------------------------------------------------------+
- | Boot Block | Block Group 0 | Block Group 1 | Block Group 2 | Block Group N |
- | 1024 Bytes | (Superblock + GDT...) | (Backup / Data ...) | (Data / Inodes ...) | (...) |
- +---------------------------------------------------------------------------------------------------+
- The Boot Block (Offset 0 to 1023)
The first 1024 bytes of any ext2/3/4 partition are reserved for the x86 PC Master Boot Record (MBR) bootstrap code or bootloaders such as GRUB Stage 1. Even if the file system uses 4096-byte blocks, Block 0 contains this 1024-byte reserved space, and the primary Superblock begins immediately at byte offset 1024 .
Internal Anatomy of a Block Group
Each block group contains a standardized series of control blocks followed by general data cluster storage: +---------------------------------------------------------------------------------------------------+
- | BLOCK GROUP INTERNAL STRUCTURE |
- +-------------------+--------------------+--------------+--------------+-------------+--------------+
- | Superblock Backup | Group Descriptors | Block Bitmap | Inode Bitmap | Inode Table | Data Blocks |
- | 1 Block (if pres) | GDT Blocks | 1 Block | 1 Block | N Blocks | N Blocks |
- +-------------------+--------------------+--------------+--------------+-------------+--------------+
Superblock: 1024 bytes holding global volume metadata. Stored in Block Group 0, with redundant backup copies in select groups.
Group Descriptor Table (GDT): An array of descriptors defining the exact starting block addresses of the Block Bitmap, Inode Bitmap, and Inode Table for every block group across the entire volume.
Block Bitmap: Exactly 1 block in size. Each bit represents one physical data block in the current block group: 0 = free / unallocated, 1 = allocated.
Inode Bitmap: Exactly 1 block in size. Each bit tracks the allocation status of an entry in the group's Inode Table: 0 = free inode, 1 = active/allocated inode.
Inode Table: A contiguous array of data blocks containing the fixed-size inode structures (typically 256 bytes each in ext4) allocated to this group.
Data Blocks: The remaining physical storage space in the block group, holding user file content, directory entries, symbolic links, and indirect/extent tree index blocks.
The Superblock: Magic Bytes & Backup Locations
The Superblock is the foundational metadata structure of the Linux file system. If the superblock becomes corrupted, the operating system kernel cannot mount the partition.
Critical Superblock Fields and Offsets
Offset (Hex) Field Name Size Forensic Description & Investigative Role
0x00 - 0x03 s_inodes_count 4 Bytes Total number of inodes configured across all block groups.
0x04 - 0x07 s_blocks_count_lo 4 Bytes Total block count of the file system (lower 32 bits).
0x14 - 0x17 s_free_blocks_count 4 Bytes Total unallocated data blocks available on the volume.
0x18 - 0x1B s_free_inodes_count 4 Bytes Total unallocated inodes available for new file creation.
0x18 - 0x1B s_first_data_block 4 Bytes 0 for 4096-byte block systems; 1 for 1024-byte block systems.
0x18 - 0x1B s_log_block_size 4 Bytes Block size calculation: 1024 << s_log_block_size (0 = 1KB, 1 = 2KB, 2 = 4KB).
0x20 - 0x23 s_blocks_per_group 4 Bytes Number of blocks managed by each block group (commonly 32,768).
0x28 - 0x2B s_inodes_per_group 4 Bytes Number of inodes allocated to each group's Inode Table (commonly 8,192).
0x2C - 0x2F s_mtime 4 Bytes Last mount time of the volume (32-bit POSIX epoch timestamp).
0x30 - 0x33 s_wtime 4 Bytes Last write / modification time of the file system metadata.
0x34 - 0x35 s_mnt_count 2 Bytes Number of times mounted since the last consistency check ( fsck ).
0x36 - 0x37 s_max_mnt_count 2 Bytes Maximum mounts permitted before an automatic file system check is forced.
0x38 - 0x39 s_magic 2 Bytes File system magic signature: 0xEF53 (Stored little-endian: 53 EF ).
0x3A - 0x3B s_state 2 Bytes File system state flags: 0x0001 = Cleanly unmounted; 0x0002 = Errors detected / dirty.
0x58 - 0x67 s_uuid 16 Bytes Unique volume UUID (128-bit identifier referenced in /etc/fstab ).
0x68 - 0x77 s_volume_name 16 Bytes Optional volume label string (UTF-8, null-padded).
0xE0 - 0xE3 s_journal_inum 4 Bytes Inode number assigned to the internal journal file (standardly Inode 8 ).
Important
CHFI Magic Signature Rule: The 2-byte magic identifier for all Second, Third, and Fourth extended file systems (ext2, ext3, ext4) is identically 0xEF53 located at byte offset 0x38 within the Superblock. When examining raw sector data in a hex editor, this appears as the byte sequence 53 EF .
Backup Superblocks & Sparse Superblock Feature ( sparse_super )
In early ext2 implementations, a full copy of the Superblock and Group Descriptor Table was mirrored into every single Block Group, consuming immense storage. Modern ext3 and ext4 volumes enable the sparse_super feature by default.
Under sparse_super , redundant backup copies of the Superblock and GDT are stored only in Block Group 0 , Block Group 1 , and block groups that are powers of 3, 5, and 7:
- Group 0 (Primary Superblock, offset 1024)
- Group 1 (First backup)
- Group 3, 5, 7
Group 9 (3^2), 25 (5^2), 27 (3^3), 49 (7^2), 81 (3^4), etc.
Forensic Recovery Scenario: If an adversary or disk corruption zeroes out Block Group 0, an investigator can recover the entire file system by executing dumpe2fs or fsstat against a backup group, or mounting the volume specifying an alternate superblock: # Locate backup superblock positions using mke2fs dry-run
mke2fs -n /dev/sdb1
- # Mount the damaged volume using an alternate superblock located at block 32768 (Group 1)
- mount -o sb=32768 /dev/sdb1 /mnt/recovery
- # Run e2fsck with an alternate superblock to restore metadata consistency
- e2fsck -b 32768 -y /dev/sdb1
- Inode Architecture: 128-Byte vs. 256-Byte Structures
In Linux, the file name and physical file data are completely decoupled. The file name is stored exclusively in a directory entry, while all file metadata, ownership permissions, timestamps, and data block pointers reside in an Index Node (Inode) .
128-Byte Inode (ext2 / ext3) vs. 256-Byte Inode (ext4) +---------------------------------------------------------------------------------------------------+
- | EXT4 256-BYTE INODE STRUCTURE |
- +---------------------------------------------------------------------------------------------------+
- | Mode, UID, Size, Timestamps | Links | i_blocks | i_block Array (60 Bytes) | Extra 128-Byte Space |
- | Bytes 0x00 - 0x27 | 2B | 4B | 15 Ptrs OR Extent Tree | crtime, ns timestamps |
- +---------------------------------------------------------------------------------------------------+
Offset (Hex) Field Name Size Forensic Interpretation & Artifact Value
0x00 - 0x01 i_mode 2 Bytes File type and permissions bitmask (e.g., 0x81ED = regular file, -rwxr-xr-x ).
0x02 - 0x03 i_uid 2 Bytes User ID of the owner (low 16 bits; combined with i_uid_high for 32-bit UID).
0x04 - 0x07 i_size_lo 4 Bytes File size in bytes (lower 32 bits).
0x08 - 0x0B i_atime 4 Bytes Last Access Time (32-bit POSIX timestamp, seconds since Jan 1, 1970 UTC).
0x0C - 0x0F i_ctime 4 Bytes Inode / Metadata Status Change Time (cannot be modified by standard user utime ).
0x10 - 0x13 i_mtime 4 Bytes Last Content Modification Time (updated when file payload changes).
0x14 - 0x17 i_dtime 4 Bytes Deletion Time (populated upon unlinking in ext2/ext3; zeroed in ext4).
0x18 - 0x19 i_gid 2 Bytes Group ID of the owner (low 16 bits).
0x1A - 0x1B i_links_count 2 Bytes Hard link count. When this reaches 0 , the inode is flagged as deallocated.
0x1C - 0x1F i_blocks_lo 4 Bytes Total count of 512-byte disk sectors allocated to this file.
0x20 - 0x23 i_flags 4 Bytes File attributes (e.g., 0x0080 = extents used EXT4_EXTENTS_FL ).
0x28 - 0x63 i_block 60 Bytes Block Addressing Array: 15 Indirect Pointers (ext2/3) OR Extent Tree Header & Leaf (ext4).
0x64 - 0x67 i_generation 4 Bytes File version / generation number (NFS tracking).
0x68 - 0x6B i_file_acl_lo 4 Bytes Block address storing POSIX Extended Access Control Lists (ACLs).
0x80 - 0xFF Extra Space 128 Bytes ext4 Specific: Contains i_crtime (Birth/Creation timestamp), nanosecond timestamp components, and inline extended attributes ( xattr ).
i_mode File Type Bitmask Decoding
Forensic investigators determine the exact nature of an artifact by masking the upper nibble of i_mode (bytes 0x00 - 0x01 ):
- 0x8000 : Regular File ( S_IFREG )
- 0x4000 : Directory ( S_IFDIR )
- 0xA000 : Symbolic Link ( S_IFLNK )
- 0x6000 : Block Device ( S_IFBLK )
- 0x2000 : Character Device ( S_IFCHR )
- 0x1000 : FIFO / Named Pipe ( S_IFIFO )
- 0xC000 : Unix Domain Socket ( S_IFSOCK )
- Timestamps & Timestomping Analysis in Linux
Linux file systems track MACB timestamps differently than Windows NTFS:
Timestamp Description Modifiable by User-Mode API? Detection of Timestomping
M (mtime) Last content write Yes ( utimes() , touch -m ) Altered by adversaries to mimic system files.
A (atime) Last file read/access Yes ( utimes() , touch -a ) Frequently disabled via noatime or relatime mount flags.
C (ctime) Metadata / Inode change No direct user API Updated by the kernel whenever permissions, ownership, link count, or size changes.
B (crtime / btime) File Birth / Creation No direct user API Stored at offset 0x90 in ext4 256-byte inodes. Recorded at file creation.
Tip
Linux Timestomping Anomaly: An attacker using the touch -d "2020-01-01 00:00:00" malware.sh command can backdate atime and mtime . However, the execution of the touch command itself alters inode metadata, forcing the Linux kernel to immediately set ctime to the current system time . If an investigator observes an mtime years prior to the ctime , or discovers that crtime (birth time) is newer than mtime , timestomping is definitively proven.
Block Addressing: Indirect Pointers vs. Extent Trees +---------------------------------------------------------------------------------------------------+
- | BLOCK ADDRESSING MECHANISM COMPARISON |
- +---------------------------------------------------------------------------------------------------+
- | ext2/ext3: 15 Pointers (60B) -> [Direct 0-11] [Single Indir 12] [Double Indir 13] [Triple Indir 14]|
- | ext4: Extent Tree (60B) -> [Header: Magic 0xF30A, Depth, Count] [Leaf Extents: Block, Len, PBN]|
- +---------------------------------------------------------------------------------------------------+
- 1. Legacy ext2/ext3: The 15 Pointer Array (60 Bytes)
The 60-byte i_block field holds fifteen 32-bit (4-byte) disk block addresses:
Pointers 0–11 (Direct): Point directly to data blocks. For 4 KB blocks, holds files up to 48 KB (12 * 4 KB).
Pointer 12 (Single Indirect): Points to a block containing 1,024 block pointers (4 KB / 4 B = 1,024 blocks = 4 MB).
Pointer 13 (Double Indirect): Points to a block holding 1,024 single-indirect pointers (1,024 * 1,024 = 1,048,576 blocks = 4 GB).
Pointer 14 (Triple Indirect): Points to a block holding 1,024 double-indirect pointers (1,024 * 1,024 * 1,024 = 1,073,741,824 blocks = 4 TB).
2. ext4: Extent Tree Architecture ( 0xF30A )
To eliminate the massive overhead and fragmentation of indirect block pointers for large multi-gigabyte files, ext4 replaces pointers with Extents . An extent represents a single contiguous run of physical disk blocks (up to 32,768 contiguous blocks = 128 MB per extent).
The 60-byte i_block field in ext4 begins with an Extent Header followed by up to 4 Extent Records: struct ext4_extent_header {
- __le16 eh_magic; // Magic number: 0xF30A
- __le16 eh_entries; // Number of valid entries following header
- __le16 eh_max; // Capacity of entries in this node (4 in inode body)
- __le16 eh_depth; // Depth of tree (0 = leaf node; >0 = index node)
- __le32 eh_generation; // Generation number
- };
- Extent Structures: Leaf vs. Index
If eh_depth == 0 , the header is followed by struct ext4_extent records (Leaf Nodes pointing to real data blocks):
ee_block (4 bytes): Logical file block number.
ee_len (2 bytes): Number of contiguous blocks (values <= 32768 are initialized; values > 32768 are uninitialized/preallocated).
ee_start_hi (2 bytes) & ee_start_lo (4 bytes): 48-bit physical block address.
If eh_depth > 0 , the header is followed by struct ext4_extent_idx records (Index Nodes pointing to external extent index blocks).
Binary Analysis of an Extent Record
Suppose raw hex analysis of an inode's i_block field (offset 0x28 ) yields: 0A F3 01 00 04 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 10 00 00
Magic Signature: 0A F3 -> In little-endian, this is 0xF30A (Ext4 Extent Header validated).
Entries: 01 00 -> 1 valid extent entry follows.
Max Entries: 04 00 -> Maximum 4 entries can fit in the inode's 60-byte space.
Depth: 00 00 -> Depth is 0, confirming this is a direct leaf node .
Leaf Extent Analysis ( 00 00 00 00 20 00 00 00 00 10 00 00 ):
ee_block : 00 00 00 00 -> Logical block 0 (file start).
ee_len : 20 00 -> Little-endian 0x0020 = 32 contiguous blocks.
ee_start_hi : 00 00 -> High bits 0.
ee_start_lo : 00 10 00 00 -> Little-endian 0x00001000 = Physical block 4,096.
Conclusion: The file occupies 32 contiguous blocks (128 KB for 4KB blocks) starting at physical block 4,096.
Directory Structure & Deletion Mechanics
In ext4, directories are structured as linked lists of directory entries ( ext4_dir_entry_2 ) contained within data blocks: struct ext4_dir_entry_2 {
- __le32 inode; // Inode number pointing to file metadata
- __le16 rec_len; // Total length of this directory entry record
- __u8 name_len; // Length of file name string
- __u8 file_type; // File type: 1=Regular, 2=Directory, 7=Symlink
- char name[]; // UTF-8 file name string (null-terminated/padded)
- };
- The Deletion Mechanics Discrepancy: ext2/3 vs. ext4
Understanding how files are deleted across Linux file systems is a high-yield CHFI exam topic: +---------------------------------------------------------------------------------------------------+
- | EXT3 VS. EXT4 DELETION FORENSIC ARTIFACTS |
- +---------------------------------------------------------------------------------------------------+
- | Feature | ext2 / ext3 | ext4 |
- | Inode Allocation Bit | Cleared to 0 | Cleared to 0 |
- | Inode Block Pointers | Preserved in inode (Recoverable) | Cleared to 0 (Extent header wiped) |
- | Deletion Timestamp | i_dtime recorded | i_dtime usually set to 0 or unused |
- | Directory Entry Record | rec_len expanded over entry | rec_len expanded over entry |
- | Primary Recovery Path | Pointer carving via TSK icat | JBD2 Journal carving / Raw Carving |
- +---------------------------------------------------------------------------------------------------+
In ext2 and ext3: When a file is unlinked, the OS sets the Inode Bitmap bit to 0, decrements i_links_count to 0, and logs i_dtime . Crucially, the 15 block pointers in i_block remain completely untouched . Forensic tools like TSK icat or ext3grep can immediately reconstruct deleted files.
In ext4: When a file is unlinked, the kernel's ext4 driver deliberately zeroes out the 60-byte i_block field (destroying the 0xF30A extent header and all block mappings). As a result, standard inode-based file recovery fails completely on ext4. Recovery requires JBD2 journal analysis or raw file carving .
Directory Slack Carving: In both ext3 and ext4, the directory entry is unlinked by increasing the rec_len of the preceding valid directory entry to absorb the deleted entry's record space. The deleted file name, length, and original inode number remain intact in directory slack space until a new file entry overwrites that specific directory block.
Journaling Forensics: The JBD2 Subsystem
Ext3 and ext4 implement fault-tolerant journaling using the Journaling Block Device (JBD / JBD2) driver. The journal is stored internally as a dedicated pseudo-file, almost universally assigned to Inode 8 .
The Three Journaling Modes
Forensic acquisition of files depends heavily on how the Linux system administrator mounted the file system:
Journaling Mode Operational Behavior Data Recovery Potential Forensic Analysis
data=journal Both file metadata AND raw file data payloads are committed to the journal before writing to storage. Highest: Complete file contents, even if deleted or overwritten on disk, reside inside the journal. Full files can be recovered by parsing unallocated journal blocks with ext4magic or jcat .
data=ordered (Default) File data payloads are flushed to physical data blocks first; only metadata changes are committed to the journal. Moderate: Journal contains file names, timestamps, and extent records, but not the file payload. Excellent for timeline reconstruction, proving file existence and execution time, but payloads must be carved from disk blocks.
data=writeback Metadata is logged, but no ordering is enforced between metadata commits and data flushing. Lowest: Metadata is preserved, but data blocks may be stale or inconsistent. Timelines and metadata changes are reconstructible; data integrity is not guaranteed.
JBD2 Binary Block Types
The journal operates as a ring buffer. Every journal block starts with a 12-byte header holding the JBD2 Magic Number 0xC03B3998 :
JBD2_DESCRIPTOR_BLOCK (Type 1): Follows a transaction start. Contains an array of tags mapping journal blocks to their eventual physical block destinations on the root file system.
JBD2_COMMIT_BLOCK (Type 2): Written after all transaction blocks are flushed. Validates that the atomic transaction completed successfully.
JBD2_SUPERBLOCK_V1 / V2 (Type 3 / 4): Identifies journal geometry, block size, and head/tail transaction sequence numbers.
JBD2_REVOKE_BLOCK (Type 5): Lists data blocks that were freed or reassigned during a transaction, instructing the replay engine to ignore older journal records for those blocks.
Practical DFIR Tool Workflows: The Sleuth Kit (TSK)
Forensic examiners rely on The Sleuth Kit (TSK) command-line utilities to parse raw Linux disk images without mounting them (which would risk altering metadata). # 1. fsstat: Inspect file system geometry, block group counts, and journal inode
- fsstat -o 2048 /dev/sdb1
- # Output highlights: Block Size: 4096, Inode Size: 256, Magic: 0xEF53, Journal Inode: 8
- # 2. istat: Inspect specific inode metadata, nanosecond timestamps, and extents
- istat -o 2048 /dev/sdb1 131075
- # Displays: File Type: Regular, Permissions: 0755, UID: 0, Size: 18432 bytes
- # Extent Tree: Depth: 0, Entries: 1, Block: 0 -> Length: 5, PBN: 524288
- # 3. fls: List directory contents recursively, displaying deleted files (*)
- fls -o 2048 -r -p -d /dev/sdb1
- # Output: * d/d 131080: /home/victim/.malware/payload.sh (deleted file entry in slack)
- # 4. icat: Carve raw data content of an inode directly to an analysis workstation
- icat -o 2048 /dev/sdb1 131075 > /cases/evidence/recovered_artifact.bin
- # 5. jls: Display transaction block lists from the ext4 journal (Inode 8)
- jls -o 2048 /dev/sdb1 8
- # 6. jcat: Extract specific transaction blocks from the JBD2 journal
- jcat -o 2048 /dev/sdb1 8 412 > /cases/evidence/journal_tx412.bin
Note
In corporate incident response, tools such as ext4magic automate the recovery of recently deleted ext4 files by cross-referencing unlinked directory entries with JBD2 journal transactions, successfully extracting file copies before journal ring buffers wrap around.