分享
 
 
 

制作RAMDISKinKERNEL的NetBSD微系统

王朝other·作者佚名  2008-05-21
窄屏简体版  字體: |||超大  

Matthew(黑夜编码人) <matthew@cnfug.org>

前言

在前面我们已经讲过如何制作软盘上运行的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_HOOKSoptions MEMORY_DISK_IS_ROOT # force root on memory diskoptions MEMORY_DISK_SERVER=0options MEMORY_DISK_ROOT_SIZE=10000 # size of memory disk, in blocksoptions MEMORY_RBFLAGS=0x00 # boot in to multi-user modepseudo-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_HOOKSoptions MEMORY_DISK_IS_ROOT # force root on memory diskoptions MEMORY_DISK_SERVER=1 # 0 readonly 1 writableoptions MEMORY_DISK_ROOT_SIZE=10000 # size of memory disk, in blocksoptions MEMORY_RBFLAGS=0x00 # boot in to multi-user mode

maxusers 48 # estimated number of users

# CPU support. At least one is REQUIRED.options I386_CPUoptions 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) supportoptions PIPE_SOCKETPAIR # smaller, but slower pipe(2)options MALLOC_NOINLINE # Not inlining MALLOC saves memory

# File systemsfile-system FFS # UFSfile-system MFS # memory file systemfile-system MSDOSFS # MS-DOS file systemfile-system KERNFS # /kern

options VNODE_OP_NOINLINE # Not inlining vnode op calls saves mem

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

# builtin terminal emulationsoptions WSEMUL_VT100 # VT100 / VT220 emulation# different kernel output - see dev/wscons/wsdisplayvar.hoptions WS_KERNEL_FG=WSCOL_BLACKoptions 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 blinkoptions 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 supportpci* at mainbus? bus ?pci* at pchb? bus ?pci* at ppb? bus ?

# PCI bridgespchb* at pci? dev ? function ? # PCI-Host bridgespceb* at pci? dev ? function ? # PCI-EISA bridgespcib* at pci? dev ? function ? # PCI-ISA bridgesppb* at pci? dev ? function ? # PCI-PCI bridges# XXX 'puc's aren't really bridges, but there's no better place for them herepuc* at pci? dev ? function ? # PCI "universal" comm. cards

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

# ISA Plug-and-Play bus supportisapnp0 at isa?

# Coprocessor Support

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

# Console Devices

# ISA console#pc0 at isa? port 0x60 irq 1 # pccons generic PC console driver

# wsconspckbc0 at isa? # pc keyboard controllerpckbd* at pckbc? # PC keyboard#pms* at pckbc? # PS/2 mouse for wsmousevga0 at isa?vga* at pci? dev ? function ?pcdisplay0 at isa? # CGA, MDA, EGA, HGAwsdisplay* at vga? console ?wsdisplay* at pcdisplay? console ?wskbd* at pckbd? console ?#wsmouse* at pms? mux 0

pcppi0 at isa?sysbeep0 at pcppi?

# Serial Devices

# PCI serial interfacescom* at puc? port ? # 16x50s on "universal" comm boards#cy* at pci? dev ? function ? # Cyclades Cyclom-Y serial boards

# ISA Plug-and-Play serial interfacescom* at isapnp? # Modems and serial boards

# ISA serial interfaces#options COM_HAYESP # adds Hayes ESP serial board supportcom0 at isa? port 0x3f8 irq 4 # Standard PC serial portscom1 at isa? port 0x2f8 irq 3com2 at isa? port 0x3e8 irq 5#com3 at isa? port 0x2e8 irq 9#ast0 at isa? port 0x1a0 irq 5 # AST 4-port serial cards#com* at ast? slave ?#boca0 at isa? port 0x100 irq 5 # BOCA 8-port serial cards#com* at boca? slave ?#tcom0 at isa? port 0x100 irq 7 # TC-800 8-port serial cards#com* at tcom? slave ?#rtfps0 at isa? port 0x1230 irq 10 # RT 4-port serial cards#com* at rtfps? slave ?#cy0 at isa? iomem 0xd4000 irq 12 # Cyclades serial cards

# Miscellaneous mass storage devices

# Network Interfaces

# PCI network interfacesfxp* at pci? dev ? function ? # Intel EtherExpress PRO 10+/100Ble* at pci? dev ? function ? # PCnet-PCI Ethernetpcn* at pci? dev ? function ? # AMD PCnet-PCI Ethernetrtk* at pci? dev ? function ? # Realtek 8129/8139

amhphy* at mii? phy ? # AMD 79c901 Ethernet PHYsurlphy* at mii? phy ? # Realtek RTL8150L internal PHYsukphy* at mii? phy ? # generic unknown PHYs

# Pseudo-Devices

# disk/mass storage pseudo-devicespseudo-device md 1 # memory disk device (ramdisk)#pseudo-device vnd 4 # disk-like interface to files

# network pseudo-devicespseudo-device bpfilter 8 # Berkeley packet filterpseudo-device ipfilter # IP filter (firewall) and NATpseudo-device loop # network loopbackpseudo-device ppp 2 # Point-to-Point Protocolpseudo-device pppoe 3

# miscellaneous pseudo-devicespseudo-device pty 2 # pseudo-terminals (Sysinst needs two)# wscons pseudo-devicespseudo-device wsmux # mouse & keyboard multiplexor#pseudo-device wsfont

2、制作ramdisk镜像# dd if=/dev/zero of=/ramdisk bs=512 count=9000# vnconfig -c /dev/vnd0d /ramdisk# disklabel -r -w /dev/vnd0d rdroot# newfs -m 0 -S 512 -i 4096 /dev/vnd0a# mount /dev/vnd0a /mnt# mkdir /mnt/{dev,bin,sbin,etc}# cp /dev/MAKEDEV /mnt/dev# cp /bin/{sh,ls} /mnt/bin# cp /sbin/init /mnt/sbin# cd /mnt/dev/ && ./MAKEDEV ramdisk# echo 'echo "This is my minibsd all in kernel" && /bin/sh' > /mnt/etc/rc# sync && umount /mnt# sync && vnconfig -u vnd0d && sync

3、将ramdisk写入kernel# mdsetroot /minibsd ramdisk

4、压缩kernel大小# gzip -9 -c /minibsd > /minibsd.gz

5、制作目标软盘

因为系统需要使用/boot(/usr/mdec/boot)来加载kernel,所以我们需要在软盘上放置boot文件。

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有