Friday, January 28, 2011

partition table与parted程序

N多LUN(iscsi盘)需要分区,手动太痛苦了。只能找non-interaction型的分区工具, 比如parted这个程序。
在分区之前有一个概念需要先明白的:partition table, 也叫disklabel

之所以使用parted才需要注意到partition table, 是因为我们常常使用的fdisk已经帮我们选择了msdos类型的partition table。所以从fdisk转到parted后,会有点小疑问。

平时我们印象中:一个硬盘只能有4个主分区,或者3个主分区1个扩展分区。
这其实只是`msdos` partition table的限制。GPT就没有这种问题:http://en.wikipedia.org/wiki/GUID_Partition_Table

msdos partition table这个名词是从parted程序引用的:
[liangqingxi@hotspare ~]$ sudo /sbin/parted /dev/sdc print
Error: Unable to open /dev/sdc - unrecognised disk label.

[jessinio@niowork ~]$ sudo parted /dev/sda print
[sudo] password for jessinio:

Model: ATA ST3250310AS (scsi)
Disk /dev/sda: 250GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos


但是从wikipedia里查的信息表明, 这与BIOS被广泛使用有着很大的关系(比如,BIOS的引导过程)
感觉上, 称为`PC compatibles`更好一点:

信息1. In the world of IBM PC compatibles, disks are usually partitioned using the PC BIOS's MBR Partition Table scheme instead
信息2. The role of the BIOS has changed over time; today BIOS is a legacy system, superseded by the more complex EFI (EFI), but BIOS remains in widespread use, and EFI booting has only been supported in Microsoft OS products supporting GPT and Linux Kernels 2.6.1 and greater builds

当硬盘没有、或者程序无法认别partition table时会有如下信息:
[liangqingxi@hotspare ~]$ sudo /sbin/fdisk -l /dev/sdc

Disk /dev/sdc: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdc doesn't contain a valid partition table

在fdisk的手册中有这样的记载:fdisk doesn’t understand GUID Partition Table (GPT)


在知道partition table这一概念后, 使用parted命令将是非常容易的. 就不记录了.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.