製作RAMDISK in KERNEL的NetBSD微系統(轉)
Matthew(黑夜編碼人)
前言
在前面我們已經講過如何製作軟盤上執行的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) support
options PIPE_SOCKETPAIR # smaller, but slower pipe(2)options MALLOC_NOINLINE # Not inlining MALLOC saves memory
# File systems
file-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 options
options GATEWAY # packet forwardingoptions 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.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 support
pci* at mainbus? bus ?pci* at pchb? bus ?pci* at ppb? bus ?
# PCI bridges
pchb* 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 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
# Console Devices
# ISA console
#pc0 at isa? port 0x60 irq 1 # pccons generic PC console driver
# wscons
pckbc0 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 interfaces
com* at puc? port ? # 16x50s on "universal" comm boards#cy* at pci? dev ? function ? # Cyclades Cyclom-Y serial boards
# ISA Plug-and-Play serial interfaces
com* 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 interfaces
fxp* 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 PHYs
urlphy* at mii? phy ? # Realtek RTL8150L internal PHYsukphy* at mii? phy ? # generic unknown PHYs
# Pseudo-Devices
# disk/mass storage pseudo-devices
pseudo-device md 1 # memory disk device (ramdisk)#pseudo-device vnd 4 # disk-like interface to files
# network pseudo-devices
pseudo-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-devices
pseudo-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檔案。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10752019/viewspace-941477/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 製作RAMDISK in KERNEL的OpenBSD微系統(轉)
- NetBSD 10.0 - 類 UNIX 作業系統作業系統
- UNIX 派生系統:NetBSD 入門(轉)
- 系統安裝引導盤的製作(轉)
- 定製AIX作業系統的shell環境(轉)AI作業系統
- 使用ramdisk啟動ubuntu檔案系統Ubuntu
- ERP系統的顯微鏡 ——論製造業ERP系統成本體系建設(轉)
- QNX 如何製作目標系統,製作系統映象,燒寫系統檔案
- 製作軟盤上執行的FreeBSD系統(轉)
- 作業系統微核心和Dubbo微核心,有何不同?作業系統
- 微機結構和作業系統作業系統
- ERP系統的顯微鏡(轉)
- 作業系統微核心和Dubbo微核心各自優缺點!作業系統
- 在Unix系統下用shell製作通用介面(轉)
- Linux 製作系統映象Linux
- u盤製作系統盤
- NetBSD的網路配置(轉)
- win10系統如何安裝ramdisk【圖文】Win10
- 基於雙核的雙系統製作
- Three.js 初探 - 微場景製作JS
- rootfs -根檔案系統製作
- 製作一個報警系統
- windows10系統盤製作Windows
- 編譯linux kernel及製作initrd ( by quqi99 )編譯Linux
- win10系統U盤製作方法_製作win10系統u盤步驟Win10
- 作業系統列表(轉)作業系統
- CS系統中分頁控制元件的製作控制元件
- win10系統隨身碟製作方法_製作win10系統u盤步驟Win10
- 微交易系統
- 微機系統
- 製作u盤linux根檔案系統掛不上!(轉)Linux
- 以太橙系統模式開發製作模式
- macOS製作系統啟動盤教程Mac
- 何謂深度定製作業系統?作業系統
- UNIX作業系統的歷史(轉)作業系統
- 學習NetBSD-pkgsrc(轉)
- U盤製作微pe工具箱(實戰)
- linux系統下音訊製作軟體不完全指南(轉)Linux音訊