#disklabel wd0

可以看到原始分区如下: 7 partitions:

#        size    offset     fstype [fsize bsize cpg/sgs]
a:  20971520  25167648     4.2BSD      0     0     0  # (Cyl.  24967*-  45772*)
b:   1048576  46139168       swap                     # (Cyl.  45772*-  46813*)
c: 117210240         0     unused      0     0        # (Cyl.      0 - 116279)
d:  25165824      1824        HFS                     # (Cyl.      1*-  24967*)
e:  28079456  89130784        HFS                     # (Cyl.  88423*- 116279)
g:  41943040  47187744     4.2BSD      0     0     0  # (Cyl.  46813*-  88423*)

a为netbsd的/分区,b为swap分区,c为整个硬盘,d为mac os的系统盘。e为两系统共享分区(在os9下格式化为fat),g为netbsd下的/home分区。 原本是两系统,os9.2一直都很少用,所以想删了,腾出空间来放数据。因为wd0d和wd0e不在连续的柱面上,所以无法将它们合并。

新的分区方案如下:wd0d删了,分成两个,一个15M(需要一个HFS类型的分区来放置ofwboot.xcf,因为openfirmwire不支持从netbsd分区里加载loader),剩下的作为/home分区。把原来的/home分区(wd0g)和共享数据的分区(wd0e)合并为一个分区,用于放置数据。

  1. 第一步,也是最关键的一步,先备份好数据。

2. 安装hfsutils。用于操作那个15M的HFS分区(格式化,拷贝文件等工具)。hfsutils是命令行的,xhfs是tk界面的。

    #cd /usr/pkgsrc/sysutils/hfsutils
    #make install
    #cd ../xhfs
    #make install

3.    分区 pdisk : Apple partition table editor

    # pdisk /dev/wd0c
    pdisk /dev/wd0c
    Edit /dev/wd0c -
    Command (? for help): p
    p

    Partition map (with 512 byte blocks) on '/dev/wd0c'
    #:                type name              length   base     ( size )
    1: Apple_partition_map Apple                 63 @ 1
    2:      Apple_Driver43*Macintosh             56 @ 64
    3:      Apple_Driver43*Macintosh             56 @ 120
    4:    Apple_Driver_ATA*Macintosh             56 @ 176
    5:    Apple_Driver_ATA*Macintosh             56 @ 232
    6:      Apple_FWDriver Macintosh            512 @ 288
    7:  Apple_Driver_IOKit Macintosh            512 @ 800
    8:       Apple_Patches Patch Partition      512 @ 1312
    9:           Apple_HFS MacOS           25165824 @ 1824     ( 12.0G)
    10:     Apple_UNIX_SVR2 NetBSD          20971520 @ 25167648 ( 10.0G) S0 RUFS k0  /
    11:     Apple_UNIX_SVR2 swap             1048576 @ 46139168 (512.0M) S1  SFS k0  (swap)
    12:     Apple_UNIX_SVR2 home            41943040 @ 47187744 ( 20.0G) S2  UFS k0  /usr
    13:           Apple_HFS Share           28079456 @ 89130784 ( 13.4G)

    Device block size=512, Number of Blocks=117210240 (55.9G)
    DeviceType=0x0, DeviceId=0x0
    Drivers-
    1:  23 @ 64, type=0x1
    2:  36 @ 120, type=0xffff
    3:  21 @ 176, type=0x701
    4:  34 @ 232, type=0xf8ff

##可以看出9分区即为wd0d,10分区为wd0a,11分区为wd0b,12分区为wd0g,13分区为wd0e。

##删9分区 Command (? for help): d d Partition number: 9 9
##创建15M分区(ofwboot.xcf只有52k,这个分区只须大于100k)

    Command (? for help): C
    C
    First block: 9p
    9p
    Length in blocks: 15m
    15m
    Name of partition: Loader
    Loader
    Type of partition: Apple_HFS
    Apple_HFS

    Command (? for help): C
    C
    First block: 10p
    10p
    Length in blocks: 10p
    10p
    Name of partition: home
    home
    Type of partition: Apple_UNIX_SVR2
    Apple_UNIX_SVR2
    Available partition slices for Apple_UNIX_SVR2:
    a   root partition
    b   swap partition
    c   do not set any bzb bits
    g   user partition
    Other lettered values will create user partitions
    Select a slice for default bzb values: i
    i

#保存退出

    Command (? for help): w
    w
    Writing the map destroys what was there before. Is that okay? [n/y]: y
    y
    Command (? for help): q
    q

4. 改完分区后重新启动。此时netbsd的/分区已由10分区变为11分区,而硬盘上已经没有ofwboot.xcf可用来启动系统。这个时候需要用到netbsd的安装盘,开机时按住command+option+o+f四键。进入openfirmwire。放入光盘,敲命令:

boot
cd:,\ofwboot.xcf
hd:11,/netbsd

使用光盘上的ofwboot.xcf来引导硬盘上的系统。系统启动到了挂载分区时出错。提示wd0g非法。wd0g为/home分区,并无修改。

5.    安装光盘启动。在openfirmwire里敲

boot cd:,\ofwboot.xcf netbsd.macppc

先择运行Shell. 查看分区

    #disklabel wd0
    7 partitions:
    #        size    offset     fstype [fsize bsize cpg/sgs]
    a:  20971520  25167648     4.2BSD      0     0     0  # (Cyl.  24967*-  45772*)
    b:   1048576  46139168       swap                     # (Cyl.  45772*-  46813*)
    c: 117210240         0     unused      0     0        # (Cyl.      0 - 116279)
    d:     30720      1824        HFS                     # (Cyl.      1*-     32*)
    e:  41943040  47187744     4.2BSD      0     0     0  # (Cyl.  46813*-  88423*)
    f:  28079456  89130784     4.2BSD      0     0     0  # (Cyl.  88423*- 116279)
    g:  25135104     32544     4.2BSD      0     0     0  # (Cyl.     32*-  24967*)

原来的wd0g变成了wd0e,我也不知道为何。但是问题还是很好解决的。

#mount /dev/wd0a /mnt 
#chroot /mnt 
##修改fstab,改wd0g为wd0e
#vi /etc/fstab 
#reboot

6. 返回第4步启动系统。正常启动后。由第5步disklabel中的输出知道,9分区是wd0d.

## 将其格式化为hfs
#hformat -l loader /dev/wd0d  
$sudo xhfs

运行xhfs,把ofwboot.xcf拷入此分区。

7.  改变home分区

#newfs /dev/wd0g 
#cd /home 
##打包用户数据,并保留原始权限
#tar cjpvf ygc.tar.bz2 ygc     
#mount /dev/wd0g /mnt/share 
#cd /mnt/share 
#tar xjvpf ygc.tar.bz2 
#vim /etc/fstab

把wd0e换成wd0g,修改home分区的挂载设备。

8.  合并wd0e,wd0f 也就是原来的home分区和两系统的共享分区。

    #pdisk /dev/wd0c
    Command (? for help): d
    d
    Partition number: 14
    14
    Command (? for help): d
    d
    Partition number: 13
    13
    Command (? for help): C
    C
    First block: 13p
    13p
    Length in blocks: 13p
    13p
    Name of partition: data
    data
    Type of partition: Apple_UNIX_SVR2
    Apple_UNIX_SVR2
    Available partition slices for Apple_UNIX_SVR2:
    a   root partition
    b   swap partition
    c   do not set any bzb bits
    g   user partition
    Other lettered values will create user partitions
    Select a slice for default bzb values: h
    h

    Command (? for help): w
    w
    Writing the map destroys what was there before. Is that okay? [n/y]: y
    y
    Command (? for help): q
    q

9.    重设openfirmwire 修改后保存重启,进入openfirmwire.使用setenv命令重设启动的环境变量

setenv
boot-device hd:9,\ofwboot.xcf hd:11,/netbsd 
reset-all

重新设置后,开机就会自动进入netbsd.

10.    重启进入系统后

    #disklabel wd0
    6 partitions:
    #        size    offset     fstype [fsize bsize cpg/sgs]
    a:  20971520  25167648     4.2BSD      0     0     0  # (Cyl.  24967*-  45772*)
    b:   1048576  46139168       swap                     # (Cyl.  45772*-  46813*)
    c: 117210240         0     unused      0     0        # (Cyl.      0 - 116279)
    d:     30720      1824        HFS                     # (Cyl.      1*-     32*)
    e:  70022496  47187744     4.2BSD      0     0     0  # (Cyl.  46813*- 116279)
    g:  25135104     32544     4.2BSD      0     0     0  # (Cyl.     32*-  24967*)

新建的分区是wd0e

#newfs /dev/wd0e 
#chmod 777 /dev/wd0e      
##让用户对其有读写执行的权限 
#chmod 777 /data ## 在/etc/fstab里添加:
/dev/wd0e    /data        ffs    rw,softdep    1    2

这样就按照原来的设想修改了分区。