mkfs
Updated: September 28, 2024
Build a linux filesystem. This is a front-end for the various filesystem builders (mkfs.fstype).
Table of Contents
To see drives use inxi -Do
or fdisk -l
ARGUMENTS
mkfs [options] [-t type] [fs-options] device [size]
-h, --help # display help information.
-t, --type <type> # specify the type of filesystem to be built.
-v, --verbose # show commands as they are executed.
-V, --version # display version information.
BUILDERS
mkfs.ext4
-b <block-size> # specify the size of blocks. 1024, 2048, 4096 per block.
-c # check device for bad blocks before creating fs.
-d root-directory # copy contents of given dir into root dir of fs.
-l <filename> # read bad blocks list from filename.
-L <newname> # set new volume label for filesystem.
-n # dry run
-q # quiet execution. (useful for scripts)
-t <fstype> # specify file system type (ext2, ext3, ext4 etc)
-U <UUID> # Set the UUID of fs. (clear, random, time)
-v # verbose execution
-V # version number
-z <undo_file> # write old contents to undo_file that can be used later to restore.
EXAMPLES
mkfs -t ext4 /dev/sdb2
mkfs.ext4 /dev/sdb2
WINDOWS
You may need to install dosfstools if it is not on your system.
Make sure the drive is first unmounted before formatting. Example for sda2: umount /dev/sda2
sudo mkdosfs -F 32 -I /dev/sda2