Linux file system creation, formatting, modification, detection

Source: Internet
Author: User
Tags deprecated uuid

Objective:

This article consumes the author a lot of time to write, reprint statement anyisalin.blog.51cto.com.




Most of this paper is a process of operation, not too much elaboration of theoretical knowledge



1, the creation of file system

There are several tools that we use to create a filesystem on Linux: fdisk,parted, where we explain only Fdisk.


The syntax of the FDISK command

fdisk [Options] ... [Device file]


Common options for FDISK commands

-l [Device file]: No device file path displays information about all disk partitions on the system, plus the device file path displays the partition information for the specified disk


No parameter display, as shown in the partition information for SDA and SDB

650) this.width=650; "src=" Http://www.178linux.com/ueditor/php/upload/image/20160303/1457011014657329.png "title= "1457011014657329.png" alt= "Blob.png" style= "white-space:normal;"/>


Add parameter display For example, only display the SDA partition information

650) this.width=650; "src=" Http://www.178linux.com/ueditor/php/upload/image/20160303/1457010983403936.png "title= "1457010983403936.png" alt= "Blob.png" style= "white-space:normal;"/>


Sub-options for FDISK commands

The main function of the FDISK command is the implementation of the sub-options.

fdisk /dev/sdb   #通过这个指令进入fdisk的命令模式对sdb进行操作Device  contains neither a valid  DOS partition table, nor Sun, SGI or OSF disklabelBuilding  A new dos disklabel with disk identifier 0xf92588db. changes will remain in memory only, until you decide to  Write them. After that, of course, the previous content won ' t be recoverable. warning: invalid flag 0x0000 of partition table 4 will be  Corrected by w (rite) warning: dos-compatible mode is deprecated. it ' s  strongly recommended to         switch off  the mode  (command  ' C ')  and change display units to          sectors  (command  ' u '). command  (m for help):  mcommand action   a   toggle  a bootable flag     #设置引导扇区    b   edit  bsd disklabel       c   toggle the dos  compatibility flag   d   delete a partition      #删指定分区    l   list known partition types      #列出分区ID列表    m   print this menu          #显示帮助手册    n   add a new partition      #添加一个新的分区    o   create a new empty DOS  Partition table       p   print the partition table     #显示分区表    q   quit without  saving changes     #不保存退出    s   create a new  empty sun disklabel       t   change a  partition ' s system id     #改变分区的系统ID    u    change display/entry units       v   verify  the partition table     #检查分区表    w   write  table to disk and exit     #将修改保存分区表并退出    x    extra functionality  (experts only)         ## There are some operations as I am not commonly used, so do not add comments command  (M FOR HELP):


If you don't practice fake bashi, you can create a new partition with me on the SDB hard drive!

[[email protected] ~]# fdisk /dev/sdb     #对sdb硬盘进行操作WARNING:  Dos-compatible mode is deprecated. it ' s strongly recommended to          switch off the mode  (command  ' C ')  and  change display units to         sectors   (command  ' u '). command  (m for help): n     #创建一个新的分区Command  action    e   extended     #扩展分区    p   primary  partition  (1-4)    #主分区p      #指定创建分区为主分区Partition  number  (1-4) : 1         #指定分区编号First  cylinder  (1-2610, default  1):      #指定起始柱面Using  default value 1last cylinder, + Cylinders or +size{k,m,g}  (1-2610, default 2610): +10g         #创建大小为10G的分区  Command  (m for help): t   selected  partition 1hex code  (type l to list codes): 83     #修改分区系统ID为83, in fact, using FDISK in Linux to create the partition default ID is 83, you can not modify command  (M FOR HELP): p      #显示当前分区表Disk  /dev/sdb: 21.5 GB, 21474836480 bytes255 heads, 63  sectors/track, 2610 cylindersunits = cylinders of 16065 * 512 =  8225280 bytesSector size  (logical/physical): 512 bytes / 512  bytesi/o size  (Minimum/optimal):  512 bytes / 512 bytesdisk identifier:  0xdee177d5   Device Boot      Start          End      Blocks   Id  System/dev/sdb1                1         1306    10490413+  83  LinuxCommand  (M  FOR HELP): w     #将修改写入分区表并退出The  partition table has  been altered! Calling ioctl ()  to re-read partition table. Syncing disks.


But a lot of careful classmates will find that we just created the partition, but the kernel does not recognize the partition

650) this.width=650; "src=" Http://www.178linux.com/ueditor/php/upload/image/20160303/1457011877455930.png "title= "1457011877455930.png" alt= "Blob.png" style= "white-space:normal;"/>

In a Linux system, when a partition is modified, it needs to be manually advertised to the kernel or restarted to recognize the newly created partition.

Partx-a/dev/sdb #使用partx命令手动通告内核重新读取分区表partx的基本选项-A [HDD file]: Advertise the modification of the specified device partition or all partitions to the kernel-n [m,n]: advertises modifications of devices in the M-to-N range to the kernel

650) this.width=650; "src=" Http://www.178linux.com/ueditor/php/upload/image/20160303/1457012074739540.png "title= "1457012074739540.png" alt= "Blob.png" style= "white-space:normal;"/>





2. File system formatting

Cat/proc/filesystems #查看当前系统支持的文件系统



MKFS Command usage:

Mkfs. Fstype/dev/partition #将指定分区格式化为指定文件系统 For example # MKFS.EXT4/DEV/SDB1

MKFS supported in centos6.7 format, CENTOS7 supports more advanced file systems such as Btrfs,xfs

650) this.width=650; "src=" Http://www.178linux.com/ueditor/php/upload/image/20160303/1457012945987426.png "title= "1457012945987426.png" alt= "Blob.png" style= "white-space:normal;"/>


[[email protected] ~]# mkfs.ext4 /dev/sdb1     #格式化分区sdb1为ext4分区mke2fs  1.41.12  (17-may-2010) filesystem label=os type: linuxblock size=4096  (log=2 ) fragment size=4096  (log=2) stride=0 blocks, stripe width=0 blocks655776  inodes, 2622603 blocks131130 blocks  (5.00%)  reserved for the super  userFirst data block=0Maximum filesystem blocks=268854886481 block  Groups32768 blocks per group, 32768 fragments per group8096 inodes  per groupSuperblock backups stored on blocks: 32768, 98304,  163840, 229376, 294912, 819200, 884736, 1605632writing inode tables:  done                             creating journal  (32768 blocks):  donewriting superblocks  and filesystem accounting information: donethis filesystem will be  automatically checked every 23 mounts or180 days, whichever  Comes first.  use tune2fs -c or -i to override.



Mke2fs:ext Series file system dedicated management tools

Common options:-t {ext2|ext3|ext4}-b {1024|2048|4096} block size, default block size of 4096-l ' LABEL ': Specifies the volume label-j equivalent to-t ext3-i # to create an inode for each number of bytes in the data space, This size should not be less than the block size-N # Number of inode-m created for the data space # The percentage of space reserved for the manager-O FEATURE [...] : Starts the specified attribute-o ^feature: Turns off the specified attribute


Mkswap: Creating Swap partitions

Mkswap [OPTIONS] device-l ' LABEL ' # #使用前提, partition for formatting or resizing partition ID 82



Other common tools:

Blkid: Block Device properties Information view

650) this.width=650; "src=" Http://www.178linux.com/ueditor/php/upload/image/20160303/1457013200210678.png "title= "1457013200210678.png" alt= "Blob.png"/>

Blkid [OPTION]: [Device]-u UUID: Find device based on specified UUID-l LABEL: find corresponding device according to specified volume label


E2label: Manage Label for ext series File system

E2label DEVICE [LABEL]

650) this.width=650; "src=" Http://www.178linux.com/ueditor/php/upload/image/20160303/1457013275707959.png "title= "1457013275707959.png" alt= "Blob.png"/>

TUNE2FS: Reset the values of the EXT series file system adjustable parameters

-L: View specified file system Super block information, Super block-l ' LABEL ': Modify volume Label-M #: Percentage of space reserved for administrators-j: Upgrade ext2 to Ext3-o: File System Properties enable or disable-O: Adjust file system default hang option-u UUID: Modifying the UUID number

DUMP2FS:

-H: View Super block information



3. File System Detection


Fsck:file system Check

Fsck is used in a way similar to Mkfs fsck. Fstype/dev/partition # #例如 FSCK.EXT4/DEV/SDB1 Check/dev/sdb1 file system Note: The file system specified earlier must be the same as the specified partition file system-A: Auto Fix error-r: Interactive fix error

650) this.width=650; "src=" Http://www.178linux.com/ueditor/php/upload/image/20160303/1457013557133577.png "title= "1457013557133577.png" alt= "Blob.png"/>





Summary: This article only for the creation of file system, format file system is mainly elaborated in detail, after the file system modification, detection because there is no actual need to modify, the detection of file system, so there is not too much write

This article is from the "The Anyisalin blog" blog, please be sure to keep this source http://anyisalin.blog.51cto.com/10917514/1747360

Linux file system creation, formatting, modification, detection

Related Article

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.