Search

Linux File System Management Tools - mkfs, mkfs.ext2, mkfs.ext3 commands - Standard Linux File systems

The Linux mkfs command can be used to format a Linux partition. The Linux "mkfs" command allows you to format a partition to a number of different filesystems. The Linux "mkfs" command also serves as a "front end," depending on the filesystem format. if you're formatting a standard ext3 filesystem, mkfs automatically calls the mkfs.ext3 command. The following commands show how create a partition using "fdisk" command and how to format the new partion using "mkfs" command.

[root@localhost ~]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.

The number of cylinders for this disk is set to 1044.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1044, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-1044, default 1044):
Using default value 1044

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

The above set of fdisk commands create /dev/sdb1 partition. After creating the partition, we can overlay a filesystem (format) using mkfs command as shown below.

[root@localhost ~]# mkfs -t ext3 /dev/sdb1
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
1048576 inodes, 2096474 blocks
104823 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2147483648
64 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 20 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.

Other Linux tools to create filesystems

 

• mkfs.ext2 command can be used to format a partition with ext2 filesystem.


• mkfs.ext3 command can be used to format a partition with ext3 filesystem.


• mkfs.msdos (or mkfs.vfat or mkdosfs) formats a partition to the Microsoft-compatible VFAT filesystem (The inode numbers for all three files are the same; that means they are three different names for the same command).


• mkswap command can be used to format a partition with Linux swap filesystem.

 

Standard Linux Filesystem Formats

 

Filesystem Type

Description

ext

The first Linux filesystem used on early versions.

ext2

The most featureful of the native Linux filesystems, but with no journaling support.

ext3

The ext3 filesystem has all the features of the ext2 filesystem with journaling has been added.

swap

The Linux swap filesystem is associated with dedicated swap partitions.

reiserfs

A stable journaled filesystem.

Jfs

JFS is a journaled filesystem designed by IBM to to work in high performance environments

vfat

VFAT lets you read Windows 9x/NT/2000/XP/Vista partitions formatted to the FAT16 or FAT32 filesystems.

iso9660

The standard filesystem for CD-ROMs

ntfs

The Microsoft Windows NT/2000/XP/2003/2008 filesystem designed for username/password security.

/proc

A Linux virtual filesystem. Virtual means that it doesn't occupy real disk space. Instead, files are created as needed. Used to provide information on kernel configuration and device status.

/dev/pts

The Linux implementation of the Open Group's Unix98 PTY support.

nfs

The Network File System, the system most commonly used to share files and printers between Linux and Unix computers.

cifs

The Common Internet File System (CIFS) is used to to share files and printers with Microsoft Windows operating systems.

Related Tutorials
• Linux File System Management Tools - fdisk command
• What is file system journaling?
• Linux File System Management Tools - fsck command
• Introduction to Linux /etc/fstab file
• Linux mount and umount commands
• Linux mount options