本文共 5213 字,大约阅读时间需要 17 分钟。
4.文件系统
4.6分区、格式化与挂载
4.6.4格式化
1.格式化为EXT
[root@localhost ~]# mkfs.ext4 /dev/sda3
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=1024 (log=0) #block大小
Fragment size=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
51200 inodes, 204800 blocks
10240 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=33816576
25 block groups
8192 blocks per group, 8192 fragments per group
2048 inodes per group
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729
Allocating group tables: done
Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done
[root@localhost ~]# dumpe2fs /dev/sda3
dumpe2fs 1.42.9 (28-Dec-2013)
Filesystem volume name:
Last mounted on:
Filesystem UUID: 3e95cd6b-7aba-4dee-bc7f-042ac125fa3d
Filesystem magic number: 0xEF53
Filesystem revision #: 1 (dynamic)
Filesystem features: has_journal ext_attr resize_inode dir_index filetype extent 64bit flex_bg sparse_super huge_file uninit_bg dir_nlink extra_isize
Filesystem flags: signed_directory_hash
Default mount options: user_xattr acl
Filesystem state: clean
Errors behavior: Continue
Filesystem OS type: Linux
Inode count: 51200
Block count: 204800
Reserved block count: 10240
Free blocks: 192685
Free inodes: 51189
First block: 1
Block size: 1024#block大小
Fragment size: 1024
Group descriptor size: 64
Reserved GDT blocks: 256
Blocks per group: 8192
Fragments per group: 8192
Inodes per group: 2048
Inode blocks per group: 256
Flex block group size: 16
Filesystem created: Fri Mar 20 14:17:32 2020
Last mount time: n/a
Last write time: Fri Mar 20 14:17:32 2020
Mount count: 0
Maximum mount count: -1
Last checked: Fri Mar 20 14:17:32 2020
Check interval: 0 ()
Lifetime writes: 4449 kB
Reserved blocks uid: 0 (user root)
Reserved blocks gid: 0 (group root)
First inode: 11
Inode size: 128 #inode大小
Journal inode: 8
Default directory hash: half_md4
Directory Hash Seed: e0a7d3c5-f805-41e1-8e51-116851e0108f
Journal backup: inode blocks
Journal features: (none)
Journal size: 4096k
Journal length: 4096
Journal sequence: 0x00000001
Journal start: 0
[root@localhost ~]# mkfs.ext4 -b 4096 /dev/sda3
#block大小设定为4096
[root@localhost ~]# mkfs.ext4 -I 256 /dev/sda3
#inode大小设定为256
2.mkfs.xfs - construct an XFS filesystem
[root@localhost ~]# mkfs.xfs /dev/sda3
meta-data=/dev/sda3 isize=256 agcount=4, agsize=12800 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0
data = bsize=4096 blocks=51200, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal log bsize=4096 blocks=853, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
#采用默认值格式化
[root@localhost ~]# mkfs.xfs -f -i size=512 /dev/sda3
meta-data=/dev/sda3 isize=512 agcount=4, agsize=12800 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0
data = bsize=4096 blocks=51200, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal log bsize=4096 blocks=855, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
#指定inode大小为512,-f是强制格式化一个已经格式化过的文件系统
[root@localhost ~]# mkfs.xfs -f -b size=1024 /dev/sda3
meta-data=/dev/sda3 isize=256 agcount=4, agsize=51200 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0
data = bsize=1024 blocks=204800, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal log bsize=1024 blocks=2564, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
#指定block 大小为1024
3.格式化为其他文件系统
[root@localhost ~]# mkfs.[tab][tab]
mkfs.btrfs mkfs.ext2 mkfs.ext4 mkfs.minix mkfs.vfat
mkfs.cramfs mkfs.ext3 mkfs.fat mkfs.msdos mkfs.xfs
#列举出系统内可以格式化的文件系统类型
4.6.5检验
1.EXT4检验
[root@study ~]# fsck.ext4 [-pf] 装置名称
选项与参数:
-p :当档案系统在修复时,若有需要回覆 y 的动作时,自动回覆 y 来继续进行修复动作。
-f :强制检查!一般来说,如果 fsck 没有发现任何 unclean 的旗标,不会主动进入
细部检查的,如果您想要强制 fsck 进入细部检查,就得加上 -f 旗标!
[root@localhost Desktop]# fsck.ext4 /dev/sda3
e2fsck 1.42.9 (28-Dec-2013)
/dev/sda3: clean, 11/51200 files, 18515/204800 block
2.XFS检验
[root@study ~]# xfs_repair [-fnd] 装置名称
选项与参数:
-f :后面的装置其实是个档案而不是实体装置
-n :单纯检查并不修改档案系统的任何资料 (检查而已)
-d :通常用在单人维护模式底下,针对根目录 (/) 进行检查与修复的动作!很危险!不要随便使用
[root@localhost Desktop]# mkfs.xfs -f /dev/sda3
#先把前面实验用的ext4格式的sda3重新格式化为xfs文件系统。
[root@localhost Desktop]# xfs_repair /dev/sda3
Phase 1 - find and verify superblock...
Phase 2 - using internal log
- zero log...
- scan filesystem freespace and inode maps...
- found root inode chunk
Phase 3 - for each AG...
- scan and clear agi unlinked lists...
- process known inodes and perform inode discovery...
- agno = 0
- agno = 1
- agno = 2
- agno = 3
- process newly discovered inodes...
Phase 4 - check for duplicate blocks...
- setting up duplicate extent list...
- check for inodes claiming duplicate blocks...
- agno = 0
- agno = 1
- agno = 2
- agno = 3
Phase 5 - rebuild AG headers and trees...
- reset superblock...
Phase 6 - check inode connectivity...
- resetting contents of realtime bitmap and summary inodes
- traversing filesystem ...
- traversal finished ...
- moving disconnected inodes to lost+found ...
Phase 7 - verify and correct link counts...
done
转载地址:http://ukctx.baihongyu.com/