查看os系统块的大小
[root]# /sbin/tune2fs -l /dev/sda1
[root@his1 ~]# fdisk -l
Disk /dev/sda: 12.3 GB, 12328140800 bytes
255 heads, 63 sectors/track, 1498 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 25 200781 83 Linux
/dev/sda2 26 286 2096482+ 82 Linux swap / Solaris
/dev/sda3 287 1498 9735390 83 Linux
Disk /dev/sdb: 20.5 TB, 20573405184 bytes
255 heads, 63 sectors/track, 2501 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdb doesn't contain a valid partition table
[root@his1 ~]# parted /dev/sdb
GNU Parted 1.8.1
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel gpt
(parted) p
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sdb: 20.6TB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name Flags
(parted) mkpart primary 0 -1
(parted) p
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sdb: 20.6GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name Flags
1 17.4kB 20.6GB 20.6GB primary
(parted) quit
[root@his1 ~]# parted /dev/sdb mkfs
Warning: The existing file system will be destroyed and all data on the
partition will be lost. Do you want to continue?
Yes/No? yes
Partition number? 1
File system? [ext2]? ext3
No Implementation: Support for creating ext3 file systems is not implemented --这里提示不支持ext3
yet.
Information: Don't forget to update /etc/fstab, if necessary.
没有可以二种方式进行格式化
此时请注意添加参数: mkfs.ext3 -F /dev/sdb1
-F参数的含义:
Force mke2fs to run, even if the specified device is not a block special device, or appears to be mounted
它会强制mke2fs运行,不管指定的设备是否块设备或着是已挂载的设备
[root@his1 ~]#mkfs -t ext3 -b 8192 /dev/sdb1 (打算用8K的数据块,但格式化时间太长,不想等)
Warning: blocksize 8192 not usable on most systems.
mke2fs 1.39 (29-May-2006)
mkfs.ext3: 8192-byte blocks too big for system (max 4096)
Proceed anyway? (y,n)n
这种格式成ext2文件系统
[root@his1 ~]# parted /dev/sdb mkfs
Warning: The existing file system will be destroyed and all data on the
partition will be lost. Do you want to continue?
Yes/No? yes
Partition number? 1
File system? [ext2]?
Information: Don't forget to update /etc/fstab, if necessary.
创建文件系统时,可以指定块的大小。如果将来在你的文件系统中是一些比较大的文件的话,
使用较大的块大小将得到较好的性能。将ext2文件系统的块大小调整为4096byte而不是缺省
的1024byte,可以减少文件碎片,加快fsck扫描的速度和文件删除以及读操作的速度。另
外,在ext2的文件系统中,为根目录保留了5%的空间,对一个大的文件系统,除非用作日志
文件,5%的比例有些过多。可以使用命令
# mke2fs -b 4096 -m 1 /dev/hda6
将它改为1%并以块大小4096byte创建文件系统。
使用多大的块大小,需要根据你的系统综合考虑,如果系统用作邮件或者新闻服务器,使用较
大的块大小,虽然性能有所提高,但会造成磁盘空间较大的浪费。比如文件系统中的文件平均
大小为2145byte,如果使用4096byte的块大小,平均每一个文件就会浪费1951byte空间。如果
使用1024byte的块大小,平均每一个文件会浪费927byte空间。在性能和磁盘的代价上如何平衡
,要看具体应用的需要。
块尺寸 最大文件尺寸 最大文件系统尺寸
1KiB 16GiB 2TiB
2KiB 256GiB 8TiB
4KiB 2TiB 16TiB
8KiB 16TiB 32TiB