Hands-on guide that shows how the `mkfs` command creates filesystems so you can store data safely. 10.04.2026 | reading time: 3 min When you attach a new disk or build an image file, the `mkfs` family writes a filesystem structure so Linux can store files; this short guide shows how to do that safely and practically. Make an ext4 image Follow these commands to create a 64MiB image, attach it as a loop device, format it as ext4, mount it and then clean up: ```bash dd if=/dev/zero of=disk.img bs=1M count=64 sudo losetup -f --show disk.img # output example: /dev/loop0 sudo mkfs.ext4 /dev/loop0 # example output: Creating filesystem with 16384 1k blocks and 4096 inodes sudo mkdir -p /mnt/tmpimg && sudo mount /dev/loop0 /mnt/tmpimg ls -la /mnt/tmpimg sudo umount /mnt/tmpimg sudo losetup -d /dev/loop0 ``` Practice on an image file first to avoid destroying real data. Options that matter `mkfs` is a dispatcher that usually calls `mkfs.<type>`; common options you will use are the filesystem type with `-t`, labels with `-L`, force with `-F`, and filesystem-specific tuning like reserved blocks or inode size, and `-c` to check for bad blocks when supported, but remember: formatting erases existing data. When and where to use it Use `mkfs` after partitioning with `fdisk` or `parted`, or on whole devices for removable media and virtual disks; choose ext4 for general use, xfs for large single files and throughput, btrfs for snapshots, and vfat for cross-platform compatibility, and always verify with `lsblk` and `blkid` before mounting. Quick safety checklist Always confirm the target device with `lsblk` or `blkid`, unmount the device before formatting, keep backups of important data, and prefer testing on image files or secondary disks when learning new filesystem types. Next steps Mastering `mkfs` unlocks control over storage layout, performance and recovery; keep experimenting with filesystem types and options, and consider formalizing your skills with certifications like CompTIA Linux+ or LPIC-1 and intensive exam preparation at bitsandbytes.academy to go deeper. Join Bits & Bytes Academy First class LINUX exam preparation. filesystem utilities storage