Disks and partitions need to be formatted before they could be mounted and used. Linux by default supports several filesystems, which would come with their pros and cons. Some of the popular supported filesystem types are ext4, Btrfs, and exFAT

There are many graphical tools to help with formatting disks and partitions in Linux. The one installed by default in most Linux distributions is mkfs, a command-line tool and probably the backend to most graphical tools.

Steps to format disk and partition in Linux:

  1. Launch terminal.
  2. List available disks and partitions in your system.

    $ lsblk NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT loop0    7:0    0  55.4M  1 loop /snap/core18/19 loop1    7:1    0  55.4M  1 loop /snap/core18/19 loop2    7:2    0    51M  1 loop /snap/snap-stor loop3    7:3    0   219M  1 loop /snap/gnome-3-3 loop4    7:4    0 217.9M  1 loop /snap/gnome-3-3 loop5    7:5    0  31.1M  1 loop /snap/snapd/104 loop6    7:6    0  62.1M  1 loop /snap/gtk-commo loop7    7:7    0  64.8M  1 loop /snap/gtk-commo loop8    7:8    0    51M  1 loop /snap/snap-stor loop9    7:9    0  31.1M  1 loop /snap/snapd/107 sda      8:0    0    20G  0 disk  ├─sda1   8:1    0     1M  0 part  ├─sda2   8:2    0   513M  0 part /boot/efi └─sda3   8:3    0  19.5G  0 part / sdb      8:16   0    20G  0 disk  └─sdb1   8:17   0    20G  0 part  sr0     11:0    1  1024M  0 rom

  3. Make sure disk or partition that you want to format is not already mounted or is in use.

    $ sudo umount /dev/sdb1 [sudo] password for user:  umount: /dev/sdb1: not mounted.

  4. Check supported filesystem for mkfs command.

    $ sudo mkfs. mkfs.bfs     mkfs.ext4    mkfs.ntfs mkfs.cramfs  mkfs.fat     mkfs.vfat mkfs.ext2    mkfs.minix    mkfs.ext3    mkfs.msdos

    Type mkfs. and press <TAB> twice for the terminal to show possible autompleted commands.

    Install necessary package if your desired filestem is not listed or supported.

  5. Format disk or partition using your preferred filesystem type.

    $ sudo mkfs.ext4 /dev/sdb1 mke2fs 1.45.6 (20-Mar-2020) Creating filesystem with 5242624 4k blocks and 1310720 inodes Filesystem UUID: ccab0f8d-3b5b-4189-9da3-23c49159c318 Superblock backups stored on blocks:  	32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,  	4096000  Allocating group tables: done                             Writing inode tables: done                             Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done

  6. Check current filesystem type to ensure disk or partition is successfully formatted.

    $ blkid /dev/sdb1  /dev/sdb1: UUID="ccab0f8d-3b5b-4189-9da3-23c49159c318" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="c088a647-01"

  7. Mount disk or partition as necessary.