Linux中国 Linux中国门户站!
设为主页 设为主页
收藏本站 收藏本站
 
当前位置 :首页 ->Linux技术 ->内核研究 ->正文

制作RAMDISK in KERNEL的NetBSD

来源:cnfug 作者:Mathrew  时间:2007-04-22 点击: [收藏] [投稿]

前言

在前面我们已经讲过怎么样制作软盘上运行的FreeBSD和OpenBSD系统,现在我们来看看怎么样制作一个运行在软盘上的NetBSD系统。同软盘中的OpenBSD系统一样,我们还是将系统中的所有配制文件及程序全部存放到NetBSD的内核中,这样整个系统看起来就是一个文件。下面让我们具体来看看怎么样完成这样一个微系统的制作。

0、NetBSD的启动过程

当硬盘MBR中的引导程序接过启动之后,MBR中的程序将读入硬盘NetBSD分区中的引导程序,引导程序默认情况下会加载/boot,然后由 boot载入内核/netbsd,此时内核开始检测一些硬件和做一些初始化。初始化完成后kernel将mount root device,然后启动系统初始化进程/sbin/init,init将根据/etc/rc中的设置来进行初始化等。

1、定制RAMDISK内核

要使用RAMDISK in KERNEL就必须在内核配制文件中加入以下选项:

options MEMORY_DISK_HOOKS
options MEMORY_DISK_IS_ROOT # force root on memory disk
options MEMORY_DISK_SERVER=0
options MEMORY_DISK_ROOT_SIZE=10000 # size of memory disk, in blocks
options MEMORY_RBFLAGS=0x00 # boot in to multi-user mode
pseudo-device md 1 # memory disk device (ramdisk)

以上的内核参数意义如下:

MEMORY_DISK_ROOT_SIZE : 内存磁盘大小,以块为单位
MEMORY_RBFLAGS=0x00 : 启动到多用户模式

以下是在我机器上使用的一个内核配制文件

include "arch/i386/conf/std.i386"

#options INCLUDE_CONFIG_FILE # embed config file in kernel binary

makeoptions COPTS="-Os" # Optimise for space. Implies -O2

# Enable the hooks used for initializing the root memory-disk.
options MEMORY_DISK_HOOKS
options MEMORY_DISK_IS_ROOT # force root on memory disk
options MEMORY_DISK_SERVER=1 # 0 readonly 1 writable
options MEMORY_DISK_ROOT_SIZE=10000 # size of memory disk, in blocks
options MEMORY_RBFLAGS=0x00 # boot in to multi-user mode

maxusers 48 # estimated number of users

# CPU support. At least one is REQUIRED.
options I386_CPU
options I686_CPU

# CPU-related options.
options MATH_EMULATE # floating point emulation

# This option allows you to force a serial console at the specified
# I/O address.
#options CONSDEVNAME="\"com\"",CONADDR=0x3f8,CONSPEED=9600

# Avoid irq 5 and 7, the most likely cause of problems on modern laptops.
options PCIC_ISA_INTR_ALLOC_MASK=0xff5f

# Standard system options

options INSECURE # disable kernel security levels

options RTC_OFFSET=0 # hardware clock is this many mins. west of GMT
#options NTP # NTP phase/frequency locked loop

options USERCONF # userconf(4) support
options PIPE_SOCKETPAIR # smaller, but slower pipe(2)
options MALLOC_NOINLINE # Not inlining MALLOC saves memory

# File systems
file-system FFS # UFS
file-system MFS # memory file system
file-system MSDOSFS # MS-DOS file system
file-system KERNFS # /kern

options VNODE_OP_NOINLINE # Not inlining vnode op calls saves mem

# Networking options
options GATEWAY # packet forwarding
options INET # IP + ICMP + TCP + UDP
#options PFIL_HOOKS # pfil(9) packet filter hooks

# builtin terminal emulations
options WSEMUL_VT100 # VT100 / VT220 emulation
# different kernel output - see dev/wscons/wsdisplayvar.h
options WS_KERNEL_FG=WSCOL_BLACK
options WS_KERNEL_BG=WSCOL_WHITE
# compatibility to other console drivers
#options WSDISPLAY_COMPAT_PCVT # emulate some ioctls
#options WSDISPLAY_COMPAT_SYSCONS # emulate some ioctls
#options WSDISPLAY_COMPAT_USL # VT handling
#options WSDISPLAY_COMPAT_RAWKBD # can get raw scancodes
# see dev/pckbc/wskbdmap_mfii.c for implemented layouts
#options PCKBD_LAYOUT="(KB_DE | KB_NODEAD)"
# allocate a number of virtual screens at autoconfiguration time
#options WSDISPLAY_DEFAULTSCREENS=4
# use a large software cursor that doesn't blink
options PCDISPLAY_SOFTCURSOR
# modify the screen type of the console; defaults to "80x25"
#options VGA_CONSOLE_SCREENTYPE="\"80x24\""

# Kernel root file system and dump configuration.
config netbsd root on ? type ?
#config netbsd root on sd0a type ffs
#config netbsd root on ? type nfs

#
# Device configuration
#

mainbus0 at root

cpu* at mainbus?

apm0 at mainbus0 # Advanced power management


# Basic Bus Support

# PCI bus support
pci* at mainbus? bus ?
pci* at pchb? bus ?
pci* at ppb? bus ?

# PCI bridges
pchb* at pci? dev ? function ? # PCI-Host bridges
pceb* at pci? dev ? function ? # PCI-EISA bridges
pcib* at pci? dev ? function ? # PCI-ISA bridges
ppb* at pci? dev ? function ? # PCI-PCI bridges
# XXX 'puc's aren't really bridges, but there's no better place for them here
puc* at pci? dev ? function ? # PCI "universal" comm. cards

# ISA bus support
isa0 at mainbus?
isa0 at pceb?
isa0 at pcib?

# ISA Plug-and-Play bus support
isapnp0 at isa?

# Coprocessor Support

# Math Coprocessor support
npx0 at isa? port 0xf0 irq 13 # x86 math coprocessor



 如果您对本文有任何疑问或者建议,请到讨论区发表您的意见: >> 论坛入口 <<



上一篇:制作RAMDISK in KERNEL的OpenBSD   下一篇:FreeBSD光盘运行版的制作过程

文章评论】 【收藏本文】 【推荐好友】 【打印本文】 【我要投稿】 【论坛讨论
更多相关文章
Power by linux-cn.com 粤ICP备05006655号