EXT4

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/OptionExampleDescription
mkfs.ext4mkfs.ext4 /dev/sdX1Create an EXT4 file system on a partition
mkfs.ext4 -L label /dev/sdX1mkfs.ext4 -L mylabel /dev/sdX1Create an EXT4 file system with a volume label

File System Checking and Repair #

Command/OptionExampleDescription
fsck.ext4fsck.ext4 /dev/sdX1Check and repair an EXT4 file system
fsck.ext4 -f /dev/sdX1fsck.ext4 -f /dev/sdX1Force check of the file system

Mounting and Unmounting #

Command/OptionExampleDescription
mountmount -t ext4 /dev/sdX1 /mntMount an EXT4 file system to a directory
umountumount /mntUnmount the file system

File System Information #

Command/OptionExampleDescription
tune2fstune2fs -l /dev/sdX1Display detailed file system information
tune2fs -m 1 /dev/sdX1tune2fs -m 1 /dev/sdX1Set reserved block percentage to 1%
df -Tdf -T /mntDisplay file system type

File System Management #

Command/OptionExampleDescription
e2labele2label /dev/sdX1 mylabelChange the volume label of an EXT4 file system
resize2fsresize2fs /dev/sdX1 20GResize the EXT4 file system to 20 GB
tune2fs -O ^metadata_csum /dev/sdX1tune2fs -O ^metadata_csum /dev/sdX1Disable metadata checksumming

Journaling and Features #

Command/OptionExampleDescription
tune2fs -O has_journal /dev/sdX1tune2fs -O has_journal /dev/sdX1Enable journaling on an EXT4 file system
tune2fs -O ^has_journal /dev/sdX1tune2fs -O ^has_journal /dev/sdX1Disable journaling on an EXT4 file system
tune2fs -E lazy_itable_init=0 /dev/sdX1tune2fs -E lazy_itable_init=0 /dev/sdX1Initialize inode tables lazily

File System Integrity #

Command/OptionExampleDescription
dumpe2fsdumpe2fs /dev/sdX1Dump file system information
e2fscke2fsck -f /dev/sdX1Check and repair file system

Extended Attributes #

Command/OptionExampleDescription
getfattrgetfattr -d /mnt/fileGet extended attributes of a file
setfattrsetfattr -n user.comment -v "Sample comment" /mnt/fileSet an extended attribute on a file

This cheatsheet covers essential EXT4 commands and options to help you manage and maintain EXT4 file systems effectively.

Cheatsheet Website

Discover our extensive collection of cheatsheets covering various tools and technologies to streamline your workflow.