Disk formatting
After the disk partition is completed, it is natural to format the file system. The format command is very simple. Use the mkfs (make file system) command.
Syntax:
mkfs [-t File system format] Device file name
Options and parameters:
- -t: File system formats can be used, such as ext3, ext2, vfat, etc. (the system will take effect only if supported)
Example 1
View the file formats supported by mkfs
[root@www ~]# mkfs[tab][tab] mkfs mkfs.cramfs mkfs.ext2 mkfs.ext3 mkfs.msdos mkfs.vfat
Press two [tab s] and you will find that the file formats supported by mkfs are as shown above.
Example 2
Format the partition / dev/hdc6 (you can specify your own partition) as an ext3 file system:
[root@www ~]# mkfs -t ext3 /dev/hdc6 mke2fs 1.39 (29-May-2006) Filesystem label= <==This refers to the name of the dividing slot(label) OS type: Linux Block size=4096 (log=2) <==block The size of is configured as 4 K Fragment size=4096 (log=2) 251392 inodes, 502023 blocks <==Determined by this configuration inode/block quantity 25101 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=515899392 16 block groups 32768 blocks per group, 32768 fragments per group 15712 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912 Writing inode tables: done Creating journal (8192 blocks): done <==Logged Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 34 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. # This creates the Ext3 file system we need! Simple and clear!
Disk inspection
fsck (file system check) is used to check and maintain inconsistent file systems.
If the system loses power or the disk has problems, you can use the fsck command to check the file system.
Syntax:
fsck [-t file system] [-ACay] Device name
Options and parameters:
- -t: given the type of file system, if it is defined in / etc/fstab or supported by the kernel itself, this parameter does not need to be added
- -s: execute fsck instructions one by one to check
- -A: check all the partition s listed in / etc/fstab
- -C: display the complete inspection progress
- -d: print e2fsck's debug results
- -p: when - A condition exists at the same time, multiple fsck checks are performed at the same time
- -R: omit / do not check when there is - A condition at the same time
- -V: detailed display mode
- -a: if there is an error, it will be repaired automatically
- -r: if there is an error in the inspection, the user will answer whether to repair it
- -Y: the option specifies that yes is automatically entered to detect each file. When you are not sure that those files are abnormal, you can perform # fsck -y all inspection and repair.
Example 1
To see how many file systems support fsck commands:
[root@www ~]# fsck[tab][tab] fsck fsck.cramfs fsck.ext2 fsck.ext3 fsck.msdos fsck.vfat
Example 2
Force detection of / dev/hdc6 partition:
[root@www ~]# fsck -C -f -t ext3 /dev/hdc6 fsck 1.39 (29-May-2006) e2fsck 1.39 (29-May-2006) Pass 1: Checking inodes, blocks, and sizes Pass 2: Checking directory structure Pass 3: Checking directory connectivity Pass 4: Checking reference counts Pass 5: Checking group summary information vbird_logical: 11/251968 files (9.1% non-contiguous), 36926/1004046 blocks
If the - f option is not added, the check process is very fast because there has been no problem with the file system! If -f mandatory check is added, the process will be displayed one by one.