LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 5124|回复: 3

磁盘分区及查看必备工具 mac-fdisk

[复制链接]
发表于 2004-6-26 22:45:22 | 显示全部楼层 |阅读模式
来自: http://penguinppc.org/projects/yaboot/doc/mac-fdisk-basics.shtml

这个软件是在linux ppc版本中必须的分区工具,因为fdisk -l在linux ppc版本中,根本没有办法用。所以这个工具,还是极有必要的。



This explains the basics of creating partitions with mac-fdisk in a
step by step manner.  Note if you need to share the disk with MacOS
you will need to first create the MacOS partitions with the MacOS
utility Drive setup.  When creating the MacOS partitions you should
first create with Drive setup a placeholder HFS partition as big as
the total space ALL of your planned GNU/Linux partitions will take.
For example, if you plan to have 4 1GB Linux partitions you would make
the HFS placeholder partition 4GB.  You will delete this partition
with mac-fdisk and create the Linux partitions in the space it leaves
behind.  The MacOS partition should be last on the disk.  

For Newworld systems you *must* have an 800K partition with type
Apple_Bootstrap appearing *before* any MacOS partitions.  

DO NOT try and create Linux partitions with Apple's Drive setup!

If you are not going to keep MacOS and intend to have a GNU/Linux only
disk/system you should use the `i' command to mac-fdisk to clear out
the partition table and make a new empty one, however mac-fdisk
occasionally miscalculates the number of blocks the disk has.  When
you run the `i' command it will prompt you for the number of blocks
the disk has, make sure this number is correct before accepting it.

NOTE: the mac-fdisk in Debian woody has been fixed, and no longer has
this problem. If you are using mac-fdisk with Debian woody
boot-floppies you need not find the number of blocks yourself as
described below.

To find out the number of blocks the disk has do the following (you
can skip this if using Debian woody mac-fdisk):

# cat /proc/partitions

find the device you are partitioning, for example `hda' you should see
something like this:

...
   3     0   20044080 hda
...

take the number next to `hda' and double it, in this example you would
get 40088160 that is the number of 512 byte blocks /dev/hda has, this
is the number mac-fdisk should give as the default when you use the
`i' command, if not type it in yourself.

If you are sharing the disk with MacOS you should have already created
two HFS partitions, the first just a placeholder to reserve the space
for all your Linux partitions.  The second for MacOS.  Note if you
want to also install MacOSX, you should use Drive setup to create a
3rd partition type Apple_UFS, or MacOSX.  The MacOSX installer uses
this as a placeholder partition, it will delete it and create 2
bootstrap partitions and then recreate the Apple_UFS partition.  It is
important that you not create the Apple_UFS partition before the
GNU/Linux placeholder otherwise the MacOSX bootstrap partition will be
ahead of the Linux bootstrap partition. Using HFS+ for MacOSX is not
recommended as MacOS will debless the OSX partition rendering it
unbootable.  GNU/Linux also has read-only support for UFS unlike HFS+.

First you need to find and delete the placeholder partition:

when you enter mac-fdisk you get the following prompt:

Command (? for help):

the first command you should give is the `p' print command:

Command (? for help): p
/dev/sdb
        #                    type name                length   base    ( size )  system
/dev/sdb1     Apple_partition_map Apple                   63 @ 1       ( 31.5k)  Partition map
/dev/sdb2          Apple_Driver43 Macintosh               54 @ 64      ( 27.0k)  Driver 4.3
/dev/sdb3          Apple_Driver43 Macintosh               74 @ 118     ( 37.0k)  Driver 4.3
/dev/sdb4      Apple_Driver_IOKit Macintosh              512 @ 192     (256.0k)  Unknown
/dev/sdb5           Apple_Patches Patch Partition        512 @ 704     (256.0k)  Unknown
/dev/sdb6               Apple_HFS untitled            194557 @ 1216    ( 95.0M)  HFS
/dev/sdb7               Apple_HFS untitled 2          333025 @ 195773  (162.6M)  HFS
/dev/sdb8              Apple_Free Extra                   10 @ 528798  (  5.0k)  Free space

Block size=512, Number of Blocks=528807
DeviceType=0x0, DeviceId=0x0
Drivers-
1: @ 64 for 22, type=0x1
2: @ 118 for 36, type=0xffff

In this case the placeholder partition is 95MB (absurd but this is
just a demonstration)

Note that partitions 2-5 are MacOS cruft, they are only required if
you are keeping MacOS, they are completly unnecessary if you delete
MacOS.  It is reccommended that you remove all of these driver
partitions if you do not plan to keep MacOS, do this with the `i'
command.

to delete this partition we use the `d' command and use the partition
number, in this case 6:

Command (? for help): d
Partition number: 6
Command (? for help): p
/dev/sdb
        #                    type name                length   base    ( size )  system
/dev/sdb1     Apple_partition_map Apple                   63 @ 1       ( 31.5k)  Partition map
/dev/sdb2          Apple_Driver43 Macintosh               54 @ 64      ( 27.0k)  Driver 4.3
/dev/sdb3          Apple_Driver43 Macintosh               74 @ 118     ( 37.0k)  Driver 4.3
/dev/sdb4      Apple_Driver_IOKit Macintosh              512 @ 192     (256.0k)  Unknown
/dev/sdb5           Apple_Patches Patch Partition        512 @ 704     (256.0k)  Unknown
/dev/sdb6              Apple_Free Extra               194557 @ 1216    ( 95.0M)  Free space
/dev/sdb7               Apple_HFS untitled 2          333025 @ 195773  (162.6M)  HFS
/dev/sdb8              Apple_Free Extra                   10 @ 528798  (  5.0k)  Free space

as you can see there is now just a free space hole.

create the bootstrap partition:

If your using the mac-fdisk in Debian woody you can do this using the
`b' command which will automatically create the partition with the
correct type and size:

Command (? for help): b
First block: 6P
Command (? for help): p
/dev/sdb
        #                    type name                length   base    ( size )  system
/dev/sdb1     Apple_partition_map Apple                   63 @ 1       ( 31.5k)  Partition map
/dev/sdb2          Apple_Driver43 Macintosh               54 @ 64      ( 27.0k)  Driver 4.3
/dev/sdb3          Apple_Driver43 Macintosh               74 @ 118     ( 37.0k)  Driver 4.3
/dev/sdb4      Apple_Driver_IOKit Macintosh              512 @ 192     (256.0k)  Unknown
/dev/sdb5           Apple_Patches Patch Partition        512 @ 704     (256.0k)  Unknown
/dev/sdb6         Apple_Bootstrap bootstrap             1600 @ 1216    (800.0k)  Unknown
/dev/sdb7              Apple_Free Extra               192957 @ 2816    ( 94.2M)  Free space
/dev/sdb8               Apple_HFS untitled 2          333025 @ 195773  (162.6M)  HFS
/dev/sdb9              Apple_Free Extra                   10 @ 528798  (  5.0k)  Free space

Otherwise you will have to create it manually, note that the `C'
command is NOT the same as the `c' command:

Command (? for help): C
First block: 6P
Length in blocks: 800K
Name of partition: bootstrap
Type of partition: Apple_Bootstrap
Command (? for help): p
/dev/sdb
        #                    type name                length   base    ( size )  system
/dev/sdb1     Apple_partition_map Apple                   63 @ 1       ( 31.5k)  Partition map
/dev/sdb2          Apple_Driver43 Macintosh               54 @ 64      ( 27.0k)  Driver 4.3
/dev/sdb3          Apple_Driver43 Macintosh               74 @ 118     ( 37.0k)  Driver 4.3
/dev/sdb4      Apple_Driver_IOKit Macintosh              512 @ 192     (256.0k)  Unknown
/dev/sdb5           Apple_Patches Patch Partition        512 @ 704     (256.0k)  Unknown
/dev/sdb6         Apple_Bootstrap bootstrap             1600 @ 1216    (800.0k)  Unknown
/dev/sdb7              Apple_Free Extra               192957 @ 2816    ( 94.2M)  Free space
/dev/sdb8               Apple_HFS untitled 2          333025 @ 195773  (162.6M)  HFS
/dev/sdb9              Apple_Free Extra                   10 @ 528798  (  5.0k)  Free space

For `First block:' we used the first Apple_Free partition, partition 6
hence `6P' you can use this syntax to avoid having to calculate the
block offsets yourself.  Also note that the Apple_Free partition is
now partition 7 and is 1600 blocks smaller, this will occur each time
you create new partitions in that space until there is no more space
left and this Apple_Free partition will simply be gone.

Now create the rest of your GNU/Linux partitions, this will show only
one partition.

Command (? for help): c
First block: 7P
Length in blocks: 7P
Name of partition: /
Command (? for help): p
/dev/sdb
        #                    type name                length   base    ( size )  system
/dev/sdb1     Apple_partition_map Apple                   63 @ 1       ( 31.5k)  Partition map
/dev/sdb2          Apple_Driver43 Macintosh               54 @ 64      ( 27.0k)  Driver 4.3
/dev/sdb3          Apple_Driver43 Macintosh               74 @ 118     ( 37.0k)  Driver 4.3
/dev/sdb4      Apple_Driver_IOKit Macintosh              512 @ 192     (256.0k)  Unknown
/dev/sdb5           Apple_Patches Patch Partition        512 @ 704     (256.0k)  Unknown
/dev/sdb6         Apple_Bootstrap bootstrap             1600 @ 1216    (800.0k)  Unknown
/dev/sdb7         Apple_UNIX_SVR2 /                   192957 @ 2816    ( 94.2M)  Linux native
/dev/sdb8               Apple_HFS untitled 2          333025 @ 195773  (162.6M)  HFS
/dev/sdb9              Apple_Free Extra                   10 @ 528798  (  5.0k)  Free space

In this example we used the `c' command instead of `C' the difference
is `c' does not ask for a partition type, which we needed to enter to
get the special Apple_Bootstrap partition.  Also note that we used the
7P syntax for the `Length of Blocks:' this means use all the space the
selected Apple_Free partition has.  For other partitions you would
want to use xyzM for number of MegaBytes similar to the above 800K for
800 KiloBytes used for the bootstrap partition.  

The partition name does not matter except for the swap partition,
where it should be `swap'.  I find it useful to use the mountpoint
path as a partition name.

once your are satisfied with your partitioning enter the `w' command
to save changes:

Command (? for help): w
Writing the map destroys what was there before. Is that okay? [n/y]: y
The partition table has been altered!

SCSI device sdb: hdwr sector= 512 bytes. Sectors= 528808 [258 MB] [0.3 GB]
sdb: sdb1 sdb2 sdb3 sdb4 sdb5 sdb6 sdb7 sdb8 sdb9
SCSI device sdb: hdwr sector= 512 bytes. Sectors= 528808 [258 MB] [0.3 GB]
sdb: sdb1 sdb2 sdb3 sdb4 sdb5 sdb6 sdb7 sdb8 sdb9
Command (? for help):

now quit mac-fdisk with the `q' command:

Command (? for help): q

If you are not going to keep MacOS then you should clear the partition
table like so:

Command (? for help): i
map already exists
do you want to reinit? [n/y]: y
size of 'device' is 528808 blocks:
new size of 'device' is 528808 blocks
Command (? for help): p
/dev/sda
        #                    type name                length   base    ( size )  system
/dev/sda1     Apple_partition_map Apple                   63 @ 1       ( 31.5k)  Partition map
/dev/sda2              Apple_Free Extra               528744 @ 64      (258.2M)  Free space

Block size=512, Number of Blocks=528808
DeviceType=0x0, DeviceId=0x0

Command (? for help):

Note if mac-fdisk's idea of the `size of 'device'' is wrong then enter
the correct value as described above.

Clearing the partition table has the advantage of getting rid of all
the MacOS cruft partitions created by Drive setup, those partitions
are only required when sharing the disk with MacOS.

create your partitions as shown in the previous example.  

---- REORDERING PARTITIONS ----

MacOSX uses Apple_UFS partitions created by Drive setup as a
placeholder, it deletes them and create two bootstrap partitions of
its own then recreates the Apple_UFS partition.  You should always
create the GNU/Linux placeholder before any MacOS or MacOSX partitions
but in case you didn't here is how to fix things.

Reordering partitions is useful if you accidently created your
bootstrap partition after your MacOS partitions, and its too late to
repartition.

the fix fortunatly is pretty simple, once you boot back into a
GNU/Linux system run mac-fdisk (aka pdisk) and use the `p' command to
print the partition table.  Find the new number of your Bootstrap
partition and then use the `r' command to move it back where it
belongs, here is an example:

[root@socrates /root]# mac-fdisk /dev/sda
Command (? for help): p
/dev/sda
        #                    type name                length   base    ( size )  system
/dev/sda1     Apple_partition_map Apple                   63 @ 1       ( 31.5k)  Partition map
/dev/sda2              Apple_Boot MacOSX_Bootstrap     16384 @ 64      (  8.0M)  Unknown
/dev/sda3            Apple_Second MacOSX_Second_stage   2048 @ 16448   (  1.0M)  Unknown
/dev/sda4               Apple_HFS MacOS9              102400 @ 18496   ( 50.0M)  HFS
/dev/sda5               Apple_UFS MacOSX              112640 @ 120896  ( 55.0M)  Unknown
/dev/sda6         Apple_Bootstrap bootstrap             1600 @ 233536  (800.0k)  Unknown
/dev/sda7         Apple_UNIX_SVR2 GNU/Linux           293672 @ 235136  (143.4M)  Linux native

Block size=512, Number of Blocks=528808
DeviceType=0x0, DeviceId=0x0

Command (? for help): r
Partition number: 6
New number: 2
Command (? for help): p
/dev/sda
        #                    type name                length   base    ( size )  system
/dev/sda1     Apple_partition_map Apple                   63 @ 1       ( 31.5k)  Partition map
/dev/sda2         Apple_Bootstrap bootstrap             1600 @ 233536  (800.0k)  Unknown
/dev/sda3              Apple_Boot MacOSX_Bootstrap     16384 @ 64      (  8.0M)  Unknown
/dev/sda4            Apple_Second MacOSX_Second_stage   2048 @ 16448   (  1.0M)  Unknown
/dev/sda5               Apple_HFS MacOS9              102400 @ 18496   ( 50.0M)  HFS
/dev/sda6               Apple_UFS MacOSX              112640 @ 120896  ( 55.0M)  Unknown
/dev/sda7         Apple_UNIX_SVR2 GNU/Linux           293672 @ 235136  (143.4M)  Linux native

Block size=512, Number of Blocks=528808
DeviceType=0x0, DeviceId=0x0

Command (? for help): w
Writing the map destroys what was there before. Is that okay? [n/y]: y
The partition table has been altered!

SCSI device sda: hdwr sector= 512 bytes. Sectors= 528808 [258 MB] [0.3 GB]
sda: sda1 sda2 sda3 sda4 sda5 sda6 sda7
SCSI device sda: hdwr sector= 512 bytes. Sectors= 528808 [258 MB] [0.3 GB]
sda: sda1 sda2 sda3 sda4 sda5 sda6 sda7
Command (? for help): q
[root@socrates /root]#

That should take care of the problem.  You may also have to fix your
/etc/fstab if your GNU/Linux partitions moved, however that is beyond
the spoke of this document.
penguinppc.org is the new home of the PowerPC GNU/Linux project, the
发表于 2004-6-30 09:27:31 | 显示全部楼层
本文将一步一步的教您使用mac-fdisk创建分区的基础。注意:如果您要和MacOS分享硬盘,您将需要首先使用MacOS的工具Drive Setup创建MacOS分区。在创建MacOS分区时,您必须首先使用Drive Setup一个HFS的占位分区,其大小应与您计划中GNU/Linux分区大小总和相等。例如:如果您计划创建4个1GB的Linux分区,您要创建一个4GB的HFS分区占位。您将使用mac-fdisk删除这个分区,并使用这个分区占有的位置创建Linux分区。MacOS分区应当在硬盘的最后面。
对NewWorld系统来讲,您必须在所有MacOS分区的前面创建一个类型为Apple_Bootstrap的800K的分区。
不要试图使用苹果的Drive Setup创建Linux分区!
如果您不想保留MacOS,只想有一个GNU/Linux系统在硬盘上,您可以在mac-fdish中使用“i”命令来清除分区表,建立一个全新的空盘。但是,mac-fdisk有时候可能会错误的计算硬盘拥有的块数。当您运行“i”命令时,它将询问硬盘所拥有的块数,请在接受之前确认这个数字是正确的。
注意:Debian woody的mac-fdisk已经被修复,不在有这个问题。如果您使用Debian woody引导软盘,您不需要象下面要陈述的这样确定块数。
要确定硬盘块数,您必须执行下面的一些步骤(如果使用Debain woody的mac-fdisk您可以跳过这些):

# cat /proc/partitions

找到您要分区的设备,例如“hda”,您应当可以看到类似:

...
3 0 20044080 hda
...

纪录在“hda”旁边的数字并乘2,在本例中,您可以得到40088160,这就是快大小为512字节的/dev/hda块数;这也是当您使用“i”命令时,mac-fdisk默认的块数,当然是在不手动输入的情况下。
如果您和MacOS共享硬盘,您应当已经创建了两个HFS分区,第一个只是一个占位用以保留安装Linux所需的空间。第二个是给MacOS用的。请注意,如果您还想安装MacOSX,您应当使用Drive Setup来建立一个类型为Apple_UFS或MacOSX的第三个分区。MacOSX会把这个分区当成占位,它会首先删除它,然后创建两个bootstrap分区,然后重新建立Apple_UFS分区。非常重要的一点是,您不能将Apple_UFS分区建立在GNU/Linux占位之前,否则MacOSX的bootstrap分区会处于Linux的bootstrap分区之前。不推荐MacOSX使用HFS+,因为OSX分区将不会受到MacOS的保护从而不能正常引导。GNU/Linux对不用于HFS+的UFS有只读支持。
首先,您需要找到并且删除占位分区:
当您输入mac-fdisk您得到如下提示:

Command (? for help):

您要使用的第一个命令是“p”显示命令:

Command (? for help): p
/dev/sdb
# type name length base ( size ) system
/dev/sdb1 Apple_partition_map Apple 63 @ 1 ( 31.5k) Partition map
/dev/sdb2 Apple_Driver43 Macintosh 54 @ 64 ( 27.0k) Driver 4.3
/dev/sdb3 Apple_Driver43 Macintosh 74 @ 118 ( 37.0k) Driver 4.3
/dev/sdb4 Apple_Driver_IOKit Macintosh 512 @ 192 (256.0k) Unknown
/dev/sdb5 Apple_Patches Patch Partition 512 @ 704 (256.0k) Unknown
/dev/sdb6 Apple_HFS untitled 194557 @ 1216 ( 95.0M) HFS
/dev/sdb7 Apple_HFS untitled 2 333025 @ 195773 (162.6M) HFS
/dev/sdb8 Apple_Free Extra 10 @ 528798 ( 5.0k) Free space

Block size=512, Number of Blocks=528807
DeviceType=0x0, DeviceId=0x0
Drivers-
1: @ 64 for 22, type=0x1
2: @ 118 for 36, type=0xffff

在本例中,占位分区有95MB(这很不合理,只是用来举例)

Note that partitions 2-5 are MacOS cruft, they are only required if
you are keeping MacOS, they are completly unnecessary if you delete
MacOS. It is reccommended that you remove all of these driver
partitions if you do not plan to keep MacOS, do this with the `i'
command.

删除这个分区,我们用“d”命令配合分区的数字。在本例,为6:

Command (? for help): d
Partition number: 6
Command (? for help): p
/dev/sdb
# type name length base ( size ) system
/dev/sdb1 Apple_partition_map Apple 63 @ 1 ( 31.5k) Partition map
/dev/sdb2 Apple_Driver43 Macintosh 54 @ 64 ( 27.0k) Driver 4.3
/dev/sdb3 Apple_Driver43 Macintosh 74 @ 118 ( 37.0k) Driver 4.3
/dev/sdb4 Apple_Driver_IOKit Macintosh 512 @ 192 (256.0k) Unknown
/dev/sdb5 Apple_Patches Patch Partition 512 @ 704 (256.0k) Unknown
/dev/sdb6 Apple_Free Extra 194557 @ 1216 ( 95.0M) Free space
/dev/sdb7 Apple_HFS untitled 2 333025 @ 195773 (162.6M) HFS
/dev/sdb8 Apple_Free Extra 10 @ 528798 ( 5.0k) Free space

您可以看到,现在那里只有空余的空间了。
建立bootstrap分区:
如果您使用Debian woody的mac-fdisk,您可以使用“b”命令来自动的创建一个类型和大小都合适的bootstrap分区:

Command (? for help): b
First block: 6P
Command (? for help): p
/dev/sdb
# type name length base ( size ) system
/dev/sdb1 Apple_partition_map Apple 63 @ 1 ( 31.5k) Partition map
/dev/sdb2 Apple_Driver43 Macintosh 54 @ 64 ( 27.0k) Driver 4.3
/dev/sdb3 Apple_Driver43 Macintosh 74 @ 118 ( 37.0k) Driver 4.3
/dev/sdb4 Apple_Driver_IOKit Macintosh 512 @ 192 (256.0k) Unknown
/dev/sdb5 Apple_Patches Patch Partition 512 @ 704 (256.0k) Unknown
/dev/sdb6 Apple_Bootstrap bootstrap 1600 @ 1216 (800.0k) Unknown
/dev/sdb7 Apple_Free Extra 192957 @ 2816 ( 94.2M) Free space
/dev/sdb8 Apple_HFS untitled 2 333025 @ 195773 (162.6M) HFS
/dev/sdb9 Apple_Free Extra 10 @ 528798 ( 5.0k) Free space

否则,您必须手动的创建它,注意“C”命令与“c”命令是不同的(译者注:大小写):

Command (? for help): C
First block: 6P
Length in blocks: 800K
Name of partition: bootstrap
Type of partition: Apple_Bootstrap
Command (? for help): p
/dev/sdb
# type name length base ( size ) system
/dev/sdb1 Apple_partition_map Apple 63 @ 1 ( 31.5k) Partition map
/dev/sdb2 Apple_Driver43 Macintosh 54 @ 64 ( 27.0k) Driver 4.3
/dev/sdb3 Apple_Driver43 Macintosh 74 @ 118 ( 37.0k) Driver 4.3
/dev/sdb4 Apple_Driver_IOKit Macintosh 512 @ 192 (256.0k) Unknown
/dev/sdb5 Apple_Patches Patch Partition 512 @ 704 (256.0k) Unknown
/dev/sdb6 Apple_Bootstrap bootstrap 1600 @ 1216 (800.0k) Unknown
/dev/sdb7 Apple_Free Extra 192957 @ 2816 ( 94.2M) Free space
/dev/sdb8 Apple_HFS untitled 2 333025 @ 195773 (162.6M) HFS
/dev/sdb9 Apple_Free Extra 10 @ 528798 ( 5.0k) Free space

`First block:'(第一块)我们用第一个Apple_Free分区,分区6,所以您可以使用句法“6P”以避免自己来计算开始的块。同时注意,现在的Apple_Free分区已经是第7个分区,并且已经小了1600个块。这种情况会在您在剩余空间上创建新的分区时发生,直到没有剩余空间可用时。Apple_Free分区将不复存在。
现在创建剩下的GNU/Linux分区,这里只示范一个分区。

Command (? for help): c
First block: 7P
Length in blocks: 7P
Name of partition: /
Command (? for help): p
/dev/sdb
# type name length base ( size ) system
/dev/sdb1 Apple_partition_map Apple 63 @ 1 ( 31.5k) Partition map
/dev/sdb2 Apple_Driver43 Macintosh 54 @ 64 ( 27.0k) Driver 4.3
/dev/sdb3 Apple_Driver43 Macintosh 74 @ 118 ( 37.0k) Driver 4.3
/dev/sdb4 Apple_Driver_IOKit Macintosh 512 @ 192 (256.0k) Unknown
/dev/sdb5 Apple_Patches Patch Partition 512 @ 704 (256.0k) Unknown
/dev/sdb6 Apple_Bootstrap bootstrap 1600 @ 1216 (800.0k) Unknown
/dev/sdb7 Apple_UNIX_SVR2 / 192957 @ 2816 ( 94.2M) Linux native
/dev/sdb8 Apple_HFS untitled 2 333025 @ 195773 (162.6M) HFS
/dev/sdb9 Apple_Free Extra 10 @ 528798 ( 5.0k) Free space

在本例中,我们使用了“c”命令而不是“C”。区别是“c”不询问分区类型,而要得到那个特殊的Apple_Bootstrap分区,我们必须输入分区类型。同时注意我们使用了“7P”的句法于“Length of Blocks:”(块长度),这意味着使用所有Apple_Free分区的空间。对其他的分区,您也许愿意使用xyzM的格式表示有多少兆字节的空间,就象上面我们在bootstrap分区中使用800K表示800千字节。
除了swap分区需要使用“swap”作为分区名,分区名并不重要。我发现使用挂载点路径为分区名十分的有用。
一旦您觉得满意了,输入“w”命令来保存结果:

Command (? for help): w
Writing the map destroys what was there before. Is that okay? [n/y]: y
The partition table has been altered!

SCSI device sdb: hdwr sector= 512 bytes. Sectors= 528808 [258 MB] [0.3 GB]
sdb: sdb1 sdb2 sdb3 sdb4 sdb5 sdb6 sdb7 sdb8 sdb9
SCSI device sdb: hdwr sector= 512 bytes. Sectors= 528808 [258 MB] [0.3 GB]
sdb: sdb1 sdb2 sdb3 sdb4 sdb5 sdb6 sdb7 sdb8 sdb9
Command (? for help):

now quit mac-fdisk with the `q' command:

Command (? for help): q

如果您不打算保留MacOS,您必须象下面这样清除分区表:

Command (? for help): i
map already exists
do you want to reinit? [n/y]: y
size of 'device' is 528808 blocks:
new size of 'device' is 528808 blocks
Command (? for help): p
/dev/sda
# type name length base ( size ) system
/dev/sda1 Apple_partition_map Apple 63 @ 1 ( 31.5k) Partition map
/dev/sda2 Apple_Free Extra 528744 @ 64 (258.2M) Free space

Block size=512, Number of Blocks=528808
DeviceType=0x0, DeviceId=0x0

Command (? for help):

注意如果mac-fdisk关于“设备”的“大小”的数据是错误的,请象上面陈述的那样输入正确的数值。清除分区表的好处是可以除去使用Drive setup创建的所有MacOS各种各样的分区。这些分区只在您想和MacOS分享硬盘时有用。
象上例示范的一样建立您的分区。

---- 重排分区 ----

MacOSX使用用Drive setup创建的Apple_UFS分区作为占位,然后会删除它并且创建两个自己的bootstrap分区,最后重新创建Apple_UFS分区。您必须将GNU/Linux占位创建于MacOS或MacOSX分区之前。然而,您可能没有这样做,这里是修复的方法。
如果您不小心在MacOS分区厚创建了bootstrap分区,并且重新分区已经太晚了,重排分区是很有用的。
幸运的是,修复是十分容易的。当您重新引导回到GNU/Linux系统时,运行mac-fdisk(aka pdisk),使用“p”命令显示分区表。找到bootstrap的新的分区数,然后使用“r”命令来将它移动到应有的位置。下面是一个例子:

[root@socrates /root]# mac-fdisk /dev/sda
Command (? for help): p
/dev/sda
# type name length base ( size ) system
/dev/sda1 Apple_partition_map Apple 63 @ 1 ( 31.5k) Partition map
/dev/sda2 Apple_Boot MacOSX_Bootstrap 16384 @ 64 ( 8.0M) Unknown
/dev/sda3 Apple_Second MacOSX_Second_stage 2048 @ 16448 ( 1.0M) Unknown
/dev/sda4 Apple_HFS MacOS9 102400 @ 18496 ( 50.0M) HFS
/dev/sda5 Apple_UFS MacOSX 112640 @ 120896 ( 55.0M) Unknown
/dev/sda6 Apple_Bootstrap bootstrap 1600 @ 233536 (800.0k) Unknown
/dev/sda7 Apple_UNIX_SVR2 GNU/Linux 293672 @ 235136 (143.4M) Linux native

Block size=512, Number of Blocks=528808
DeviceType=0x0, DeviceId=0x0

Command (? for help): r
Partition number: 6
New number: 2
Command (? for help): p
/dev/sda
# type name length base ( size ) system
/dev/sda1 Apple_partition_map Apple 63 @ 1 ( 31.5k) Partition map
/dev/sda2 Apple_Bootstrap bootstrap 1600 @ 233536 (800.0k) Unknown
/dev/sda3 Apple_Boot MacOSX_Bootstrap 16384 @ 64 ( 8.0M) Unknown
/dev/sda4 Apple_Second MacOSX_Second_stage 2048 @ 16448 ( 1.0M) Unknown
/dev/sda5 Apple_HFS MacOS9 102400 @ 18496 ( 50.0M) HFS
/dev/sda6 Apple_UFS MacOSX 112640 @ 120896 ( 55.0M) Unknown
/dev/sda7 Apple_UNIX_SVR2 GNU/Linux 293672 @ 235136 (143.4M) Linux native

Block size=512, Number of Blocks=528808
DeviceType=0x0, DeviceId=0x0

Command (? for help): w
Writing the map destroys what was there before. Is that okay? [n/y]: y
The partition table has been altered!

SCSI device sda: hdwr sector= 512 bytes. Sectors= 528808 [258 MB] [0.3 GB]
sda: sda1 sda2 sda3 sda4 sda5 sda6 sda7
SCSI device sda: hdwr sector= 512 bytes. Sectors= 528808 [258 MB] [0.3 GB]
sda: sda1 sda2 sda3 sda4 sda5 sda6 sda7
Command (? for help): q
[root@socrates /root]#

这样就能解决这个问题。您还必须修改/etc/fstab如果GNU/Linux分区被移动。当然,这已超出本文讨论的范围。
发表于 2004-7-1 20:29:08 | 显示全部楼层
Done.
本人的华语水平有限。翻译中大多采用意译。欢迎大家多提意见,使它更加完善。
 楼主| 发表于 2004-7-2 09:37:49 | 显示全部楼层
多谢兄弟,辛苦了。。。

这篇文章是玩家必备的,是基础的基础。。。。。

再次感谢。。

北南 呈上
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表