Linux parted 分区
2015-09-21 17:30
525 查看
转自http://tilt.lib.tsinghua.edu.cn/node/889
如何使用parted对齐分区以得到最优性能
Sat, 03/08/2014 - 18:02 - tlbluestar来源地址: http://rainbow.chard.org/2013/01/30/how-to-align-partitions-for-best-per...
How to align partitions for best performance using parted
There are two common problems when creating partitions in Linux on big storage arrays. The first is easy, and the warning message from fdisk is a bit of a giveaway:WARNING: The size of this disk is 8.0 TB (7970004230144 bytes). DOS partition table format can not be used on drives for volumes larger than (2199023255040 bytes) for 512-byte sectors. Use parted(1) and GUID partition table format (GPT).
The answer: use parted. Don’t have it? Install it!
The second problem is this warning from parted:
(parted) mklabel gpt (parted) mkpart primary 0 100% Warning: The resulting partition is not properly aligned for best performance. Ignore/Cancel?
…and no matter what combination of numbers you use, the message just keeps coming back. It’s tempting to ignore it, but don’t.
There are a few posts on the subject, but this one from HP really gets to the guts of the problem.
Here’s a quick step-by-step guide to aligning partitions properly. It’s just an abstraction of the HP post, but hopefully easier to follow. This will work for most arrays (in fact it works for all the arrays that I’ve seen); there are more options in HP’s post, but I’ve included the most common configuration here.
1. Get the alignment parameters for your array (remember to replace sdb with the name of your device as seen by the kernel).
# 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. Add optimal_io_size to alignment_offset and divide the result by physical_block_size. In my case this was (1048576 + 0) / 512 = 2048.
3. This number is the sector at which the partition should start. Your new parted command should look like
mkpart primary 2048s 100%
The trailing ‘s’ is important: it tells parted that you’re talking about sectors, not bytes or megabytes.
4. If all went well, the partition will have been created with no warnings. You can check the alignment thusly (replacing ’1′ with the partition number if necessary):
(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%
相关文章推荐
- linux自学心得之--安装内核头文件
- Linux下的有名管道(06)---使用两个管道实现两个进程之间的通信(手机模式)
- 关于linux有效用户id的解释
- Linux sed命令解析
- CentOS iSCSI服务器搭建------Target篇
- LINUX文件锁定
- Linux知识(2)----fcitx输入法安装
- CentOS 6.5上使用gdb调试时出现Missing separate debuginfos, use: debuginfo-install glibc-2.12-1.132.el6.i686 .
- block_dump观察Linux IO写入的具体文件
- windows远程(xrdp+vnc)连接ubuntu linux
- linux环境变量 export命令详解
- Linux下的有名管道(05)---使用两个管道实现两个进程之间的通信(对讲机模式)
- phalcon的安装详细
- Centos下安装svn客户端
- 【问题】CentOS6.5系统"libc.so.6: version 'GLIBC_2.15' not found"解决方法
- [Linux] ls和size命令以及程序内存映像、磁盘映像的理解
- Linux 正则表达式
- RHEL7无人值守自动安装 DHCP+TFTP +SYSLINUX+FTP +Kickstart
- Linux 下软件安装
- 【Linux导论】Linux引导流程(The Boot Process)