How to Format a Filesystem
There are several commands available which can format a Linux filesystem. All are based on the mkfs command, which includes extensions that describe the filesystem format, such as mkfs.ext2, mkfs.ext3, and mkfs.reiserfs. Closely related is the mkswap command, which formats a Linux swap partition. Of course, the commands discussed in this section should not be run on a mounted filesystem.
These commands are straightforward. The following command formats the /dev/ sdbl partition to the ext2 filesystem:
$ sudo mkfs.ext2 /dev/sdbl
|
Filesystem Type |
Description |
|
ext |
The first Linux filesystem, used only on early versions. |
|
ext2 |
A Linux filesystem in common use for smaller partitions such as the /boot directory; also known as the Second Extended Filesystem. |
|
swap |
The Linux swap filesystem is associated with dedicated swap partitions. |
|
msdos, fat16, vfat |
Microsoft formatted filesystems are generally recognized in Linux as the noted filesystem types. |
|
iso9660 |
The standard filesystem for CD/DVD media. |
|
ntfs, fuseblk |
The current Microsoft Windows filesystem. |
|
proc, sysfs, tmpfs, devfs |
Linux virtual filesystems. |
|
/dev/pts |
The Linux implementation for virtual terminals. |
|
nfs |
The Network File System, the system most commonly used to share files and printers between Linux and Unix computers. |
|
cifs, smb |
The Common Internet File System (CIFS) is the successor to the Samba/Server Message Block (SMB) system for shared directories. |
|
Table 5-3. Some Linux Standard Filesystem Types | |
|
Filesystem Type Description | |
|
ext3 |
The default filesystem |
|
reiserfs |
The Reiser File System is resizable and supports fast journaling; troubled due to the legal problems of its original developer |
|
xfs |
Developed by Silicon Graphics to support very large files, up to 9 x 1018 bytes |
|
Table 5-4. |
Journaling Filesystems |
The following command formats /dev/sdc2 to the Linux swap filesystem:
$ sudo mkswap /dev/sdc2
You can convert partitions between the ext2 and ext3 formats. As the only difference is the journal, you could add a journal to the ext2 formatted /dev/sdb1 partition with the following command:
$ sudo tune2fs -j /dev/sdbl
The journal can be removed with the following command:
$ sudo tune2fs -O *has_journal /dev/sdbl
Continue reading here: Manage Filesystems in etcfstab
Was this article helpful?