Mkfs Partition

Mkfs Partition
mkfs is used to build a Linux file system on a device, usually a hard disk partition. filesystem is either the device name (e.g. /dev/hda1, /dev/sdb2) or the mount point (e.g. /, /usr, /home) for the file system. blocks is the number of blocks to be used for the file system. mkfs is a command used to format a block storage device with a specific filesystem. The command is part of UNIX and UNIX-like operating systems. In UNIX, a block storage device must be formatted with a file system before it can be mounted and accessed through the operating system’s filesystem hierarchy.


build a Linux file system

mkfs -t <fs type> <device>

mkfs -t ext4 /dev/sda1


Using Mkfs
The type defaults to the old ext2 type, but for modern Linux hard disk systems you should always specify the type explicitly as either ext3 or ext4. These newer file system types are journalling file systems.
The mkfs commands do not care about the System ID (type) of a partition given in the partition table. You can create any type of file system in any type of partition.
Creating a partition with fdisk does not automatically create any type of file system in that partition.
Creating a file system with mkfs does not automatically mount or make available that file system for use in Linux.

Produce verbose output, including all file system-specific commands that are executed. Specifying this option more than once inhibits execution of any file system-specific commands. This is really only useful for testing.
-t fstype
Specifies the type of file system to be built. If not specified, the default file system type (currently ext2) is used.
File system-specific options to be passed to the real file system builder. Although not guaranteed, the following options are supported by most file system builders.
Check the device for bad blocks before building the file system.
-l filename
Read the bad blocks list from filename
Produce verbose output.

mkfs help

FDisk Partition

Disk Partitioning
Disk partitioning is the creation of one or more regions on a hard disk or other secondary storage, so that an operating system can manage information in each region separately.[1] Partitioning is typically the first step of preparing a newly manufactured disk, before any files or directories have been created. The disk stores the information about the partitions locations and sizes in an area known as the partition table that the operating system reads before any other part of the disk.


Fdisk Partition
Actually partition your hard drive with the fdisk utility. Linux allows only 4 primary partitions.

Four Primary Partitions
Mixed Partitions
Logical Partitions

Fdisk Usage
fdisk is started by typing (as root) fdisk device at the command prompt. device might be something like /dev/hda or /dev/sda. The basic fdisk commands are.

fdisk Options

toggle a bootable flag

edit nested BSD disklabel

toggle the dos compatibility flag

delete a partition
list known partition types
add a new partition
print the partition table
change a partition type
verify the partition table

print this menu
change display/entry units
extra functionality (experts only)

Save & Exit
write table to disk and exit
quit without saving changes

Create a new label

create a new empty GPT partition table
create a new empty SGI (IRIX) partition table
create a new empty DOS partition table
create a new empty Sun partition table

Partition Table
Command (m for help): p  
Disk /dev/sda1: 296.2 GiB, 318068752384 bytes, 621228032 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x7142a2bc

Partition Table

Deleting Partition
Command (m for help): d
No partition is defined yet!
Could not delete partition 11

Deleting Partition

Creating Partition
Command (m for help): n
Partition type
p   primary (0 primary, 0 extended, 4 free)
e   extended (container for logical partitions)
Select (default p): e
Partition number (1-4, default 1): 1
First sector (2048-621228031, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-621228031, default 621228031):

Created a new partition 1 of type ‘Extended’ and of size 296.2 GiB.

Creating Partition