Linux mkfs command parameters and usage details---Linux Format file system commands (including swap partitions)

Source: Internet
Author: User
Tags what file system

MKFS command Linux Format Disk command

Linux mkfs directive: MKFS usage rights: Super User usage: MKFS [-v] [-t fstype] [fs-options]fileSYS [blocks] [-l lable] Description: Establish a Linux file system on a specific partition parameter: Device: Pre-check the hard drive partition, for example:/dev/sda1-v: Verbose display mode- T: Given the type of file system, the default value for Linux isexT2-c: Before making the file system, check whether the partition has a bad track-L Bad_blocks_file: The block data with the bad track is added to the Bad_blocks_file block: The size of the given block-L: Build L Able added: Mkfs itself does not perform the work of setting up the filesystem, but rather calls the relevant program to execute it. For example, if you specify Ext2 in the "-T" parameter, MKFS calls theMKE2FSTo create a file system. If you omit the "block number" parameter when you use it, MKFS automatically sets the appropriate number of blocks.   Example: Build a Msdos file system on/DEV/HDA5, check for bad tracks, and list the process in detail: mkfs-v-t msdos-c/dev/hda5 mfks-t Ext3/dev/sda6 Format SDA6 partition as ext3 format mkfs-t ext2/dev/sda7//Convert SDA7 partition to ext2 format extended knowledge: MKFS use example [[email protected] be inan]# mkfs-t File System storage device Note: Here the file system is to be specified, such as ext3; reiserfs; ext2; fat32; msdos, etc... Device such as a hard disk partition, floppy disk, CD-ROM, etc... ... Before you format the partition, you need to know how to view the partition of the hard disk and to format it accordingly;fdisk-L to view; Refer to: Linux view disk partitioning, file system, usage commands, and related tools for example I want to format a partition on a mobile USB drive, and the Panorama should be: [[email protected] beinan]# fdisk-l disk/dev/ hda:80.0 GB, 80026361856 bytes255 heads, sectors/TRAck, 9729 cylindersunits = cylinders of 16065 * mb = 8225280 bytes device Boot      start   &NBS P     End      blocks   Id  system/dev/hda1   *           1         765     6144831    7  hpfs/ntfs/dev/hda2             766        2805    16386300    c  w95 FAT32 (LBA)/dev/hda3 &NB Sp          2806        9729    55617030    5  extended /dev/hda5            2806        3825     8193118+  83 &N Bsp Linux/dev/hda6            3826        5100    10241406   &NBSP;LINUX/DEV/HDA7            5101        5198       787153+ &nbsp,  linux swap/solaris/dev/hda8            5199        6657 &nbs P  11719386   &NBSP;LINUX/DEV/HDA9            6658        775 1     8787523+  83  linux/dev/hda10           7752       &NBSP ; 9729    15888253+  83  linux disk/dev/sda:1035 MB, 1035730944 bytes256 heads, sectors/track , cylindersunits = cylinders of 16128 * 8257536 bytes device Boot      start     & nbsp   End      blocks   Id  system/dev/sda1               1 & nbsp        25      201568+  83  linux/dev/sda2              26              806400    5  extended/dev/sda5     &NBsp        26          50      201568+  83 &NBSP;LINUX/DEV/SD A6              51          76      200781 &nbs P    linux We can see the SDA this device, so you can use Fdisk-l/DEV/SDA specifically to show his partition situation, such as I want to format the/DEV/SDA6 partition as a ext3 file system, then:[[email  Protected] beinan]# mkfs-t ext3  /dev/sda6mke2fs 1.37 (21-mar-2005) Filesystem label=os type:linuxblock size=1024 (l og=0) Fragment size=1024 (log=0) 50200 inodes, 200780 blocks10039 blocks (5.00%) reserved for the suPer Userfirst Data block=1maximum filesystem blocks=6737100825 block groups8192 blocks per group, 8192 fragments per group Inodes per groupsuperblock backups stored on blocks:8193, 24577, 40961, 57345, 73729 Writing inode Tables:donecreati Ng Journal (4096 blocks): donewriting superblocks and FileSystem accounting infoRMation: Note: here direct enter; done this filesystem'll be automatically checked every mounts or180 days,whichEver comes first. Use tune2fs-c or-i to OverrIDE. So the format is good, Sda6 is now the ext3 file system, we can load this partition with mount, and then use this filesystem; [[email protected] beinan]#mkdir/MNT/SDA6 [[Email protected] beinan]#chmod777/MNT/SDA6 [[email protected] beinan]# Mount/dev/sda6/mnt/sda6 Of course you can also format the partition into other file systems; For example, we convert the/DEV/SDA6 format to Ext3, Ext2, R EISERFS, FAT32, MSDOS file system, the command format is as follows; [[email protected] beinan]# mkfs-t EXT3/DEV/SDA6 [[email protected] beinan]# mkfs-t EX T2/dev/sda6[[email protected] beinan]# mkfs-t reiserfs/dev/sda6[[email protected] beinan]# mkfs-t fat32/dev/sda6[ [Email protected] beinan]# mkfs-t Msdos/dev/sda6 ... 2)Mkfs.ext3 mkfs.reiserfs mkfs.ext2 mkfs.msdos Mkfs.vfat mke2fs Introduction; We'll start with a mkfs tool, and then we'll introduce Mkfs.ext3 Mkfs.reiserfs mkfs.ext2. Mkdosfs Mkfs.msdos Mkfs.vfat, in fact, mkfs in the execution of the command, is also called this tool, which is the main reason I introduced the mkfs first; through the file name, we know what file system these tools support These commands provide us with more convenience;   [[email protected] beinan]# mkfs.ext3   &NBSP;/DEV/SDA6     Note: Format the device as a ext3 file system [[email protected] beinan]# mke2fs-j  /DEV/SDA6       NOTE: Format the device as a ext3 file system [[ Email protected] beinan]# mkfs.ext2  /dev/sda6       NOTE: Format the device as a ext2 file system [email protected ] beinan]# mke2fs   &NBSP;/DEV/SDA6           NOTE: Format the device as a ext2 file system  [[email  Protected] beinan]# mkfs.reiserfs  /dev/sda6   NOTE: Format the device as a reiserfs file system [[email protected] beinan]# Mkfs.vfat  /DEV/SDA6         NOTE: Format the device as a FAT32 file system [[email protected] beinan]# Mkfs.msdos & nbsp /DEV/SDA6   NOTE: Format the device as a FAT16 file system, Msdos file system is fat16;[[email protected] beinan]# mKdosfs  /DEV/SDA6         NOTE: Format the device as a FAT16 file system, with MKFS.MSDOS&NBSP, ...    2) MkswapFormat a partition as swap zone; [[email protected] beinan]# MKSWAP/DEV/SDA6 Note: Create this partition for swap swap partitions [[email protected] beinan]#Swapon/DEV/SDA6 Note: Load swap partition; [[email protected] beinan]#Swapoff/DEV/SDA6 Note: Turn off swap partition, we check swap partition that the system has already loaded, [[email protected] beinan]# SWAPON/DEV/SDA6 Note: Load swap partition; [[email protected] Beinan ]# swapon-s Filename Type Size UsedPRIORITY/DEV/HDA7 Partition 787144 0-1/dev/sda6 Partition 225144 0-3<code> Why does my system have two swap partitions? Because I use the mobile drive to do experiments, mainly for the purpose of writing tutorials; Sda6 is the swap partition I built on the U disk;

If you let swap boot load, you should change the/etc/fstab file, add similar to the following line;

<code>/dev/sda6 swap Swap defaults 0 0 Note: Change the/DEV/HDA7 in this line to your swap partition, or write the command line directly /etc/rc.d/rc.local; Swapon/dev/sda6 If your hard drive is no longer partitioned, you can create a swap file [[email protected] beinan]#DDIf=/dev/zero Of=/tmp/swap bs=1024 count=524288 Note: Create a swap file of size 512M, in the/tmp directory; You can create swap files based on your desired size; Read 524288+0 A block output 524288+0 block [[email protected] beinan]# Mkswap/tmp/swap Note: Put/tmp/swap file, create swap area Setting up Swapspace version 1,   size = 536866 kbno label, Uuid=d9d8645d-92cb-4d33-b36e-075bb0a2e278[[email protected] beinan]# Swapon/tmp/swap Note: Mount Swap [[email protected] beinan]# swapon-sfilename Type Size used PRIORITY/DEV/HDA7 partition 787144 888-1/tmp/swap file 524 280 0-2 Note: In fact, when we installed the system, we have divided the swap partition, view/etc/fstab, should swap the line, if you do not add swap when installing the system, can be added by this method;

Linux mkfs command parameters and usage details---Linux Format file system commands (including swap partitions)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.