When working with ext4 partitions in Linux, it's crucial to know which filesystem features are enabled. Features like has_journal
(journaling), extent
(extent-based allocation), and huge_file
(support for files >2TB) significantly impact performance and capabilities.
The tune2fs
utility is your best friend for inspecting ext4 filesystem parameters. Run this command with sudo privileges:
sudo tune2fs -l /dev/sdXN | grep "Filesystem features"
Replace /dev/sdXN
with your actual partition (e.g., /dev/sda1
). This will output something like:
Filesystem features: has_journal ext_attr resize_inode dir_index filetype extent 64bit flex_bg sparse_super large_file huge_file uninit_bg dir_nlink extra_isize
Here's what key features mean:
- has_journal: Journaling enabled (crash protection)
- extent: Using extents for file storage (better performance)
- huge_file: Supports files >2TB
- 64bit: Supports filesystems >16TB
- flex_bg: Flexible block groups
For even more detailed information:
sudo dumpe2fs -h /dev/sdXN | grep -A10 "Filesystem features"
Example output showing both default and non-default features:
Filesystem features: has_journal ext_attr resize_inode dir_index filetype needs_recovery extent 64bit flex_bg sparse_super large_file huge_file uninit_bg dir_nlink extra_isize Default mount options: user_xattr acl
To verify if journaling is active and see its size:
sudo dumpe2fs /dev/sdXN | grep -i journal
Sample output:
Journal inode: 8 Journal backup: inode blocks Journal features: journal_incompat_revoke Journal size: 128M
Here's a Bash script to comprehensively check ext4 features:
#!/bin/bash PARTITION="/dev/sda1" # Change this to your partition echo "=== EXT4 Filesystem Features Check ===" echo "Partition: $PARTITION" echo "" # Basic feature listing echo "[1] Filesystem features:" sudo tune2fs -l $PARTITION | grep -A1 "Filesystem features" # Journal details echo "" echo "[2] Journal information:" sudo dumpe2fs $PARTITION | grep -A5 -i "journal" # Mount options echo "" echo "[3] Default mount options:" sudo tune2fs -l $PARTITION | grep "Default mount options"
Remember that:
- You need root privileges for these commands
- The partition shouldn't be mounted when checking certain parameters
- Some features can't be changed after filesystem creation
- Feature names might vary slightly between different Linux distributions
When working with existing ext4 partitions, you'll often need to determine which filesystem features are enabled. Unlike during mkfs.ext4 where you explicitly set features like has_journal
or extents
, examining an existing filesystem requires different tools.
The most reliable way is using tune2fs -l
which shows filesystem features in the "Filesystem features" line:
sudo tune2fs -l /dev/sdX1 | grep "Filesystem features"
Example output might show:
Filesystem features: has_journal ext_attr resize_inode dir_index filetype extent sparse_super large_file huge_file uninit_bg dir_nlink extra_isize
For even more detailed information including default mount options:
sudo dumpe2fs -h /dev/sdX1 | grep -A5 "Features"
To verify if journaling is active (even more specifically than the general features list):
sudo debugfs -R "stats" /dev/sdX1 | grep "Journal features"
Here's a Python snippet to programmatically check features:
import subprocess def get_ext4_features(device): result = subprocess.run(['tune2fs', '-l', device], stdout=subprocess.PIPE, text=True) for line in result.stdout.split('\n'): if line.startswith('Filesystem features:'): return line.split(':')[1].strip().split() return [] features = get_ext4_features('/dev/sda1') print("Active features:", features) print("Has journaling:", 'has_journal' in features)
Modern mkfs.ext4 enables several features by default:
- extents (since kernel 2.6.23)
- journaling (unless explicitly disabled with -O ^has_journal)
- huge_file (support for >2GB files)
Remember that current mount options (visible in mount
or /proc/mounts
) may differ from the original filesystem features. Some features can be toggled at mount time while others are baked into the filesystem structure.