Chinaunix首页 | 论坛 | 博客
  • 博客访问: 716648
  • 博文数量: 235
  • 博客积分: 4309
  • 博客等级: 中校
  • 技术积分: 2325
  • 用 户 组: 普通用户
  • 注册时间: 2011-01-17 11:25
个人简介

If you don\\\\\\\\\\\\\\\'t wanna do it, you find an EXCUSE; if you do, you\\\\\\\\\\\\\\\'ll find a WAY :-)

文章分类

全部博文(235)

文章存档

2014年(3)

2013年(2)

2012年(31)

2011年(199)

分类: BSD

2011-10-11 13:59:21

1:Back Up Your Working Kernel
  1. # cp -Rp /boot/kernel /boot/kernel.good

2:保存 Kernel 配置文件
  1. # cd /usr/src/sys/amd64/conf
  2. # mkdir /root/kernels
  3. # cp GENERIC /root/kernels/MYKERNEL
  4. # ln -s /root/kernels/MYKERNEL
3:Trimming a Kernel
  1. # dmesg |grep 'not found' (看看GENERIC 内核是不是捕捉到了所有 硬件)
  2. # dmesg |grep -i cpu (蓝色字体 便是阁下的 CPU架构)
  3. CPU: Intel(R) Core(TM) i7 CPU Q740 @ 1.73GHz (1728.97-MHz K8-class CPU)
  4. <你会不会问我了?  内核配置文件 要写 K8 哦?自然不是!>

  5. 判断内核配置 CPU 选项如何填写:
  6. # less /usr/src/sys/amd64/conf/NOTES (找到你相应架构的目录)
  7. CPU OPTIONS
  8. cpu HAMMER # aka K8, aka Opteron & Athlon64

  9. 方法一:根据 GENERIC 调整配置
  10. # vim MYKERNEL
  1. # Basic Options
  2. cpu HAMMER (CPU 架构类型)
  3. ident MYKERNEL (命名)
  4. makeoptions  DEBUG=-g # Build kernel with gdb debug symbols

  5. options SCHED_ULE # ULE scheduler
  6. options PREEMPTION # Enable kernel thread preemption

  7. options INET # InterNETworking
  8. options INET6 # IPv6 communications protocols
  9. options SCTP # Stream Control Transmission Protocol

  10. options FFS # Berkeley Fast Filesystem
  11. options SOFTUPDATES # Enable FFS soft updates support
  12. options UFS_ACL # Support for access control lists
  13. options UFS_DIRHASH # Improve performance on big directories
  14. options UFS_GJOURNAL # Enable gjournal-based UFS journaling

  15. options MD_ROOT # MD is a potential root device
  16. options NFSCLIENT # Network Filesystem Client
  17. options NFSSERVER # Network Filesystem Server
  18. options NFSLOCKD # Network Lock Manager
  19. options NFS_ROOT # NFS usable as /, requires NFSCLIENT

  20. options MSDOSFS # MSDOS filesystem
  21. options CD9660 # ISO 9660 filesystem
  22. options PROCFS # Process filesystem (requires PSEUDOFS)
  23. options PSEUDOFS # Pseudo-filesystem framework

  24. options GEOM_PART_GPT # GUID Partition Tables
  25. options GEOM_LABEL # Provides labelization

  26. options COMPAT_43TTY    # BSD 4.3 TTY compat [KEEP THIS!]
  27. options COMPAT_FREEBSD32  # Compatible with i386 binaries
  28. options COMPAT_FREEBSD4 # Compatible with FreeBSD4
  29. options COMPAT_FREEBSD5 # Compatible with FreeBSD5
  30. options COMPAT_FREEBSD6 # Compatible with FreeBSD6
  31. options  COMPAT_FREEBSD7 # Compatible with FreeBSD7

  32. options SCSI_DELAY=5000 # Delay (in ms) before probing SCSI
  33. options KTRACE # ktrace(1) support
  34. options SYSVSHM # SYSV-style shared memory
  35. options SYSVMSG # SYSV-style message queues
  36. options SYSVSEM # SYSV-style semaphores

  37. options P1003_1B_SEMAPHORES # POSIX-style semaphores
  38. options _KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time extensions
  39. options KBD_INSTALL_CDEV # install a CDEV entry in /dev
  40. options AUDIT # Security event auditing

  41. # Make an SMP-capable kernel by default
  42. options SMP # Symmetric MultiProcessor Kernel
  43. ... ... ...
  44. ... ... ...

  45. # Device Drivers
  46. # Floppy drives
  47. # device fdc (注释掉 没有的设备)
  48. :wq

  49. 方法二:Include GENERIC 
  50. # vim MYKERNEL
  51. ident MYKERNEL (命名)
  52. include GENERIC (包含 GENERIC)
  53. options CPU_SOEKRIS (添加 选项)

  54. nooption MSDOSFS   (撤销 选项)
  55. nodevice fdc   (撤销 设备)
  56. :wq


4:Building a Kernel
  1. # cd /usr/src
  2. # make buildkernel KERNCONF=MYKERNEL ()
  3. # make installkernel KERNCONF=MYKERNEL
  4. 关于用不用 -j选项:
  5. (-j:理论上核心数 +1更多不起作用,因为 线程与核心 本身无法等同
  6. 但是:
  7. 由于less /usr/src/UPDATING 文档内提到
  8. General Notes
  9. -------------
  10. Avoid using make -j when upgrading. From time to time in the
  11. past there have been problems using -j with buildworld and/or
  12. installworld. This is especially true when upgrading between
  13. "distant" versions (eg one that cross a major release boundary
  14. or several minor releases, or when several months have passed
  15. on the -current branch).
  16. 因此:我建议大家还是不要用了,除了kernel 和 buildworld 其他软件想用无妨!)

5:Testing Kernel
  1. 方法一:安装后直接运行 new kernel

  2. 方法二:nextboot
  3. # make KERNCONF=MYKERNEL INSTKERNAME=test kernel (编译安装时起个名字)
  4. 此时你已经安装完 new kernel !

  5. # mv /boot/kernel /boot/kernel.test
  6. # mkdir /boot/kernel
  7. # cp /boot/kernel.good/* /boot/kernel/ (将老版本Kernel 拉回来)

  8. # nextboot -t kernel.test (下次启动运行kernel.test,仅一次)
  9. # mv /boot/kernel /boot/kernel.previous (测试后保存 老版本 kernel)
  10. # mv /boot/kernel.test /boot/kernel (将kernel.test 改为默认 kernel)
  11. ------------------------------------------------------------------------------------------------------
  12. 声明:这是从书上看到的 我感觉很变态

  13. 下面这是 less /usr/src/UPDATING 文档里的方法 (这个很正常)
  14. To test a kernel once
  15. ---------------------
  16. If you just want to boot a kernel once (because you are not sure
  17. if it works, or if you want to boot a known bad kernel to provide
  18. debugging information) run
  19. make installkernel KERNCONF=YOUR_KERNEL_HERE KODIR=/boot/testkernel
  20. nextboot -k testkernel

  21. 方法三:Loader Prompt
  22. ok unload (erase the loaded kernel and all modules from memory)
  23.    ok load /boot/kernel.test/kernel
       ok load /boot/kernel.test/acpi.ko
       ok boot   (使用 kernel.test 重新启动)

6:

阅读(914) | 评论(0) | 转发(0) |
0

上一篇:NMAP

下一篇:Building FreeBSD from Source

给主人留下些什么吧!~~