转自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 parted 分区的更多相关文章

  1. (转)硬盘分区备忘(主分区,扩展分区和逻辑分区)以及Linux硬盘分区工具parted 介绍

    场景:最近在学习Linux的基础知识,不可避免的设计到Linux的磁盘分区,以前做过总结,但是那种总结就是复制别人的文章,总结完就不想看第二遍,所以很容易就遗忘了!清楚明白的理解分区后,我就可以在自己 ...

  2. (转)linux磁盘分区fdisk分区和parted分区

    linux磁盘分区fdisk分区和parted分区 原文:http://www.cnblogs.com/jiu0821/p/5503660.html ~~~~~~~~~~~~~~~~~~~~~~~~~ ...

  3. linux磁盘分区模式

    linux磁盘分区模式 模式一:MBR 1)主分区不超过四个 2)单个分区容量最大2TB 模式二:GPT 1)主分区个数"几乎"没有限制(原因:在GPT的分区表中最多可以支持128 ...

  4. <实训|第七天>横扫Linux磁盘分区、软件安装障碍附制作软件仓库

    期待已久的linux运维.oracle"培训班"终于开班了,我从已经开始长期四个半月的linux运维.oracle培训,每天白天我会好好学习,晚上回来我会努力更新教程,包括今天学到 ...

  5. Linux 磁盘分区修改与管理

    --Linux 磁盘分区修改与管理 -----------------------------2014/03/05 1. 目的,将磁盘卷/dev/cciss/c0d0p8修改成新的用途. 原: /de ...

  6. linux中分区、格式化文件系统、挂载

    以前学linux的时候,毕竟自己没搞运维,就只注重了很多命令的运用,没太在意文件系统这块.买了本linux的书,这部分看了点东西,记个笔记哈哈. 有个场景,比如说我们现在的服务器上存储不够用了,那么当 ...

  7. fdisk与parted分区

    我所接触的linux分区分为两种,一种是使用fdisk分区,另外一种是parted分区.前者是针对MBR模式分区的,后者是针对GPT模式分区的 fdisk分区: fdisk -l ---->查看 ...

  8. Linux磁盘分区工具的使用

    ----------fdisk分区工具----------   一..下面来介绍fdisk分区工具的命令格式:    fdisk是传统的Linux硬盘分区工具,也是Linux系统中最常用的一种硬盘分区 ...

  9. Linux磁盘分区--MBR分区

    今天心情不高兴,做IT不容易被公司重视,一定要速度学会运营,成为一个高逼格的技术男. 今天我要熟练掌握linux系统分区的能力.大家都知道,linux系统分区有两种分区格式:GTP和MBR. MBR作 ...

随机推荐

  1. linux 下的进程管理工具 supervisor

    在linux下监控进程: 1)yum install python-setuptools   linux下的python安装工具 2)easy_install supervisor     安装sup ...

  2. SRM 502 DIV1 500pt(DP)

    题目简述 给定比赛时间T和n个题目,你可以在任意时间提交题目,每个题目有一个初始分数maxPoints[i],每个单位时间题目的分数将会减少pointsPerMinute[i],即如果在时间t解决了第 ...

  3. https://github.com/mlzboy/spider-impl.git

    Installation - pygit2 0.24.0 documentation Python 2.7, 3.2+ or PyPy 2.6+ (including the development ...

  4. 第二百四十七天 how can I 坚持

    今天去了趟北海公园,看到地铁宣传图片挺好看的,实景也倒是不错,环境好了,哪都好,今天是蓝天白云啊. 回来的路上看了,扎克伯格对质疑的回应.哎.改变世界在硅谷是行动,而不是口号.change the w ...

  5. work6

    1) 把程序编译通过, 跑起来. 把正确的 playPrev(GoMove) 的方法给实现了. 如果大家不会下围棋,那就需要大家实地或者上网练习一下围棋的死活,提子是怎么回事.这个应该一个小时就能搞定 ...

  6. iOS学习之自动布局

    Autolayout: 最重要的两个概念: 约束:对控件位置和大小的限定条件 参照:对控件设置的约束是相对于哪一个视图而言的 自动布局的核心计算公式: obj1.property1 =(obj2.pr ...

  7. CABasicAnimation精讲

    前言 本教程写了这个效果图的demo,同时总结CABasicAnimation的使用方法. 看完gif动画完,看到了什么?平移.旋转.缩放.闪烁.路径动画. 实现平移动画 实现平移动画,我们可以通过t ...

  8. Unity3D之Mecanim动画系统学习笔记(四):Animation State

    动画的设置 我们先看看Animation Clip的一些设置: Loop time:动画是否循环播放. 下面出现了3个大致一样的选项: Root Transform Rotation:表示为播放动画的 ...

  9. iOS-图片png

    把图片添加到工程里面:就报了108个警告!!! 然后我发现我添加的图片有很多命名是这样子的: xcode去找图片的时候是按照什么方式找的呢????? 还发现有好几张同名的图片..... ------- ...

  10. ModelMap和ModelAndView

    一.ModelMap和ModelAndView 1.1.ModelMap ModelMap对象主要用于传递控制方法处理数据到结果页面,也就是说我们把结果页面上需要的数据放到ModelMap对象中即可, ...