sex8cn.com:SSD硬盘咋分区?专家告诉你最佳分区实践

来源:百度文库 编辑:偶看新闻 时间:2024/05/02 19:28:38
SSD硬盘咋分区?专家告诉你最佳分区实践2011-04-14 2:28你有一块崭新的SSD?你计划给它分区?你知道SSD硬盘分区的最佳做法吗?让我来告诉你吧!

  分区实践示例

  我很庆幸我所生活的这座城市居然有MicroCenter商店,我在那里买了一块64GB SSD硬盘,它采用SandForce 1222控制器,我曾经对SandForce控制器在各种基准测试中的实时数据压缩功能非常感兴趣,因此我最终决定自己也搞一块来试试,但在测试之前,我需要考虑如何配置这块SSD。

  我们面临的挑战是,分区发生在柱面边界(记住Linux中的fdisk使用“磁头”和“磁道”定义柱面),如果柱面边界和SSD的“页面”对不齐,在读/修改/写期间,SSD需要承担更多地工作,可能会导致额外的写周期,进而降低性能,如果你不对SSD分区,那么不需要担心这个问题。

  默认情况下,Linux fsdisk使用默认的225磁头,63扇区/磁道几何形状,一个扇区等于512字节,每柱面就含有16065个5212字节大小的扇区(2008.125个4KB页面),在4KB页面上着肯定是不行的,因此我们需要调整几何形状,在4KB页面上对齐柱面边界,以便任何分区都和柱面边界对齐。

  如果你在网上搜索,你会发现一些针对不同SSD的几何建议,例如,ext4的领导者Theodore Ts’o就专门写了一篇博客探讨这个主题,他的建议如下:

  224 heads (32*7)
  56 sectors per track (8*7)

  这样每个柱面包含12544个扇区(256*49),每个磁道使用56个扇区,大小为56*512字节,即每磁道28762字节,这和每柱面4KB的7个块是一样的,因此每柱面4KB页面的数量是一个整数,这样任何分区都是协调一致的,下面是如何实现这种效果的一个例子:

  [root@test64 ~]# fdisk -H 224 -S 56 /dev/sdd
  The number of cylinders for this disk is set to 9345.
  There is nothing wrong with that, but this is larger than 1024,
  and could in certain setups cause problems with:
  1) software that runs at boot time (e.g., old versions of LILO)
  2) booting and partitioning software from other OSs
  (e.g., DOS FDISK, OS/2 FDISK)
  Command (m for help): n
  Command action
  e extended
  p primary partition (1-4)
  p
  Partition number (1-4): 1
  First cylinder (1-9345, default 1): 2
  Last cylinder or +size or +sizeM or +sizeK (2-9345, default 9345):
  Using default value 9345
  Command (m for help): w
  The partition table has been altered!
  Calling ioctl() to re-read partition table.
  Syncing disks.

  注意,我是从第二个柱面开始的,以保证分区/dev/sdd1从柱面边界开始。

  可以在fdisk后面跟上“-l”参数检查分区。

  [root@test64 ~]# fdisk -l /dev/sdd
  Disk /dev/sdd: 60.0 GB, 60022480896 bytes
  224 heads, 56 sectors/track, 9345 cylinders
  Units = cylinders of 12544 * 512 = 6422528 bytes
  Device Boot Start End Blocks Id System
  /dev/sdd1 2 9345 58605568 83 Linux

  我们也可以使用“-lu”参数查看扇区的数量。

  [root@test64 ~]# fdisk -lu /dev/sdd
  Disk /dev/sdd: 60.0 GB, 60022480896 bytes
  224 heads, 56 sectors/track, 9345 cylinders, total 117231408 sectors
  Units = sectors of 1 * 512 = 512 bytes
  Device Boot Start End Blocks Id System
  /dev/sdd1 12544 117223679 58605568 83 Linux

  分区从12544扇区(256*9)开始,在设备的末尾结束。

  在OCZ技术社区有人提供了另一种建议,使用的几何参数略有不同。

  32 heads
  32 sectors per track

  这样每柱面包含1024个扇区(32*32),512字节大小的扇区形成512KB的柱面(每柱面128个4KB页面),还是以/dev/sdd为例,这种几何划分法的命令如下:

  [root@test64 ~]# fdisk -H 32 -S 32 /dev/sdd
  The number of cylinders for this disk is set to 114483.
  There is nothing wrong with that, but this is larger than 1024,
  and could in certain setups cause problems with:
  1) software that runs at boot time (e.g., old versions of LILO)
  2) booting and partitioning software from other OSs
  (e.g., DOS FDISK, OS/2 FDISK)
  Command (m for help): n
  Command action
  e extended
  p primary partition (1-4)
  p
  Partition number (1-4): 1
  First cylinder (1-114483, default 1): 2
  Last cylinder or +size or +sizeM or +sizeK (2-114483, default 114483):
  Using default value 114483
  Command (m for help): w
  The partition table has been altered!
  Calling ioctl() to re-read partition table.
  Syncing disks.

  Fdisk加上“-l”参数可以检查分区。

  [root@test64 ~]# fdisk -l /dev/sdd
  Disk /dev/sdd: 60.0 GB, 60022480896 bytes
  32 heads, 32 sectors/track, 114483 cylinders
  Units = cylinders of 1024 * 512 = 524288 bytes
  Device Boot Start End Blocks Id System
  /dev/sdd1 2 114483 58614784 83 Linux

  注意,这种几何划分方法的“单位”是512KB(524288字节),它比第一种方法的柱面数更多,我们可以使用fdisk –lu命令查看扇区布局。

  [root@test64 ~]# fdisk -lu /dev/sdd
  Disk /dev/sdd: 60.0 GB, 60022480896 bytes
  32 heads, 32 sectors/track, 114483 cylinders, total 117231408 sectors
  Units = sectors of 1 * 512 = 512 bytes
  Device Boot Start End Blocks Id System
  /dev/sdd1 1024 117230591 58614784 83 Linux

  注意,我们从扇区1024开始,使用512字节的扇区,意味着分区匹配512KB。

  那种方法更好呢?我认为这取决于许多因素,特别是SSD的内部结构和固件工作原理,如果你不打算给你的SSD分区,如使用整个设备作为一个分区,那么你不需要担心这些问题,但如果你打算分区,这两个方法你就得选择一个,最重要的一条原则是,确保分区和边界保持对齐,这样有助于发挥SSD的性能,并延长它的使用寿命。

更多精彩转贴强力推荐