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

Source: Internet
Author: User

  MKFS command  linux formatted disk command           Linux mkfs         instruction: MKFS   With permissions: Super User usage: MKFS [-v] [-t fstype] [fs-options] filesys [blocks] [-l lable] Description: Build Linux file system on specific partition Parameters: Device: Pre-check hard drive partition, for example:/dev/sda1-v: Verbose display mode-T: For a given file system type, the Linux preset is ext2-c: Before making a file system, check the Partiti On whether there is a bad rail-l Bad_blocks_file: block data with bad rails is added to the Bad_blocks_file block: The size of the given block-L: Build lable           Supplemental Note:         &NBSP;MKFS itself does not perform the work of establishing a file system, but rather to invoke the relevant program to execute. For example, if you specify Ext2 in the "-T" parameter, then the         &NBSP;MKFS will invoke MKE2FS to establish the file system. If you omit the specified number of blocks parameter, MKFS automatically sets the     The appropriate number of blocks.   Example: Build a Msdos file system on the/DEV/HDA5 and check if there are bad tracks, and list the procedures in detail: mkfs-v-T msdos-c/dev/hda5           &NBSP;MFKS-T Ext3/dev/sda6  //SDA6 partition format ext3 format             MKFS-T E XT2/DEV/SDA7    //format SDA7 partitions into ext2 format   &nbsp     Extended Knowledge: Mkfs Use example     [root@localhost beinan]# mkfs-t file system   storage device   Note: The file system here is specified, such as Ext3, ReiserFS, EXT2, FAT32, MSDOS, etc. Equipment such as the partition of a hard disk, floppy disk, optical drive, etc... ... Before you format the partition, you have to know how to view the hard disk partitions, and the targeted format, such as using fdisk-l to view; Refer to: Linux view disk partitions, file systems, usage commands, and related tools for example, I want to format a mobile disk in a partition ; The panorama should be: [root@localhost beinan]# fdisk-l   disk/dev/hda:80.0 GB, 80026361856 bytes 255 heads, MB Sectors/track, 9 729 cylinders Units = cylinders of 16065 * (8225280 bytes   Device Boot      start         End      blocks   Id  system/dev/hda1   *           1         765     6144831    7  hpfs/ntfs/dev/hda2       &NBS P     766        2805    16386300    c  w95 FAT32 (LBA)/dev/hda3 &NB Sp          2806        9729 &nbsP  55617030    5  extended/dev/hda5            2806        3825     8193118+  83  linux/dev/hda6            3826   &NBS P    5100    10241406   &NBSP;LINUX/DEV/HDA7            5101 &nbs P      5198      787153+  82  linux swap/solaris/dev/hda8       &N Bsp    5199        6657    11719386    linux/dev/hda9     &NBS P      6658        7751     8787523+  83  linux/dev/hda10   &NB Sp       7752        9729    15888253+  83  linux   DISK/DEV/SDA : 1035 MB, 1035730944 bytes 256 heads, sectors/track, cylinders Units = cylinders of 16128 *-8257536 bytes Bsp; Device Boot      start         end      blocks   Id  system/d EV/SDA1               1          25      201568 +  83  linux/dev/sda2              26        -     806400    5  extended/dev/sda5              26   &NB Sp      50      201568+  83  linux/dev/sda6           &NBSP ;  51          76      200781      linux We can see SDA this device, so you can use Fdisk-l/DEV/SDA specifically to show his partitioning; for example, I want to format the/DEV/SDA6 partition as ext3 file system: [root@localhost beinan]# mkfs-t ext3  /dev/sda6 the Mke 2FS 1.37 (21-mar-2005) filesystem label= OS Type:linux block size=1024 (log=0) Fragment size=1024 (log=0) 50200 inodes, 2 00780 Blocks 100Blocks (5.00%) reserved for the super user-A-block=1 Maximum filesystem blocks=67371008 block groups 8192 b Locks per group, 8192 fragments/Group 2008 inodes per group superblock backups stored on blocks:8193, 24577, 40961, 5 7345, 73729   writing inode tables:done creating journal (4096 blocks): Done writing superblocks and filesystem Acco unting Info rmation:   Note: direct return here; done   This filesystem'll be automatically checked every-mounts or 180 day s, whichever comes.  use tune2fs-c or-i to Overr IDE. So the format is good, Sda6 is now the ext3 file system, we can load the partition with mount, and then use the file system; [Root@localhost beinan]# mkdir/mnt/sda6  [ Root@localhost beinan]# chmod 777/mnt/sda6  [root@localhost beinan]# mount/dev/sda6  /mnt/sda6 Of course you can also format the partition into Other file systems; For example, we format the/dev/sda6 as Ext3, ext2, REISERFS, FAT32, MSDOS file system, and the command format is as follows; [Root@localhost beinan]# mkfs-t ext3- / dev/sda6  [root@localhost beinan]# mkfs-t ext2  /dev/sda6 [root@localhost beinan]# mkfs-t ReiserFS  /dev/sda6 [root@localhost beinan]# mkfs-t FAT32  /DEV/SDA6 [root@localhost beinan]# mkfs-t-Msdos & nbsp /dev/sda6 ...   2) mkfs.ext3 mkfs.reiserfs mkfs.ext2 Mkfs.msdos Mkfs.vfat; After we've talked about a mke2fs tool, 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 I first introduced mkfs the main reason; by file name, We know what file systems are supported by these tools; These commands provide us with more convenience;     [root@localhost beinan]# mkfs.ext3   &NBSP;/DEV/SDA6     NOTE: Format the device as ext3 file system [root@localhost beinan]# mke2fs-j  /DEV/SDA6       NOTE: Format the device as a ext3 file system [Roo T@localhost beinan]# mkfs.ext2  /dev/sda6       NOTE: Format the device into ext2 file system root@localhost beinan]# mke2fs &NB Sp  /dev/sda6           NOTE: Format the device into ext2 file system   [root@localhost beinan]# Mkfs.reiserfs &NBSP;/DEV/SDA6   NOTE: Format the device into ReiserFS file system [root@localhost beinan]# mkfs.vfat  /dev/sda6       &N BSP; NOTE: Format the device into FAT32 file system [Root@localhost beinan]# Mkfs.msdos  /DEV/SDA6   NOTE: The device is formatted into a FAT16 file system, MSDOS file system is FAT16; [Root@localhost beinan]# Mkdosfs  /DEV/SDA6         NOTE: Format the device into FAT16 file system, mkfs.msdos  ...       2) Mkswap Format a partition as a swap swap area;   [root@localhost beinan]# mkswap/dev/sda6   NOTE: Create this partition for swap swap partitions   [root@localhost beinan]# swapon  /dev/sda6   NOTE: Load swap partition; [root@localhost beinan]# Swapoff  /dev/sda6   NOTE: Close swap partition; We look at the swap partition that the system has loaded; [root@localhost beinan]# swapon  /dev/sda6   Note: loading the swap partition; [Root@localhost beinan]#                 Filename                 & nbsp              type            size    u sed &nbs P &NBSP;PRIORITY/DEV/HDA7                               Partition       787144  0       -1/DEV/SDA6                               partition       225144  0      -3 <code>   Why My system has two swap partitions. Because I use a mobile disk to do the experiment, mainly for the use of the tutorial; Sda6 is the swap partition I built on U disk;   If let swap boot on the load, should be changed/etc/fstab file, add similar to the following line;


<code>/dev/sda6 Swap defaults 0 0 Note: Change the/dev/hda7 in this row to your swap partition; or write the command line directly In/etc/rc.d/rc.local also; Swapon/dev/sda6 if your hard disk cannot be partitioned, you can create a swap file [root@localhost beinan]# dd If=/dev/zero OF=/TMP/SW AP bs=1024 count=524288 Note: Create a swap file of size 512M, in the/tmp directory, you can create a swap file based on the size you want, read the 524288+0 block and output the 524288+0 block [root@l Ocalhost beinan]# mkswap/tmp/swap Note:/tmp/swap file, create swap swap area Setting up Swapspace version 1, size = 536866 KB No label, uuid=d9d8645d-92cb-4d33-b36e-075bb0a2e278 [root@localhost beinan]# swapon/tmp/swap Note: Mount swap [root@localhost Beinan] # swapon-s Filename Type Size Used priority/dev/hda7 partition 787144 888-1 file 524280 0-2 Note: Actually, when we were installing the system, The swap partition is already partitioned; View/etc/fstab, the line that should swap, and if you do not add swap when you install the system, you can add it by using this method;

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.