Create a file system

1. Check which file systems are supported by the kernel in the current system
[root@ns1 ~]# cat /proc/filesystems 
2. Command: mkfs
whole process: make file system
parameter: -t file system type partition
3. Example:
[root@ns1 ~ ]# mkfs -t ext3 /dev/sdb1
Note: The result of creating ext3 and ext2 will be different, ext3 has one more line: Creating journal (32768 blocks): done, which is called creating journal.
mkfs -t ext3 = mkfs.ext3
similar to
[root@ns1 ~]# mkfs.
Display results: mkfs.cramfs mkfs.ext3 mkfa.ext4dev mkfs.vfat
 mkfs.ext2 mkfs.ext4 mkfs.msdos
4. Specially manage ext Series files:
Command: mke2fs creates an ext2 file system by default
Parameters : -j: Creates an ext3 file system
Example:
[root@ns1 ~]# mke2fs /dev/sdb1
[root@ns1 ~]# mke2fs -j /dev/sdb1
 -b BLOCK_SIZ: Specify the block size, the default is 4096, the available values ​​are 1024, 2046 or 4096
Example:
[root@ns1 ~]# mke2fs -b 1024 /dev/sdb2
 -L LABEL: Specify the partition volume label
Example :
[root @ns1 ~]# mke2fs -L DATA /dev/sdb1
 -m #: Specifies the percentage of blocks reserved for superusers
Example :
[root@ns1 ~]# mke2fs -m 3 /dev/sdb1
 -i #: Used for Specifies how many bytes of space to create an inode. The default is 8192. The value given here should be 2^n times the block size.
Example :
[root@ns1 ~]# mke2fs -i 4096 /dev/sdb1
 -N #: Specify the number of inodes
 -F: Force the creation of a file system
 -E: The user specifies additional file system attributes
5. Query or view the related attributes of the disk device
Command : blkid
Example:
[root@ns1 ~]# blkid /dev/sdb
/dev/ sdb: LABEL="DATA" UUID="534e7479-904d-423c-b299-09d1399ab365" TYPE="ext2" 
[root@ns1 ~]# 
Pay attention to UUID (Universal Unique Identifier), TYPE (Partition Type) and LABEL (Volume Label)
6. Used to view or define volume labels
Command : e2label Device file volume label
Example:
[root@ns1 ~]# e2label /dev/sdb zby
[root@ns1 ~]# e2label /dev/sdb
zby
[root@ns1 ~]# 
7. Adjust the relevant attributes of the file system
Command : tune2fs
parameter: -j: Do not damage the original data, upgrade ext2 to ext3, note: Can't downgrade.
 Example:
[root@ns1 ~]# blkid /dev/sdb
/dev/sdb: LABEL="zby" UUID="534e7479-904d-423c-b299-09d1399ab365" TYPE="ext2" 
saw TYPE='etx2'
[ root@ns1 ~]# tune2fs -j /dev/sdb
tune2fs 1.41.12 (17-May-2010)
Creating journal inode: Done
This filesystem will be automatically checked every 25 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@ns1 ~]# blkid /dev/sdb
/dev/sdb: LABEL="zby" UUID="534e7479-904d-423c-b299-09d1399ab365" SEC_TYPE="ext2" TYPE="ext3" 
[root@ns1 ~ ] 
#See TYPE='ext3'
 -L LABEL:
 Example of setting or modifying the volume label:
[root@ns1 ~]# blkid /dev/sdb
/dev/sdb: LABEL="zby" UUID="534e7479-904d- 423c-b299-09d1399ab365" SEC_TYPE="ext2" TYPE="ext3" 
saw LABEL='zby'
[root@ns1 ~]# tune2fs -L DATA /dev/sdb
tune2fs 1.41.12 (17-May-2010)
[ root@ns1 ~]# blkid /dev/sdb
/dev/sdb: LABEL="DATA" UUID="534e7479-904d-423c-b299-09d1399ab365" SEC_TYPE="ext2" TYPE="ext3" 
[root@ns1 ~] #saw 
LABEL=' DATA'
 -m #: Adjust the reserved percentage
 -r #: Specify the number of reserved blocks
 -o: Set the default mount options
     acl
 -c #: Perform self-check after the specified number of mounts reaches # times, 0 or -1 means disable this function
 -i #: Perform self-check after not hanging, 0 or -1 means disable this function
Remarks :- When the environment used by c and -i is to read and write a large database, it just reaches the self-test time, and the server performance will drop sharply.
  Example:
[root@ns1 ~]# mke2fs -j /dev/sdb
mke2fs 1.41.12 (17- May-2010)
/dev/sdb is entire device, not just one partition!
Continue anyway? (y,n) y
filesystem label=
OS:Linux
blocksize=4096 (log=2)
blocksize= 4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
327680 inodes, 1310720 blocks
65536 blocks (5.00%) reserved for the super user
first data block=0
Maximum filesystem blocks=1342177280
40 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
32768, 98304, 163840, 229376, 294912, 819200, 884736


正在写入inode表: 完成                            
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成


This filesystem will be automatically checked every 27 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
[root@ns1 ~]# 
 -l:显示超级快中的信息
 举例:
[root@ns1 ~]# tune2fs -l /dev/sdb
tune2fs 1.41.12 (17-May-2010)
Filesystem volume name:   <none>
Last mounted on:          <not available>
Filesystem UUID:          9da08fdd-5429-4143-a90e-cc8fd4cb02b6
Filesystem magic number:  0xEF53
Filesystem revision #:    1 (dynamic)
Filesystem features:      has_journal ext_attr resize_inode dir_index filetype sparse_super large_file
Filesystem flags:         signed_directory_hash 
Default mount options:    (none)
Filesystem state:         clean
Errors behavior:          Continue
Filesystem OS type:       Linux
Inode count:              327680
Block count:              1310720
Reserved block count:     65536
Free blocks:              1254785
Free inodes:              327669
First block:              0
Block size:               4096
Fragment size:            4096
Reserved GDT blocks:      319
Blocks per group:         32768
Fragments per group:      32768
Inodes per group:         8192
Inode blocks per group:   512
Filesystem created:       Wed Apr 11 23:15:18 2018
Last mount time:          n/a
Last write time:          Wed Apr 11 23:15:18 2018
Mount count:              0
Maximum mount count:      27
Last checked:             Wed Apr 11 23:15:18 2018
Check interval:           15552000 (6 months)
Next check after:         Mon Oct  8 23:15:18 2018
Reserved blocks uid:      0 (user root)
Reserved blocks gid:      0 (group root)
First inode:              11
Inode size:          256
Required extra isize: 28
Desired extra isize: 28
Journal inode: 8
Default directory hash: half_md4
Directory Hash Seed: 4c738d1c-b531-4926-8687-f76df8ef1ce3
Journal backup: inode blocks
[root@ns1 ~]# 
8.dumpe2fs (optional Compatible with ext4)
command: dumpe2fs /dev/sdb1 = tune2fs -l /dev/sdb1
Note: In the display content, we can see Free blocks (idle blocks) in each fast group, and we may see free blocks for the used hard disks It is discrete, which means there are fragments.
 Example:
[root@ns1 ~]# df -lh
[root@ns1 ~]# dumpe2fs /dev/sda3
Parameters: -h: Only want to see the information of the super block
 Example:
[root @ns1 ~]# dumpe2fs -h /dev/sdb
9.fsck
explanation: Check and repair all file systems supported by Linux

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324843650&siteId=291194637