Home / Alt manpages / mkfs.minix(8)

  • mkfs.minix(8)
  • Admin command
  • linux

Format a Minix Filesystem Safely with mkfs.minix

Reach for mkfs.minix when some embedded tool, old kernel build or compatibility test insists on the Minix filesystem and nothing newer will do. This walkthrough formats a disposable image first, then shows the version and size options you need for a real target. Allow about 10 minutes.

  • Part of util-linux, so it is already on the machine.
  • Works on a block device or a plain image file; the examples below use an image so nothing real is at risk.
  • Formatting a real device needs enough privilege to open it, usually sudo. Plain inspection does not.

Before you start

Check what you actually have installed before trusting the manpage word for word. On this machine mkfs.minix --version reports util-linux 2.41.3, while dpkg lists the installed util-linux package as 2.39.3-9ubuntu6.6. The binary and its manpage can drift apart like that, so run the version check on the host where you will actually work.

1. Check the version and help output

  • Run both commands. They cost nothing and confirm exactly what you have.
mkfs.minix --version
mkfs.minix --help

The long --version option cannot be combined with other options. The help output lists the short and long spellings the installed binary actually supports, which matters when a host is running a different util-linux release than you expect.

Destructive action

Creating a filesystem writes filesystem metadata over the target. On a partition or disk, that can make existing data unavailable. Confirm the path with a separate command such as lsblk, unmount it first, and check it again immediately before formatting. Recovery is restoring the overwritten data from a backup; mkfs.minix has no undo operation.

2. Practise on a throwaway image

  • Create a small image file. 4 MiB is plenty to see the tool work.
  • Format it with the default version. No extra flags needed for a first pass.
image=/tmp/minix-example.img
truncate -s 4M "$image"
mkfs.minix --lock "$image"

truncate creates the regular file that stands in for a device. --lock asks for an exclusive BSD lock while the command runs; give it no mode and it defaults to yes. Use it, since it cuts down collisions with anything else touching the device. Left to itself, mkfs.minix makes a version 1 filesystem with a 30-character filename limit.

A successful run returns status 0 and prints something like this:

1376 inodes
4096 blocks
Firstdatazone=47 (47)
Zonesize=1024
Maxsize=268966912

The inode count and other numbers shift with the image size and chosen format, so do not expect an exact match. Status 8 means an operational error; status 16 means a usage or syntax error. Read the full error text before trying again either way.

3. Choose the right filesystem version

Different versions exist for a reason: compatibility with a specific kernel, tool or embedded system, not because a higher number is better. Confirm what the consumer actually needs before picking one.

  • Version 1 is the default. 14 or 30-character filenames depending on flags.
  • Version 2 (-2, same as -v) also allows 14 or 30-character filenames.
  • Version 3 (-3) allows up to 60-character filenames.
image_v2=/tmp/minix-v2.img
truncate -s 4M "$image_v2"
mkfs.minix --lock -2 "$image_v2" 2048

The trailing 2048 requests that many filesystem blocks. It is a backwards-compatibility argument; leave it out and the size comes from the device. The local manpage documents counts greater than 10 and less than 65,536. Stay inside that documented range rather than trusting an older or newer binary to handle edge values the same way.

image_v3=/tmp/minix-v3.img
truncate -s 4M "$image_v3"
mkfs.minix --lock -3 -n 60 "$image_v3"

Useful controls for unusual media

  • -c checks for bad blocks before creating the filesystem and reports how many it found. Can take a while on real media.
  • -l filename reads a supplied bad-block list instead, one number per line, and reports how many entries it read.
  • -i number sets the inode count. Only touch this when you know the workload needs a different file count: too few starves you of files even with free space left; an arbitrarily large value just wastes space.

Both bad-block options are still part of the formatting operation: the target gets written either way, they just check first.

No lock is the default. Prefer --lock whenever another process might also touch the device or image. The LOCK_BLOCK_DEVICE environment variable can request locking with 1 or turn it off with 0, but an explicit --lock flag wins over either setting. If locking fails unexpectedly, go find out what else is holding the device rather than formatting a different one by guesswork.

4. Verify, then clean up

  • Capture the exit status immediately after the format command, in your own shell.
  • Inspect the image before trusting it for anything real.
status=$?
printf 'mkfs.minix exit status: %s\n' "$status"
file /tmp/minix-example.img

A zero status means the command reported no errors, not that you picked the right device. For anything real, run the matching Minix checking tool before mounting or handing the device off, and keep the formatting output alongside your change record.

These examples only touched files under /tmp. Remove them with your normal temp-file cleanup once you are done. If you formatted a real device by mistake, stop writing to it immediately and fall back on your backup or data-recovery procedure.

Done means

  • Target confirmed. The path was independently identified and was not mounted or needed elsewhere.
  • Version matches the consumer. The Minix version and filename length fit what will actually read it.
  • Exit status recorded. mkfs.minix returned 0 and the output was kept.
  • Locking used where it matters. --lock was set whenever another process could touch the device.
  • Extras were deliberate. Any bad-block check, inode choice or explicit block count was a considered decision, not a default left on autopilot.