linux ssd分区对齐,高性能Linux: SSD分区对齐问题

分区对齐

分区对齐意味着分区与数据存储设备(例如硬盘,固态驱动器(SSD)或RAID卷)的合理的边界对齐。正确的分区对齐可确保数据访问期间的理想性能。不正确的分区对齐将导致性能降低,尤其是SSD(内部页面大小为4,096或8,192字节),具有4,096字节扇区和RAID卷的硬盘。

分区历史

过去,第一个分区始终在LBA(Logical Block Address)地址63处开始,该地址对应于第64个扇区(另请参见CHS和LBA硬盘寻址)。这种(逻辑)扇区的大小为512字节。这对于普通硬盘(物理扇区大小为512字节)是可接受的。就外部访问而言,物理扇区大小为4,096字节的较新硬盘实际上模拟了512字节的扇区大小,但在内部它们使用4,096字节。即使SSD也可以使用4096或8192字节的页面大小。从LBA地址63开始的分区就是这些新硬盘和SSD的问题。

如果使用典型块大小为4096字节的文件系统格式化分区,则文件系统的4096字节块将不会直接适用于硬盘的4096字节扇区或8192字节扇区的SSD页面。当写入4096字节的文件系统块时,必须修改两个4096字节的扇区或页面。

7dc07d3715ccec288a79c5b07a5fdbcd.png

正确的分区对齐

为了避免这些问题,建议在1M字节边界处进行对齐。当前的寻址系统被划分为512字节的逻辑扇区,这样做将对应于2,048个扇区。

a189af0dc09d7265719bc10afd4dba4d.png

Linux上如何做分区对齐

通过停用DOS兼容模式和设置扇区单元可以实现正确的对齐(分区将从LBA地址2,048开始。对于页面大小为4096字节的SSD,在开始时将有256个空页。磁盘分区将在第257页处开始)。

下面是使用fdisk进行分区,其中使用-c参数来停用dos兼容模式,-u参数用来使用扇区作为数据单元。

root@ubuntu-10-04:~# fdisk -c -u /dev/sdb

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel

Building a new DOS disklabel with disk identifier 0xfae13403.

Changes will remain in memory only, until you decide to write them.

After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): p

Disk /dev/sdb: 160.0 GB, 160041885696 bytes

255 heads, 63 sectors/track, 19457 cylinders, total 312581808 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0xfae13403

Device Boot Start End Blocks Id System

Command (m for help): n

Command action

e extended

p primary partition (1-4)

p

Partition number (1-4): 1

First sector (2048-312581807, default 2048):

Using default value 2048

Last sector, +sectors or +size{K,M,G} (2048-312581807, default 312581807): +10G

Command (m for help): p

Disk /dev/sdb: 160.0 GB, 160041885696 bytes

255 heads, 63 sectors/track, 19457 cylinders, total 312581808 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0xfae13403

Device Boot Start End Blocks Id System

/dev/sdb1 2048 20973567 10485760 83 Linux

Command (m for help):

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值