FILEFRAG(8)

๐Ÿ’– FILEFRAG(8) ๐Ÿ’–

okay bestie, welcome to filefrag โ€” a lil' tool from the System Manager's Manual section 8 (that's the sysadmin zone, we love her) ๐ŸŽ€


โœจ NAME โœจ

filefrag โ€” the girl who reports on file fragmentation ๐Ÿ’…


๐ŸŒธ SYNOPSIS ๐ŸŒธ

filefrag [ -bblocksize ] [ -BeEkPsvVxX ] [ files... ]

๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

So basically, filefrag spills the tea on how badly fragmented a particular file might be. It's giving investigative journalism but for your disk ๐Ÿ•ต๏ธโ™€๏ธโœจ

It makes allowances for indirect blocks for ext2 and ext3 file systems โ€” cute of it โ€” but fr fr it can be used on files for any file system. No gatekeeping here ๐Ÿ’–

The filefrag program initially attempts to get the extent information using FIEMAP ioctl, which is more efficient and faster (main character energy, no cap). And if FIEMAP is not supported? Bestie, it doesn't panic โ€” it falls back to using FIBMAP. Lowkey resilient ๐Ÿ’ช


๐Ÿ’… OPTIONS ๐Ÿ’…

  • -B โ€” Force the use of the older FIBMAP ioctl instead of the FIEMAP ioctl, for testing purposes. Retro era activated ๐Ÿ•ฐ๏ธ
  • -bblocksize โ€” Use blocksize in bytes, or with [KMG] suffix, up to 1GB, for output instead of the file system blocksize. For compatibility with earlier versions of filefrag, if blocksize is unspecified it defaults to 1024 bytes. And hear me out: since blocksize is an optional argument, it must be added without any space after -b. No space. Zero. Not even one. She's sensitive about it ๐Ÿ˜ญ
  • -e โ€” Print output in extent format, even for block-mapped files. Extent format era, periodt โœจ
  • -E โ€” Display the contents of ext4's extent status cache. Heads up though: this feature is not supported on all kernels, and it is only supported on ext4 file systems. So check before you get attached ๐Ÿ™ˆ
  • -k โ€” Use 1024-byte blocksize for output (identical to '-b1024'). Same vibe, shorter name ๐ŸŽ€
  • -P โ€” Pre-load the ext4 extent status cache for the file. Same disclaimer as before, bestie: not supported on all kernels, and only supported on ext4 file systems ๐Ÿ’€
  • -s โ€” Sync the file before requesting the mapping. Get it together first, then ask ๐Ÿ’ซ
  • -v โ€” Be verbose when checking for file fragmentation. She's a talker and honestly? We stan ๐Ÿ—ฃ๏ธ
  • -V โ€” Print version number of program and library. And if you give it twice, it also prints the FIEMAP flags that are understood by the current version. Double tap for extra lore ๐Ÿ‘‘โœจ
  • -x โ€” Display mapping of extended attributes. xattrs, but make it visible ๐ŸŒˆ
  • -X โ€” Display extent block numbers in hexadecimal format. Hex girlies rise up ๐Ÿ”ฅ

๐Ÿซถ AUTHOR ๐Ÿซถ

filefrag was written by Theodore Ts'o <tytso@mit.edu>. Shoutout to the icon who built her ๐Ÿ’–


ngl bestie, if you're checking fragmentation on an ext4 box and -E or -P just quietly doesn't work? That's the kernel talking, not you. It's literally not supported on all kernels. Not your fault, babe ๐Ÿ˜ญ

and that's the whole page, bestie!! this one's from E2fsprogs version 1.47.4, dated March 2025 โ€” so it's fresh, it's current, it ate and left no crumbs ๐ŸŒธโœจ๐Ÿฆ‹ mwah, go defrag something (or don't, it's a report tool, love that for us) ๐Ÿ’œ๐ŸŽ€

๐Ÿ“ฆ where this page comes from