mkfs
| mkfs | |
|---|---|
| Original authors | Ken Thompson, Dennis Ritchie |
| Developer | AT&T Bell Laboratories |
| Initial release | 1979 |
| Operating system | Unix and Unix-like |
| Type | Command |
In Unix and Unix-like operating systems, mkfs is a command used to format a block storage device with a specific file system. In those systems, 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.
In 4.2BSD, newfs was a front end for mkfs; in 4.3-Tahoe, newfs replaced mkfs.
History
[edit]The command was originally implemented in the first version of Unix as a method to initialize either a DECtape (using the "t" argument) or an RK03 disk pack (using the "r" argument).[1] The initialization process would write formatting data to the device so that it contained an empty file system. It created the super-block, i-list, and free list on the storage device and established the root directory with entries for "." and ".." (self and parent, respectively). The RK03 disk packs had 4872 available blocks after initialization, while the tapes had 578 blocks (at 512 bytes/block).[2] The mkfs executable was kept in the /etc directory instead of a binary directory so it would not be inadvertently called and destroy information.
In Version 6 Unix, mkfs took, as its second argument, the name of a file containing parameters to be used when creating the file system; if the file cannot be opened, it's treated as the number of blocks in the partition in which the file system is being created.[3] The mkfs in Version 7 Unix was the same.[4] Unix System III added some optional arguments.[5]
4.2BSD added newfs as a front end for mkfs;[6] in 4.3-Tahoe,newfs replaced mkfs.[7]
Many Unix-like operating systems include the mkfs command, the newfs command, or both. This includes HP-UX,[8] Minix,[9] SunOS,[10][11] Solaris[12] and Linux.[13]
Syntax
[edit]The basic syntax of the command, which is common to all modern implementations, is:
$ mkfs -t <fs type> <device>
where 'fs type' is the type of the filesystem and 'device' is the target UNIX device to write the filesystem data to. Usually the "device" is a drive partition. Often the command is simply a wrapper for another command that performs the formatting for a specific file system. For example,
$ mkfs -t ext3 /dev/sda1
would call the command mke2fs while passing along the appropriate arguments to format the device /dev/sda1 with the ext3 filesystem. The default options for the command are stored in the file mke2fs.conf, usually in the /etc directory. Depending on the implementation and the specific file system requested, the command may have many options that can be specified such as inode size, block size, volume label, and other features.[14] (See file system for details)
The filesystem-specific commands that mkfs calls may be invoked directly by the user from the command line. In Linux, the convention has been to name the filesystem-specific commands as: mkfs.<fs-type>. Where <fs-type> is an abbreviation for the file system, e.g., mkfs.ext2, mkfs.msdos, mkfs.minix, etc. File systems supported by the command vary by implementation and include: MSDOS, SCO bfs, CPM, ext2, ext3, ext4, minix, fat (vfat), HFS, VXFS, RF disk, RK disk, DECtape, and NTFS.
See also
[edit]- dd — convert and copy a file
- e2fsprogs — a set of utilities for maintaining the ext2, ext3 and ext4 file systems
- fdisk — examine and write partition table
- format — create a file system on DOS or Windows
- fsck — file system check
- mkisofs — make an iso file system
- mount — mount a file system
- parted — partition manager
References
[edit]- ^ "mkfs(1) - Unix First Edition Manual Page". man.cat-v.org. Retrieved 2013-04-30.
- ^ "file(5) - Unix First Edition Manual Page". man.cat-v.org. 1971-01-01. Retrieved 2013-04-30.
- ^ – Version 6 Unix Programmer's Manual
- ^ – Version 7 Unix Programmer's Manual
- ^ Unix User's Manual (PDF). Bell Telephone Laboratories. 1980. MKFS(1M).
- ^ "4.2BSD newfs(8) man page source". 20 February 1983.
- ^ "4.3-Tahoe newfs(8) man page source". October 1, 1987.
- ^ Section 1M: System Administration Commands (A-M) HP-UX 11i Version 3. HP-UX Reference. Hewlett Packard Enterprise. 2007. mkfs(1M).
- ^ "MKFS 1". Minix3.org. Archived from the original on 2013-07-02. Retrieved 2013-04-30.
- ^ SunOS Reference Manual (PDF). Sun Microsystems. 1988. MKFS(8).
- ^ SunOS Reference Manual (PDF). Sun Microsystems. 1988. NEWFS(8).
- ^ "SunOS 5.10. 17 Nov 2000". Archived from the original on 26 November 2005. Retrieved 2 February 2013.
- ^ The Linux man-pages Project
- ^ "E2fsprogs version 1.41.9. August 2009". Archived from the original on 2013-02-17. Retrieved 2013-02-02.