EXT4 Cheatsheet
#
EXT4 is the fourth extended file system used in Linux, known for its improvements over EXT3 including larger file system sizes, improved performance, and extended attributes.
File System Creation
#
Command/Option | Example | Description |
---|
mkfs.ext4 | mkfs.ext4 /dev/sdX1 | Create an EXT4 file system on a partition |
mkfs.ext4 -L label /dev/sdX1 | mkfs.ext4 -L mylabel /dev/sdX1 | Create an EXT4 file system with a volume label |
File System Checking and Repair
#
Command/Option | Example | Description |
---|
fsck.ext4 | fsck.ext4 /dev/sdX1 | Check and repair an EXT4 file system |
fsck.ext4 -f /dev/sdX1 | fsck.ext4 -f /dev/sdX1 | Force check of the file system |
Mounting and Unmounting
#
Command/Option | Example | Description |
---|
mount | mount -t ext4 /dev/sdX1 /mnt | Mount an EXT4 file system to a directory |
umount | umount /mnt | Unmount the file system |
Command/Option | Example | Description |
---|
tune2fs | tune2fs -l /dev/sdX1 | Display detailed file system information |
tune2fs -m 1 /dev/sdX1 | tune2fs -m 1 /dev/sdX1 | Set reserved block percentage to 1% |
df -T | df -T /mnt | Display file system type |
File System Management
#
Command/Option | Example | Description |
---|
e2label | e2label /dev/sdX1 mylabel | Change the volume label of an EXT4 file system |
resize2fs | resize2fs /dev/sdX1 20G | Resize the EXT4 file system to 20 GB |
tune2fs -O ^metadata_csum /dev/sdX1 | tune2fs -O ^metadata_csum /dev/sdX1 | Disable metadata checksumming |
Journaling and Features
#
Command/Option | Example | Description |
---|
tune2fs -O has_journal /dev/sdX1 | tune2fs -O has_journal /dev/sdX1 | Enable journaling on an EXT4 file system |
tune2fs -O ^has_journal /dev/sdX1 | tune2fs -O ^has_journal /dev/sdX1 | Disable journaling on an EXT4 file system |
tune2fs -E lazy_itable_init=0 /dev/sdX1 | tune2fs -E lazy_itable_init=0 /dev/sdX1 | Initialize inode tables lazily |
File System Integrity
#
Command/Option | Example | Description |
---|
dumpe2fs | dumpe2fs /dev/sdX1 | Dump file system information |
e2fsck | e2fsck -f /dev/sdX1 | Check and repair file system |
Extended Attributes
#
Command/Option | Example | Description |
---|
getfattr | getfattr -d /mnt/file | Get extended attributes of a file |
setfattr | setfattr -n user.comment -v "Sample comment" /mnt/file | Set an extended attribute on a file |
This cheatsheet covers essential EXT4 commands and options to help you manage and maintain EXT4 file systems effectively.