• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

mkfs Command Examples in Linux

by admin

The mkfs command is used to build a Linux file system on a device, which is usually a drive partition. The below table lists some options of the mkfs command and their descriptions.

Option Used To
-v Produce verbose output
-V Produce verbose output including file-system specific command
-t {fstype} Specify type of file system to build
fs-options Pass file system specific options to builder
-c Check device for bad blocks before building
-l {file-name} Read list of bad blocks from file

Syntax

One syntax option of the mkfs command is:

# mkfs [options] {device name}

Another syntax option is:

# mkfs.{file system type} [options] {device name}

Creating a file system on a partition.

fdisk command options

mkfs Command Examples

1. To make the file system:

# mkfs /dev/sda2 

2. To produce the verbose output:

# mkfs -V /dev/sda2 

3. To specify the file system type:

# mkfs -t fstype /dev/sda2 

4. To file system-specific options to be passed to the real file system builder:

# mkfs fs-options 

5. To check the device for bad blocks before building the file system:

# mkfs -c 

6. To read the bad blocks list from filename:

# mkfs -l filename 

7. To produce the verbose output:

# mkfs -v /dev/sda2 

Filed Under: Linux

Some more articles you might also be interested in …

  1. Linux: No space left on device while df command shows a lot of free space
  2. RHEL/CentOS 6,7 : How to caculate the size of hugepage used by a specific process/application
  3. resize2fs Command Examples in Linux
  4. /var/cache/yum Constantly Filling Files System in CentOS/RHEL
  5. How to add header and trailer line to a file in Linux
  6. Unable to set a GRUB password on a Raspberry Pi 3 system
  7. System Log File /var/log/messages Is Getting Deleted or Trimmed Automatically (CentOS/RHEL)
  8. How To Create/Remove and Mount a Stratis Filesystem in CentOS/RHEL 8
  9. How to convert text files to all upper or lower case
  10. How To Auto Mount a FileSystem Using Systemd

You May Also Like

Primary Sidebar

Recent Posts

  • What are /dev/zero and /dev/null files in Linux
  • grpck command – Remove corrupt or duplicate entries in the /etc/group and /etc/gshadow files.
  • xxd command – Expressed in hexadecimal form
  • sesearch: command not found

© 2022 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright