|
这种方法特点是/sbin/init一启动时就能拥有完整的设备节点(新类型和兼容性设备),并且有机会在安装 devfs 以前将 /dev 绑定安装到另一位置。
兼容性比较好
和gentoo的做法应该是差不多的
因为是 Gentoo 的boss Daniel Robbins 写的一些东西
我改了其中的一些配置 然后用一个script把他装在系统中
具体实现如下:
1.编译内核打开devfs 具体不在赘述
2.安装devfsd v1.3.25
下载
ftp://ftp.atnf.csiro.au/pub/peop ... vfsd-v1.3.25.tar.gz
-----------------------------------
tar -xzvf devfsd-v1.3.25.tar.gz
cd devfsd-v1.3.25
make
make install
------------------------------------
3.用root执行下面这段代码
---------------------------------------------------------------------
#!/bin/sh
# Script for config devfs
# mailto flaboy_cn@hotmail.com
echo
if [ -e /sbin/init.system ]
then
echo "can't run this script on your system"
echo "Quit.."
exit
else
cat > /tmp/init << "EOF"
#!/bin/bash
# Copyright 2001 Daniel Robbins <drobbins@gentoo.org>, Gentoo Technologies, Inc.
# Distributed under the GNU General Public License, version 2.0 or later.
trap ":" INT QUIT TSTP
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
umask 022
if [ $$ -ne 1 ]
then
exec /sbin/init.system $*
fi
mount -n /proc
devfs="yes"
for copt in `cat /proc/cmdline`
do
if [ "${copt%=*}" = "wrapper" ]
then
parms=${copt##*=}
#parse wrapper option
if [ "${parms/nodevfs//}" != "${parms}" ]
then
devfs="no"
fi
fi
done
if [ "$devfs" = "yes" ]
then
if [ -e /dev/.devfsd ]
then
clear
echo
echo "The init wrapper has detected that /dev has been automatically mounted by"
echo "the kernel. This will prevent devfs from automatically saving and"
echo "restoring device permissions. While not optimal, your system will still"
echo "be able to boot, but any perm/ownership changes or creation of new compat."
echo "device nodes will not be persistent across reboots until you fix this"
echo "problem."
echo
echo "Fortunately, the fix for this problem is quite simple; all you need to"
echo "do is pass the \"devfs=nomount\" boot option to the kernel (via GRUB"
echo "or LILO) the next time you boot. Then /dev will not be auto-mounted."
echo "The next time you compile your kernel, be sure that you do not"
echo "enable the \"Automatically mount filesystem at boot\" devfs kernel"
echo "configuration option. Then the \"devfs=nomount\" hack will no longer be"
echo "needed."
echo
read -t 15 -p "(hit Enter to continue or wait 15 seconds...)"
else
mount -n /dev /lib/dev-state -o bind
mount -n -t devfs none /dev
if [ -d /lib/dev-state/compat ]
then
echo Copying devices from /lib/dev-state/compat to /dev
cp -ax /lib/dev-state/compat/* /dev
fi
fi
/sbin/devfsd /dev > /dev/null 2>&1
fi
exec /sbin/init.system $*
EOF
cat > /tmp/devfsd.conf << "EOF"
#IBM dW sample devfsd.conf
REGISTER .* MKOLDCOMPAT
UNREGISTER .* RMOLDCOMPAT
REGISTER .* MKNEWCOMPAT
UNREGISTER .* RMNEWCOMPAT
LOOKUP .* MODLOAD
REGISTER ^pt[sy]/.* IGNORE
CHANGE ^pt[sy]/.* IGNORE
REGISTER .* COPY /lib/dev-state/$devname $devpath
CHANGE .* COPY $devpath /lib/dev-state/$devname
CREATE .* COPY $devpath /lib/dev-state/$devname
REGISTER ^cdrom/cdrom0$ CFUNCTION GLOBAL symlink cdroms/cdrom0 cdrom
UNREGISTER ^cdrom/cdrom0$ CFUNCTION GLOBAL unlink cdrom
REGISTER ^misc/psaux$ CFUNCTION GLOBAL symlink misc/psaux mouse
UNREGISTER ^misc/psaux$ CFUNCTION GLOBAL unlink mouse
EOF
mkdir /lib/dev-state
mv /sbin/init /sbin/init.system
echo " || Rename /sbin/init to /sbin/init.system"
mv /tmp/init /sbin/init
chmod +x /sbin/init
echo " || Creat NEW /sbin/init"
mv /tmp/devfsd.conf /etc/devfsd.conf
echo " || Creat /etc/devfsd.conf"
rm /etc/rc.d/rcsysinit.d/S20mountproc
echo " Alldone!"
fi
echo " wilcome 2 join us! DIY your System!"
echo
---------------------------------------------------------------------
|
|