Linux磁盘格式化
CentOS7所支持的文件系统格式;默认是用xfs作为系统的文件系统。 "/"和"/boot"都是xfs格式!
[root@linux-xl ~]# cat /etc/filesystems
xfs
ext4
ext3
ext2
nodev proc
nodev devpts
iso9660
vfat
hfs
hfsplus
*
mke2fs命令:
mke2fs、mkfs.ext2、mkfs.ext3、mkfs.ext4均可用于磁盘格式化!唯独不支持xfs!
比如执行格式化为ext4系统(mkfs.ext4=mke2fs -t ext4)
-L:=label,预设该分区的标签
-t:用来指定文件系统的类型(xfs、ext4、ext3、ext2等)
-b:分区时指定每个数据块的大小,目前支持1024、248、4096 bytes每个块
-i:指定inode大小,默认单位是byte
-N:设定inode数量,有时候默认的数量不够用,所以需要自己设定inode数量
-c:在格式化之前先检测一下磁盘是否有问题,加上这个选项后会非常慢
-m:格式化时,指定预留给管理员的磁盘比例,是一个百分比,只针对mke2fs命令
格式化sdb1为ext4文件系统
[root@linux-xl ~]# mke2fs -t ext4 -b 2048 /dev/sdb1#指定为ext4的格式,块大小为2048;这里还有一个命令mkfs.ext4等价于mke2fs -t ext4
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=2048 (log=1)
Fragment size=2048 (log=1)
Stride=0 blocks, Stripe width=0 blocks
131072 inodes, 1048576 blocks
52428 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=269484032
64 block groups
16384 blocks per group, 16384 fragments per group
2048 inodes per group
Superblock backups stored on blocks:
16384, 49152, 81920, 114688, 147456, 409600, 442368, 802816
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
指定sdb1为2048k块
[root@linux-xl ~]# mke2fs -b 2048 /dev/sdb1
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=2048 (log=1)
Fragment size=2048 (log=1)
Stride=0 blocks, Stripe width=0 blocks
131072 inodes, 1048576 blocks
52428 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=537919488
64 block groups
16384 blocks per group, 16384 fragments per group
2048 inodes per group
Superblock backups stored on blocks:
16384, 49152, 81920, 114688, 147456, 409600, 442368, 802816
Allocating group tables: done
Writing inode tables: done
Writing superblocks and filesystem accounting information: done
指定预留给root的磁盘空间
[root@linux-xl ~]# mke2fs -t ext4 -m 0.1 /dev/sdb1 #预留百分之1.1的空间给root用户,并指定文件系统格式为ext4,如果不指定则是默认为ext2
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
131072 inodes, 524288 blocks
524 blocks (0.10%) reserved for the super user
First data block=0
Maximum filesystem blocks=536870912
16 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912
Allocating group tables: done
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done
mke2fs指定inode对应块大小
[root@linux-xl ~]# mke2fs -t ext4 -i 8192 /dev/sdb1 #增加inode
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
262144 inodes, 524288 blocks
26214 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=536870912
16 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912
Allocating group tables: done
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done
查看分区信息
[root@linux-xl ~]# blkid /dev/sdb1
/dev/sdb1: UUID="ffd991f6-2fc8-4c56-9ffb-41a9f741d70d" TYPE="ext4"
mkfs命令:
支持的文件系统mkfs.btrfs mkfs.cramfs mkfs.ext2 mkfs.ext3 mkfs.ext4 mkfs.minix mkfs.xfs
格式化sdb1为xfs文件系统:
[root@linux-xl ~]# mkfs.xfs /dev/sdb1 #用mkfs.xfs就可以实现xfs的格式化,如果是已经格式化过的需要加-f强制执行
mkfs.xfs: /dev/sdb1 appears to contain an existing filesystem (ext4).
mkfs.xfs: Use the -f option to force overwrite.
[root@linux-xl ~]# mkfs.xfs -f /dev/sdb1
meta-data=/dev/sdb1 isize=512 agcount=4, agsize=131072 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=524288, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
别在该奋斗的年纪,选择安逸。