brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: dumpe2fs -h prints the ext4 superblock without the long group list

Linux
~/tips/tip-filesystems-dumpe2fs-h-superblock

sudo dumpe2fs -h /dev/sdb1

Shows the settings stored in an ext4 filesystem, such as features, state and block size, in one short screen.

I can never remember which features an ext4 disk was formatted with. The answer lives in the superblock, and dumpe2fs prints it. Without a flag it also lists every block group, which scrolls for pages on a big disk. One flag fixes that.

sudo dumpe2fs -h /dev/sdb1

The -h flag prints only the superblock information and skips the block group details. The device can also be given as LABEL=name or UUID=..., so you don’t need to know the device name. You usually need root to read the device.

On a fresh ext4 image the top of the output looks like this:

Filesystem magic number:  0xEF53
Filesystem revision #:    1 (dynamic)
Filesystem features:      has_journal ext_attr resize_inode dir_index filetype extent 64bit flex_bg sparse_super large_file huge_file dir_nlink extra_isize metadata_csum
Default mount options:    user_xattr acl
Filesystem state:         clean
Errors behavior:          Continue

Lower down you get the block size, the inode and block counts, the reserved block count, the last mount time and the mount count. That is a quick way to see whether the filesystem is marked clean and what happens on errors, without running a check.

To pick out only what you care about:

sudo dumpe2fs -h /dev/sdb1 | grep -E 'state|Errors|features|Block size'

tune2fs -l lists the same superblock, so use whichever name sticks. The caveat is in the man page: on a mounted filesystem the printed information may be old or inconsistent. Treat it as a snapshot, and unmount the filesystem first if you need exact numbers. It belongs to the ext2, ext3 and ext4 toolset, so other filesystems need their own tools.

Further reading: dumpe2fs(8) man page, tune2fs(8) man page

More Linux tips a2query -m rewrite renice -n 10 -p 4242 cat config.yml | xsel -ib xvfb-run -a your-program --some-flag dpkg --get-selections > packages.txt All Linux tips (261) All topics

Link