The command to create a file system in Linux is mkfs
.
This command has several variations, each designed for a specific file system type. Here are some of the most common ones:
mkfs.ext4
: Creates an ext4 file system, the default file system for most modern Linux distributions.mkfs.ext3
: Creates an ext3 file system, a previous version of the ext4 file system.mkfs.ext2
: Creates an ext2 file system, an older version of the ext3 file system.mkfs.xfs
: Creates an XFS file system, known for its performance and reliability.mkfs.btrfs
: Creates a Btrfs file system, a modern file system with advanced features like snapshots and data integrity checks.
To use these commands, you need to specify the target device, for example, /dev/sdb1
.
Examples:
- Creating an ext4 file system on
/dev/sdb1
:sudo mkfs.ext4 /dev/sdb1
- Creating an XFS file system on
/dev/sdb1
:sudo mkfs.xfs /dev/sdb1
Remember to replace /dev/sdb1
with the actual device you want to format.
Before formatting a device, make sure you have a backup of any important data. Formatting a device will erase all data on it.