Linux parted 分区

转自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%

时间: 2024-08-08 12:45:36

Linux parted 分区的相关文章

linux parted分区

导读 在 Linux 中,为磁盘分区通常使用 fdisk 和 parted 命令.通常情况下,使用 fdisk 可以满足日常的使用,但是它仅仅支持 2 TB 以下磁盘的分区,超出 2 TB 部分无法识别.而随着科技的进步,仅仅能识别 2 TB 的fdisk 很明显无法满足需求了,于是乎,parted & GPT 磁盘成为了绝佳的搭配.这里主要讲解下使用 parted 为 MBR 以及 GPT 磁盘进行分区. GPT 磁盘分区: 首先,你得有一块 GPT 分区的硬盘.小于 2 TB 的磁盘也可以转

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

场景:最近在学习Linux的基础知识,不可避免的设计到Linux的磁盘分区,以前做过总结,但是那种总结就是复制别人的文章,总结完就不想看第二遍,所以很容易就遗忘了!清楚明白的理解分区后,我就可以在自己的电脑上随意操作了! 1 主分区 我们知道硬盘的第一个扇区也就是第0扇区是用来存放主引导记录(MBR)的,因此也称MBR扇区. 一个扇区是512字节,因此MBR的大小也是512字节,其具体数据结构是:446个字节的引导代码.64个字节的分区表及2个字节的签名值"55AA". 由于MBR的分

parted分区工具

Parted是一个磁盘分区管理工具,它比fdisk更加灵活,功能也更丰富. [[email protected] ~]# parted /dev/sdb    分区 GNU Parted 2.1 Using /dev/sdb Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) help     #打印帮助信息 align-check TYPE N                        check

Linux 硬盘分区

硬盘分区   Linux分区表有以下两种:MBR,GPT MBR: MBR分区表(即主引导记录)大家都很熟悉.所支持的最大卷:2T,而且对分区有限制:最多4个主分区或3个主分区加一个扩展分区 GPT: GPT(即GUID分区表).是源自EFI标准的一种较新的磁盘分区表结构的标准,是未来磁盘分区的主要形式.与MBR分区方式相比,具有如下优点.突破MBR 4个主分区限制,每个磁盘最多支持128个分区.支持大于2T的分区,最大卷可达18EB. Linux中fdisk分区工具支持MBR分区,parted

Linux 格式化分区 报错Could not stat --- No such file or directory 和 partprobe 命令

分区的过程正常: [[email protected] /]# fdisk -l Disk /dev/sda: 21.4 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot      Start         End      Blocks   Id  System /dev/sda1   *

交互式fdisk分区工具 VS 非交互式parted分区工具及实例演练!

交互式fdisk分区工具 VS 非交互式parted分区工具 linux中磁盘资源是如何管理? 在windows系统中,我们对磁盘管理或是分区,C盘D盘E盘,打开"磁盘管理器",以设备的形式管理. 而linux哲学"一切皆文本"的思想,无论是设备也好,在linux中都是以文件的形式,来管理磁盘资源的. 设备文件,用于关联至一个设备驱动程序,能够跟与之对应设备产生关联,与硬件设备进行交互使用. 每个设备都有,设备号,用于内核标识识别设备: 主设备号:major num

linux 磁盘分区 fdisk

linux磁盘分区:fdisk(小于2T的分区工具) [[email protected] ~]# fdisk -l            #####查看磁盘空间 Disk /dev/sda: 16.1 GB, 16106127360 bytes 255 heads, 63 sectors/track, 1958 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 5

Linux硬盘分区Partition与档案系统管理

文件系统重点:inode(索引节点),block(逻辑区块),superblock(每个档案系统开始的位置的那个block,用于存储像是档案系统的大小,空的或填满的区块,以及它各自的总数等等信息) 磁盘的物理组成: 圆形的磁盘盘 机械手臂,与在机械手臂上的磁盘读取头(可擦写磁盘盘上的数据) 主轴马达,可以转动磁盘盘,让机械手臂的读取头在磁盘盘上读写数据 磁盘盘的物理组成: 扇区(sector)为最小的物理储存单位,每个扇区为512bytes 将扇区组成一个圆,那就是磁柱,磁柱是分区的最小单位 第

设置Linux交换分区

Linux下可以创建两种类型的交换空间,一种是swap分区,一种是swap文件.前者适合有空闲的分区可以使用,后者适合于没有空的硬盘分区,硬盘的空间都已经分配完毕.例如:安装redhat的时候,你可以默认划分硬盘空间,交换区的大小事系统默认配置,当你安装完系统后需要安装一个oracle数据库,突然发出警告,交换空间不够.此刻该怎么办?1.查看交换分区的方式可以通过命令top,free命令查看当前的交换分区.也可以使用cat /proc/swaps查看交换分区2.如何通过swap文件扩充交换空间的