Skip to content

Linux mkfs Guide

Mattscreative edited this page Dec 5, 2025 · 2 revisions

Linux mkfs Guide

Complete beginner-friendly guide to mkfs on Linux, covering Arch Linux, CachyOS, and other distributions including creating filesystems, formatting partitions, and filesystem types.


Table of Contents

  1. Understanding mkfs
  2. mkfs Basics
  3. Filesystem Types
  4. Formatting Partitions
  5. Troubleshooting

Understanding mkfs

What is mkfs?

mkfs creates filesystem on device.

Uses:

  • Format partitions: Prepare partitions for use
  • Create filesystems: Set up filesystem structure
  • Initialize storage: Prepare new disks
  • Reformat: Change filesystem type

Warning:

  • Data loss: Erases all data on device
  • Backup first: Always backup important data
  • Double-check: Verify device before formatting

mkfs Basics

Basic Syntax

Format:

# General format
mkfs.fstype /dev/device

# Or
mkfs -t fstype /dev/device

Common Usage

Format partition:

# Format as ext4
sudo mkfs.ext4 /dev/sdb1

# Format as ext4 (alternative)
sudo mkfs -t ext4 /dev/sdb1

Filesystem Types

ext4

Most common:

# Format as ext4
sudo mkfs.ext4 /dev/sdb1

# With label
sudo mkfs.ext4 -L "MyDisk" /dev/sdb1

ext3

Older ext:

# Format as ext3
sudo mkfs.ext3 /dev/sdb1

ext2

Basic ext:

# Format as ext2
sudo mkfs.ext2 /dev/sdb1

Btrfs

Modern filesystem:

# Format as Btrfs
sudo mkfs.btrfs /dev/sdb1

# With label
sudo mkfs.btrfs -L "MyBtrfs" /dev/sdb1

XFS

High-performance:

# Format as XFS
sudo mkfs.xfs /dev/sdb1

FAT32

Compatibility:

# Format as FAT32
sudo mkfs.vfat /dev/sdb1

# Or
sudo mkfs.fat -F 32 /dev/sdb1

NTFS

Windows compatibility:

# Format as NTFS
sudo mkfs.ntfs /dev/sdb1

Formatting Partitions

Check Before Formatting

Verify device:

# List devices
lsblk

# Check current filesystem
sudo file -s /dev/sdb1

Format with Options

Advanced formatting:

# ext4 with options
sudo mkfs.ext4 -L "Data" -m 0 /dev/sdb1

# Options:
# -L: Label
# -m: Reserved blocks percentage

Troubleshooting

Format Errors

Check device:

# Unmount first
sudo umount /dev/sdb1

# Check for errors
sudo fsck /dev/sdb1

# Then format
sudo mkfs.ext4 /dev/sdb1

Device Busy

Fix busy device:

# Check what's using it
sudo lsof /dev/sdb1

# Or
sudo fuser -m /dev/sdb1

# Unmount
sudo umount /dev/sdb1

Summary

This guide covered mkfs usage, filesystem creation, and partition formatting for Arch Linux, CachyOS, and other distributions.


Next Steps


This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.

Clone this wiki locally