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

fsck

Check and repair file systems — the front end fsck, and e2fsck (= fsck.ext4) for ext2/3/4.

Niveau
RHCSA-examen
Groep
Schijven en bestandssystemen
Root nodig
Ja
Pakket
util-linux / e2fsprogs
Ook
e2fsck, fsck.ext4

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

Wat het doet

fsck DEVICE calls the checker for the file system type (for ext4: e2fsck). Run it on unmounted file systems only. At boot, systemd runs fsck for ext4 lines with a non-zero 6th field in fstab. For XFS use xfs_repair (fsck.xfs does nothing).

Zo schrijf je het

fsck [-lsAVRTMNP] [-C [FD]] [-t TYPE] [FS-OPTIONS] DEVICE...
e2fsck [-pacnyrdfkvtDFV] [-b SUPERBLOCK] [-B BLOCKSIZE] DEVICE

Opties 31

Meest gebruikt

fsck (front end)

-A
Check all file systems in /etc/fstab.
-R
With -A: skip the root file system.
-t TYPES
Only these types.
-N
Show what would be done.
-C [FD]
Show progress.
-M
Skip mounted file systems.
-P
With -A: check root in parallel with others.
-s
Serial, one at a time.
-T
No title.
-V
Verbose.
-l
Lock the whole disk.
-r [FD]
Report statistics.

e2fsck / fsck.ext4

-f
Force a check even when the file system looks clean.
-n
Read-only: answer no to all (check only).
-y
Answer yes to all repairs.
-p, -a
Repair safe problems automatically (preen).
-b SUPERBLOCK
Use a backup superblock (from dumpe2fs or mkfs -n).
-B BLOCKSIZE
Block size for -b.
-c
Check for bad blocks (twice = read-write test).
-l FILE, -L FILE
Add / set the bad block list.
-k
Keep existing bad blocks with -c.
-D
Optimize directories.
-E OPTIONS
Extended options.
-j JOURNAL
External journal.
-C FD
Progress to a file descriptor (0 = screen).
-F
Flush buffers first.
-t
Timing statistics.
-v
Verbose.
-d
Debug.
-z FILE
Undo file.
-V
Show the version.

Voorbeelden 10

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

  1. 1Check an ext4 file system

    umount /backup
    fsck.ext4 -f /dev/vdb3

    -f forces a full check.

  2. 2Check only, change nothing

    e2fsck -fn /dev/vdb3

    See the problems first.

  3. 3Repair everything without questions

    e2fsck -fy /dev/vdb3

    For many errors; check backups first.

  4. 4Use a backup superblock

    dumpe2fs /dev/vdb3 | grep -i 'backup superblock' | head -2
    e2fsck -b 32768 /dev/vdb3

    When the main superblock is broken.

  5. 5With progress

    e2fsck -f -C 0 /dev/vgdata/lvweb

    Progress bar for big disks.

  6. 6Dry run of fsck for fstab

    fsck -A -N

    Shows the checks it would run.

  7. 7Before shrinking (required)

    e2fsck -f /dev/vgfiles/lvdocs; resize2fs /dev/vgfiles/lvdocs 3G

    resize2fs asks for a fresh check.

  8. 8XFS? Use xfs_repair

    fsck.xfs /dev/vdb1

    Does nothing; xfs_repair is the tool.

  9. 9Force a check at the next boot

    tune2fs -C 100 -c 20 /dev/vdb3

    Mount count above the max = check at boot (for fstab entries with pass 2).

  10. 10Find bad blocks on an old disk

    e2fsck -fc /dev/vdb3

    Read test with badblocks.

Let op

  • Running fsck on a mounted file system can destroy it.

Exitcodes

0 :: No errors. 1 :: Errors were corrected. 2 :: Corrected; reboot needed. 4 :: Errors left uncorrected. 8 :: Operational error. 16 :: Usage error. 32 :: Cancelled by the user. 128 :: Shared library error.

Volledige handleiding

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

In je terminal: man 8 fsck