commands

mkfs.ext4 — Create an ext4 filesystem

The executable is mkfs.ext4. Writes filesystem metadata to the target; use only a freshly created private regular image. Use a fresh private workspace; live operations are VM-only.

Formal Syntax & Structure

linux syntaxlinux
mkfs.ext4 [-L LABEL] IMAGE

Parameters & Attributes

NameTypeDescription
-LoptionFilesystem label
IMAGEoperandPrivate regular image

Return Value

exit status and output

Successful formatting creates filesystem metadata in the specified private image; inspect diagnostics and status before any later use. A format completion does not prove a successful mount or recovery of prior contents.

Working Example

Example Snippetlinux
test ! -e ./disk.img && test ! -L ./disk.img || exit 1(set -o noclobber; : > ./disk.img) || exit 1truncate -s 33554432 ./disk.img || exit 1test -f ./disk.img && test ! -L ./disk.img || exit 1mkfs.ext4 -L BM_LAB ./disk.img
Linux Reference