免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2786 | 回复: 3
打印 上一主题 下一主题

[NetBSD] Edit partition table in NetBSD/macppc [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-05-04 00:21 |只看该作者 |倒序浏览
在netbsd中修改分区
by: YGC
原文地址:http://blog.chinaunix.net/u/1885/showart.php?id=291153

#disklabel wd0
可以看到原始分区如下:

  1. 7 partitions:
  2. #        size    offset     fstype [fsize bsize cpg/sgs]
  3. a:  20971520  25167648     4.2BSD      0     0     0  # (Cyl.  24967*-  45772*)
  4. b:   1048576  46139168       swap                     # (Cyl.  45772*-  46813*)
  5. c: 117210240         0     unused      0     0        # (Cyl.      0 - 116279)
  6. d:  25165824      1824        HFS                     # (Cyl.      1*-  24967*)
  7. e:  28079456  89130784        HFS                     # (Cyl.  88423*- 116279)
  8. 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界面的。

  1. #cd /usr/pkgsrc/sysutils/hfsutils
  2. #make install
  3. #cd ../xhfs
  4. #make install
复制代码


3.        分区
pdisk : Apple partition table editor

  1. # pdisk /dev/wd0c
  2. pdisk /dev/wd0c
  3. Edit /dev/wd0c -
  4. Command (? for help): p
  5. p

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

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

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

  29. ##删9分区
  30. Command (? for help): d
  31. d
  32. Partition number: 9
  33. 9
  34. ##创建15M分区(ofwboot.xcf只有52k,这个分区只须大于100k)
  35. Command (? for help): C
  36. C
  37. First block: 9p
  38. 9p
  39. Length in blocks: 15m
  40. 15m
  41. Name of partition: Loader
  42. Loader
  43. Type of partition: Apple_HFS
  44. Apple_HFS

  45. Command (? for help): C
  46. C
  47. First block: 10p
  48. 10p
  49. Length in blocks: 10p
  50. 10p
  51. Name of partition: home
  52. home
  53. Type of partition: Apple_UNIX_SVR2
  54. Apple_UNIX_SVR2
  55. Available partition slices for Apple_UNIX_SVR2:
  56.   a   root partition
  57.   b   swap partition
  58.   c   do not set any bzb bits
  59.   g   user partition
  60. Other lettered values will create user partitions
  61. Select a slice for default bzb values: i
  62. i

  63. #保存退出
  64. Command (? for help): w
  65. w
  66. Writing the map destroys what was there before. Is that okay? [n/y]: y
  67. y
  68. Command (? for help): q
  69. 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.
查看分区

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

原来的wd0g变成了wd0e,我也不知道为何。但是问题还是很好解决的。
#mount /dev/wd0a /mnt
#chroot /mnt
#vi /etc/fstab
修改fstab,改wd0g为wd0e
#reboot

6.        返回第4步启动系统。正常启动后。由第5步disklabel中的输出知道,9分区是wd0d.
  1. #hformat -l loader /dev/wd0d
复制代码

将其格式化为hfs
$sudo xhfs
运行xhfs,把ofwboot.xcf拷入此分区。


7.        改变home分区

  1. #newfs /dev/wd0g
  2. #cd /home
  3. #tar cjpvf ygc.tar.bz2 ygc        #打包用户数据,并保留原始权限
  4. #mount /dev/wd0g /mnt/share
  5. #cd /mnt/share
  6. #tar xjvpf ygc.tar.bz2
复制代码

#vim /etc/fstab
把wd0e换成wd0g,修改home分区的挂载设备。

8.        合并wd0e,wd0f 也就是原来的home分区和两系统的共享分区。
  1. #pdisk /dev/wd0c
  2. Command (? for help): d
  3. d
  4. Partition number: 14
  5. 14
  6. Command (? for help): d
  7. d
  8. Partition number: 13
  9. 13
  10. Command (? for help): C
  11. C
  12. First block: 13p
  13. 13p
  14. Length in blocks: 13p
  15. 13p
  16. Name of partition: data
  17. data
  18. Type of partition: Apple_UNIX_SVR2
  19. Apple_UNIX_SVR2
  20. Available partition slices for Apple_UNIX_SVR2:
  21.   a   root partition
  22.   b   swap partition
  23.   c   do not set any bzb bits
  24.   g   user partition
  25. Other lettered values will create user partitions
  26. Select a slice for default bzb values: h
  27. h

  28. Command (? for help): w
  29. w
  30. Writing the map destroys what was there before. Is that okay? [n/y]: y
  31. y
  32. Command (? for help): q
  33. q
复制代码

9.        重设openfirmwire
修改后保存重启,进入openfirmwire.使用setenv命令重设启动的环境变量
  1. setenv boot-device hd:9,\ofwboot.xcf hd:11,/netbsd
  2. reset-all
复制代码

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

10.        重启进入系统后

  1. #disklabel wd0
  2. 6 partitions:
  3. #        size    offset     fstype [fsize bsize cpg/sgs]
  4. a:  20971520  25167648     4.2BSD      0     0     0  # (Cyl.  24967*-  45772*)
  5. b:   1048576  46139168       swap                     # (Cyl.  45772*-  46813*)
  6. c: 117210240         0     unused      0     0        # (Cyl.      0 - 116279)
  7. d:     30720      1824        HFS                     # (Cyl.      1*-     32*)
  8. e:  70022496  47187744     4.2BSD      0     0     0  # (Cyl.  46813*- 116279)
  9. 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

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

[ 本帖最后由 YGC 于 2007-5-5 15:38 编辑 ]

论坛徽章:
0
2 [报告]
发表于 2007-05-04 08:54 |只看该作者
楼主硬盘多大,各分区都是多少?
我的硬盘是30g,用到后来发现/usr空间满了,只好把/home也给他用了.

另外,eva用pkgsrc在netbsd3.1/i386上安装上了.
在netbsd3.1/macppc上出现问题,忘记具体错误了,好象提示我autoselect包(好象是auto什么的,呵呵,忘性好)没有,但是那个包确实有的.

[ 本帖最后由 ground 于 2007-5-4 08:59 编辑 ]

论坛徽章:
0
3 [报告]
发表于 2007-05-04 16:37 |只看该作者
1. 我的硬盘是60G,disklabel显示的size除以2就是啦。
2. 贴输出。。。

论坛徽章:
0
4 [报告]
发表于 2007-05-05 12:41 |只看该作者
eva我在macppc下安装没问题。要不要我把package发给你,你pkg_add试一下。。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP