|
楼主 |
发表于 2007-8-16 10:55:00
|
显示全部楼层
我觉得视乎改变的不多,
initrd启动后,仍然是启动真正的根系统上的init,加载inittab,根据他进行进一步的动作。
改变的只有initrd本身。
一个arch initrd的样子
========================
----------------archlinux initrd.img 的目录树---------------------------------
|-- bin
| |-- cat
| |-- chroot
| |-- cpio
| |-- dd
| |-- false
| |-- fstype
| |-- gunzip
| |-- gzip
| |-- halt
| |-- insmod
| |-- ipconfig
| |-- kill
| |-- kinit
| |-- kinit.shared
| |-- ln
| |-- losetup
| |-- mdassemble
| |-- minips
| |-- mkdir
| |-- mkfifo
| |-- mknod
| |-- moddeps
| |-- modprobe -> /sbin/modprobe
| |-- mount
| |-- nfsmount
| |-- nuke
| |-- parseblock
| |-- pivot_root
| |-- poweroff
| |-- readlink
| |-- reboot
| |-- replace
| |-- resume
| |-- run-init
| |-- sh
| |-- sleep
| |-- true
| |-- umount
| |-- uname
| `-- zcat
|-- config
|-- dev
|-- etc
| |-- start_udev
| `-- udev
| |-- rules.d
| | `-- udev.rules
| `-- udev.conf
|-- hooks
| |-- filesystems
| `-- udev
|-- init
|-- kernel26
|-- lib
| |-- klibc-rOj3PRLKBA9FcF5ZuoqKQLmOWcA.so
| |-- modules
| | `-- 2.6.22-ARCH
| | |-- kernel
| | | |-- drivers
| | | | |-- cdrom
| | | | | `-- cdrom.ko
| | | | `-- ide
| | | | |-- ide-cd.ko
| | | | |-- ide-core.ko
| | | | |-- ide-disk.ko
| | | | `-- pci
| | | | |-- generic.ko
| | | | `-- via82cxxx.ko
| | | `-- fs
| | | |-- ext3
| | | | `-- ext3.ko
| | | |-- jbd
| | | | `-- jbd.ko
| | | `-- mbcache.ko
| | |-- modules.alias
| | |-- modules.dep
| | `-- modules.symbols
| `-- udev
| |-- ata_id
| |-- cdrom_id
| |-- edd_id
| |-- firmware.sh
| |-- load-modules.sh
| |-- scsi_id
| |-- usb_id
| `-- vol_id
|-- proc
|-- sbin
| |-- modprobe
| |-- udevd
| |-- udevsettle
| `-- udevtrigger
`-- sys
21 directories, 74 files
-------------------------init @ initrd.img -----------------------------------------------------
#!/bin/sh
msg () { [ "${quiet}" != "y" ] && echo $@; }
err () { echo "ERROR: $@"; }
msg ":: Loading Initramfs"
/bin/mount -t sysfs none /sys
/bin/mount -t proc none /proc
read CMDLINE </proc/cmdline
export CMDLINE
# Used so hooks can override params to kinit
export kinit_params=""
export root=""
echo "/sbin/modprobe" > /proc/sys/kernel/modprobe
for cmd in $CMDLINE; do
case "$cmd" in
\#*) break ;; # ignore everything after a # in the commandline
[0123456Ss]) export runlevel="$cmd" ;;
single) export runlevel="S" ;; #some people use 'single'
# replace can cause problems for the following entries
# These should only be applied to the lefthand side of the expression
# until we find a fix hardcode the stuff here.
root=*) export "${cmd}";;
md=*) export "${cmd}" ;;
crypto=*) export "${cmd}" ;;
resume2=*) export "${cmd}" ;;
ip=*) export "${cmd}" ;;
nfsaddrs=*) export "${cmd}" ;;
nfsroot=*) export "${cmd}" ;;
# only export stuff that does work with dash
*=*) cmd="$(replace "${cmd}" '.' '_')"
cmd="$(replace "${cmd}" '-' '_')"
export "${cmd}"
;;
*) cmd="$(replace "${cmd}" '.' '_')"
cmd="$(replace "${cmd}" '-' '_')"
export "${cmd}=y"
;;
esac
done
if [ "x${disablehooks}" != "x" ]; then
for d in $(replace "${disablehooks}" ','); do
export "hook_${d}=disabled"
done
fi
if [ "x${disablemodules}" != "x" ]; then
for d in $(replace "${disablemodules}" ','); do
export "mod_${d}=disabled"
done
fi
if [ "x${earlymodules}" != "x" ]; then
for m in $(replace "${earlymodules}" ','); do
/sbin/modprobe -q $m > /dev/null 2>&1
done
fi
. /config
for m in $MODULES; do
TST=""
eval "TST=\$mod_${m}"
if [ "${TST}" != "disabled" ]; then
/sbin/modprobe -q $m > /dev/null 2>&1
fi
done
if [ -e "/hooks" ]; then
for h in $HOOKS; do
TST=""
eval "TST=\$hook_${h}"
if [ "${TST}" != "disabled" ]; then
run_hook () { msg "$h: no run function defined"; }
if [ -e "/hooks/$h" ]; then
. /hooks/$h
msg ":: Running Hook [${h}]"
run_hook
fi
fi
done
fi
if [ "${rootdelay}" != "0" ]; then
msg -n "Waiting for devices to settle..."
/bin/sleep "${rootdelay}"
export rootdelay=0
export kinit_params="$kinit_params rootdelay=0"
msg "done."
fi
if [ "${break}" = "y" ]; then
echo ":: Break requested, type 'exit' to resume operation"
echo " NOTE: klibc contains no 'ls' binary, use 'echo *' instead"
PS1="ramfs$ " /bin/sh -i
fi
if [ ! -b "${root}" ]; then
# This duplicates code from the filesystem hook
# without this, mkinitcpio would fail for users who use
# neither the udev hook, nor the filesystem hook
msg "\nRoot device '${root}' doesn't exist, attempting to create it"
eval $(/bin/parseblock "${root}")
if [ "${BLOCKNAME}" = "unknown" ]; then
echo "ERROR: Failed to parse block device name for '${root}'"
elif [ "x${BLOCKDEVICE}" = "x" ]; then
echo "ERROR: Failed to parse block device ids for '${root}'"
else
export root="${BLOCKNAME}"
echo "/bin/mknod \"${BLOCKNAME}\" b ${BLOCKDEVICE}"
/bin/mknod "${BLOCKNAME}" b ${BLOCKDEVICE} >/dev/null
fi
if [ ! -b "${root}" ]; then
err "Unable to create/detect root device '${root}'"
echo "Dropping to a recovery shell... type 'exit' to reboot"
echo "NOTE: klibc contains no 'ls' binary, use 'echo *' instead"
echo ""
echo "If the device '${root}' gets created while you are here,"
echo "try adding 'rootdelay=8' or higher to the kernel command-line"
PS1="ramfs$ " /bin/sh -i
msg "Rebooting..."
/bin/reboot
fi
fi
msg ":: Initramfs Completed - control passing to kinit"
if [ -f "/message" ]; then
msg "$(cat /message)"
fi
#Special handling if udev is running
udevpid=$(/bin/minips -C udevd -o pid=)
if [ "x${udevpid}" != "x" ]; then
/bin/kill -9 $udevpid
/bin/sleep 0.01
fi
exec /bin/kinit -- "root=${root}" ${kinit_params} "${runlevel}" > /dev/null 2>&1
============================================================
而且我将生成的arch 的 initrd.img用到mgc上是没问题的。
因此生成的initrd.img应该是没问题的。
只是改生成initrd的工具而已
以上是我不太成熟的看法。
替换后对硬件的支持应该能够变好。
[ 本帖最后由 lanzinc 于 2007-8-16 11:36 编辑 ] |
|