Filters
Zo zoek je
  • Gewone woorden vinden namen, teksten en voorbeelden.
  • "twee woorden" vindt precies die zin.
  • --naam of -x vindt een optie.
  • #woord zoekt alleen in commando's.
  • @grep vindt lessen en labs die grep gebruiken.
  • Filters: cat:network · in:labs · in:notes · level:rhcsa · ch:8 · root:yes. Zet ! voor een woord om het weg te laten. OR tussen woorden betekent één ervan.
  • ↑ ↓ bewegen · Enter openen · Esc sluiten · / zoeken

mkfs

Create a file system on a partition or volume (front end for mkfs.xfs, mkfs.ext4, mkfs.vfat …).

Niveau
RHCSA-examen
Groep
Schijven en bestandssystemen
Root nodig
Ja
Pakket
util-linux

Dit deel is nog niet vertaald. Je ziet de Engelse tekst.

Wat het doet

mkfs -t TYPE DEVICE calls the program mkfs.TYPE. On RHEL the main types are xfs (default), ext4 and vfat. All options after the type go to that program. Creating a file system deletes everything that was on the device.

Zo schrijf je het

mkfs [-t TYPE] [FS-OPTIONS] DEVICE [SIZE]

Opties 5

Meest gebruikt

-t, --type TYPE
The file system type (default ext2 — always give it).
FS-OPTIONS
Options for the real mkfs program (like -L label).
-V, --verbose
Show what is run.
-h, --help
Show help.
--version
Show the version.

Voorbeelden 10

$ als gewone gebruiker# als root (of met sudo)

  1. 1XFS file system

    mkfs -t xfs /dev/vdb1

    Same as mkfs.xfs /dev/vdb1.

  2. 2ext4 with a label

    mkfs -t ext4 -L backup /dev/vdb2

    The label goes to mkfs.ext4.

  3. 3Which mkfs programs exist?

    ls /usr/sbin/mkfs.*

    The types you can use.

  4. 4Check the disk first

    lsblk -f /dev/vdb

    Make sure the partition is empty or not needed.

  5. 5FAT for a USB stick

    mkfs -t vfat -n USBKEY /dev/sdc1

    Readable on Windows and macOS.

  6. 6On an LVM logical volume

    mkfs -t xfs /dev/vgdata/lvweb

    Same as on a partition.

  7. 7See what would be run

    mkfs -V -t ext4 /dev/vdb2

    Prints the real command.

  8. 8Overwrite an old file system

    mkfs -t xfs -f /dev/vdb1

    mkfs.xfs needs -f when it finds an old file system.

  9. 9Remove old signatures first

    wipefs -a /dev/vdb1; mkfs -t xfs /dev/vdb1

    Clean start.

  10. 10Check the result

    blkid /dev/vdb1

    Shows TYPE and the new UUID.

Let op

  • Without -t, mkfs creates ext2. Always give the type.
  • The wrong device = lost data. Check with lsblk -f.

Exitcodes

0 :: Done. 1 :: Error.

Volledige handleiding

Deze pagina legt het commando uit in eenvoudige woorden. De originele handleiding heeft elk detail.

In je terminal: man 8 mkfs