fsck.cramfs - Linux


Overview

fsck.cramfs is a utility used to check and repair inconsistencies in a CramFS filesystem (Compressed Read-only Advanced Multi-File System). It is commonly utilized to verify the integrity of CramFS filesystems in embedded systems and other scenarios where read-only storage is preferred.

Syntax

fsck.cramfs [options] <device>

Options/Flags

| Option | Description | Default |
|—|—|—|
| -b | Checks the block device containing the CramFS | N/A |
| -f | Forces the check and repair process | N/A |
| -h | Displays help and usage information | N/A |
| -l | Lists the files and directories in the CramFS | N/A |
| -p | Prints the contents of corrupted files | N/A |
| -r | Repairs any detected inconsistencies | N/A |
| -s | Prints statistics about the CramFS | N/A |
| -v | Enables verbose output | N/A |

Examples

Basic usage (check device):

fsck.cramfs /dev/mmcblk0p1

Repair corrupted files:

fsck.cramfs -r /dev/mmcblk0p1

List files in CramFS:

fsck.cramfs -l /dev/mmcblk0p1

Common Issues

  • Cannot access device: Ensure that the specified device is properly formatted as a CramFS filesystem.
  • Corrupted files: If corrupted files are found, consider using the -r option to repair them.
  • Filesystem errors: If filesystem errors are reported, they may need to be fixed manually using other tools or by re-flashing the device.

Integration

Using with other commands:

  • mount to mount the CramFS filesystem after checking and repairing.
  • losetup to loopback the CramFS file (-b option) to fsck.cramfs.

Example script:

#!/bin/bash

# Mount the USB drive
sudo mount /dev/sda1 /mnt

# Check and repair the CramFS filesystem
fsck.cramfs -r /dev/sda1

# Display the contents of the filesystem
ls -la /mnt

Related Commands

  • fsck – Generic file system checker
  • cramfsck – Alternative CramFS checker
  • mkcramfs – Utility to create CramFS filesystems