
mkfs.cramfs: Create a ROM filesystem
mkfs.cramfs: Create a ROM filesystem
Overview
- mkfs.cramfs builds a read-only, compressed ROM filesystem (CramFS) in a partition. It is lightweight and simple, but limited in features compared to modern filesystems.
Quick start
- Create a ROM filesystem in a partition:
mkfs.cramfs /dev/sdXY
- Create a ROM filesystem with a volume name:
mkfs.cramfs -n my_volume /dev/sdXY
Prerequisites and caveats
- Ensure the target partition is unmounted before creating the filesystem.
- This is a read-only filesystem once created; write operations require remaking the filesystem.
- Back up any data on the partition, as mkfs.cramfs will overwrite existing content.
- CramFS is older and has limited features compared to ext4, btrfs, or squashfs; verify it suits your use case.
Common pitfalls
- Wrong device path: double-check /dev/sdXY before running mkfs. A mistaken path can wipe data on a different partition.
- Not mounting: after creation, you must mount the filesystem to access data, e.g., mount /dev/sdXY /mnt.
- Size expectations: cramfs does not support certain advanced features like compression tuning; rely on default behavior.
Examples in context
- Create a ROM filesystem in /dev/sdb1:
mkfs.cramfs /dev/sdb1
- Create with a volume name and then mount:
mkfs.cramfs -n romimage /dev/sdb1
sudo mount -t cramfs /dev/sdb1 /mnt/rom
Tips
- Always verify the device path with lsblk or fdisk -l before running mkfs.
- If you need writable behavior or more features, consider newer filesystems.
- After mounting, remember that changes cannot be saved back unless you recreate the filesystem; use read-only for distribution images.
Troubleshooting
- If mounting fails with bad filesystem type, ensure the kernel supports cramfs and that the mkfs version matches expected format.
- Check dmesg for any filesystem-related errors after mounting.
- If you plan to distribute this image, test portability on the target hardware to ensure cramfs compatibility.
See Also
- How to Use the mv Command in Linux
- What Can You Do with the resolvectl Command in Systemd?
- How to Use BWA Command for Efficient DNA Alignment
- How to Use the dos2unix Command for File Conversion
- How to Use the ln Command for Effective File Management in Linux
- How to Use the awk Command in Linux for Text Processing