Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3625205
  • 博文数量: 880
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 6155
  • 用 户 组: 普通用户
  • 注册时间: 2016-11-11 09:12
个人简介

To be a better coder

文章分类

全部博文(880)

文章存档

2022年(5)

2021年(60)

2020年(175)

2019年(207)

2018年(210)

2017年(142)

2016年(81)

分类: LINUX

2018-02-05 10:08:18

1、用命令fdisk -l,查看新增的硬盘sdb的容量

2、用命令parted /dev/sdb,进入parted分区工具,开始进行分区。
(parted) mklabel gpt
(parted) print
查看sdb的信息
(parted) mkpart primary 0% 100%
或者用
(parted) mkpart primary 0% 4000gb
(parted) quit

3、用mkfs.ext4 -F sdb1命令格式化分区



如果上面使用类似下面的命令
mkpart primary 0 4000gb
会出现分区提示警告:
Warning: The resulting partition is not properly aligned for best performance.
警告:生成的分区没有正确地对齐以实现最佳性能。忽略/取消?

下面是正确对齐分区的快速分步指南:

1.获得你阵列的alignment参数
# cat /sys/block/sdb/queue/optimal_io_size
1048576
# cat /sys/block/sdb/queue/minimum_io_size
262144
# cat /sys/block/sdb/alignment_offset
0
# cat /sys/block/sdb/queue/physical_block_size
512

2.把optimal_io_size的值与alignment_offset的值相加,之后除以physical_block_size的值。
在上面的例子中是:(1048576 + 0) / 512 = 2048

3.这个数值是分区起始的扇区。新的parted命令应该写成类似下面这样
mkpart primary 2048s 100%
2048s中的字母s是很有意义的:它告诉parted,你的输入是2048扇区,而不是2048字节,也不是2048兆字节。

4.如果顺利,分区将不再提示警告信息。然后,可以检查分区是否对齐了
请将下面命令中的1替换为合适的分区号。
(parted) align-check optimal 1                                            
1 aligned

As I alluded to before, there are cases where this won’t work: if optimal_io_size is zero, for example, there are other rules to follow. Of course it would be nice if parted could do this—the values are all available as ioctls, after all—but then what would I write about? :)

末尾的最后一条评论更加实用:
Apparently, using % causes parted to automatically align the sectors for best performance:

(parted) mkpart primary ext4 0% 100%

注意:没特别调整优化过的CentOS,系统默认optimal_io_size 的值为0,这时候不用计算,也直接采用 2048s进行分割即可 

阅读(2522) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~