zoukankan      html  css  js  c++  java
  • 如何使用parted对齐分区以得到最优性能

    如何使用parted对齐分区以得到最优性能

    来源地址: 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%
  • 相关阅读:
    h5页面页面在iphoneX手机上底部会有留白解决办法
    自定义单张图片放大预览功能,可支持手势缩放,依赖jquery
    js事件内部有click事件时,click事件会重复调用解决方法
    h5页面通过阿里云的broswer-js-sdk上传文件
    python字符串前加r、f、u、l 的区别
    Python基础面试题 :计算列表中出现最多次的字符
    python基础入门教程:传参是传值还是传引用
    Python 面试题:输入一个数组,输出该数组的第二大的数字
    Python 7种超实用的数据清洗方法,这你一定要掌握
    python教程:3个非常有用的内置函数(filter/map/reduce)
  • 原文地址:https://www.cnblogs.com/mouseleo/p/13829717.html
Copyright © 2011-2022 走看看