The mkfs
command in Bash is used to create a file system on a specified device or partition. This command is essential for preparing storage devices for use, allowing the operating system to manage files and directories on that device.
The basic syntax of the mkfs
command is as follows:
mkfs [options] [arguments]
-t, --type
: Specify the type of file system to create (e.g., ext4, vfat).-L, --label
: Assign a label to the file system.-n, --no-mount
: Do not mount the file system after creation.-V, --verbose
: Provide detailed output during the execution of the command.Here are some practical examples of using the mkfs
command:
mkfs -t ext4 /dev/sdb1
mkfs -t vfat -L MY_USB /dev/sdc1
mkfs -t ext3 -n /dev/sda1
mkfs -t ext4 -V /dev/sdd1
mkfs
, as it will erase existing data on the specified device.-L
option to give your file system a recognizable label, making it easier to identify later.lsblk
or fdisk -l
to avoid formatting the wrong partition.