initramfs的init示例 - digwtx's Blog
initramfs的init示例
digwtx
posted @ 2009年7月22日 04:07
in 未分类
, 2081 阅读
#!/bin/sh
echo "Loading, please wait..."
export PATH="/bin:/sbin"
[ -d /dev ] || mkdir -m 0755 /dev
[ -d /root ] || mkdir --mode=0700 /root
[ -d /sys ] || mkdir /sys
[ -d /proc ] || mkdir /proc
[ -d /tmp ] || mkdir /tmp
# Mount /proc and /sys:
mount -n proc /proc -t proc
mount -n sysfs /sys -t sysfs
/sbin/udevd --daemon
/sbin/udevadm trigger
/sbin/udevadm settle
#下面的这串解析内核命令行参数的代码是从Ubuntu的initrd抄过来的
for x in $(cat /proc/cmdline); do
case $x in
init=*)
init=${x#init=}
;;
root=*)
ROOT=${x#root=}
case $ROOT in
LABEL=*)
ROOT="/dev/disk/by-label/${ROOT#LABEL=}"
;;
UUID=*)
ROOT="/dev/disk/by-uuid/${ROOT#UUID=}"
;;
/dev/nfs)
BOOT=nfs
;;
esac
;;
rootflags=*)
ROOTFLAGS="-o ${x#rootflags=}"
;;
rootfstype=*)
ROOTFSTYPE="${x#rootfstype=}"
;;
rootdelay=*)
ROOTDELAY="${x#rootdelay=}"
;;
resumedelay=*)
RESUMEDELAY="${x#resumedelay=}"
;;
loop=*)
LOOP="${x#loop=}"
;;
loopflags=*)
LOOPFLAGS="-o ${x#loopflags=}"
;;
loopfstype=*)
LOOPFSTYPE="${x#loopfstype=}"
;;
cryptopts=*)
cryptopts="${x#cryptopts=}"
;;
nfsroot=*)
NFSROOT="${x#nfsroot=}"
;;
netboot=*)
NETBOOT="${x#netboot=}"
;;
ip=*)
IPOPTS="${x#ip=}"
;;
boot=*)
BOOT=${x#boot=}
;;
resume=*)
RESUME="${x#resume=}"
;;
noresume)
NORESUME=y
;;
panic=*)
panic="${x#panic=}"
;;
quiet)
quiet=y
;;
ro)
readonly=y
;;
rw)
readonly=n
;;
debug)
debug=y
exec >/tmp/initramfs.debug 2>&1
set -x
;;
debug=*)
debug=y
set -x
;;
break=*)
break=${x#break=}
;;
break)
break=premount
;;
0|1|2|3|4|5|6)
RUNLEVEL=$x
;;
esac
done
for ((t=0;t<32;i++)) ;
do
echo "Mounting the ROOT DEVICE..."
mount -o ro $ROOT /mnt
mountpoint -q /mnt && break
sleep 4
done
killall udevd
umount /proc
umount /sys
exec switch_root /mnt /sbin/init $RUNLEVEL
/bin/sh
echo "Loading, please wait..."
export PATH="/bin:/sbin"
[ -d /dev ] || mkdir -m 0755 /dev
[ -d /root ] || mkdir --mode=0700 /root
[ -d /sys ] || mkdir /sys
[ -d /proc ] || mkdir /proc
[ -d /tmp ] || mkdir /tmp
# Mount /proc and /sys:
mount -n proc /proc -t proc
mount -n sysfs /sys -t sysfs
/sbin/udevd --daemon
/sbin/udevadm trigger
/sbin/udevadm settle
#下面的这串解析内核命令行参数的代码是从Ubuntu的initrd抄过来的
for x in $(cat /proc/cmdline); do
case $x in
init=*)
init=${x#init=}
;;
root=*)
ROOT=${x#root=}
case $ROOT in
LABEL=*)
ROOT="/dev/disk/by-label/${ROOT#LABEL=}"
;;
UUID=*)
ROOT="/dev/disk/by-uuid/${ROOT#UUID=}"
;;
/dev/nfs)
BOOT=nfs
;;
esac
;;
rootflags=*)
ROOTFLAGS="-o ${x#rootflags=}"
;;
rootfstype=*)
ROOTFSTYPE="${x#rootfstype=}"
;;
rootdelay=*)
ROOTDELAY="${x#rootdelay=}"
;;
resumedelay=*)
RESUMEDELAY="${x#resumedelay=}"
;;
loop=*)
LOOP="${x#loop=}"
;;
loopflags=*)
LOOPFLAGS="-o ${x#loopflags=}"
;;
loopfstype=*)
LOOPFSTYPE="${x#loopfstype=}"
;;
cryptopts=*)
cryptopts="${x#cryptopts=}"
;;
nfsroot=*)
NFSROOT="${x#nfsroot=}"
;;
netboot=*)
NETBOOT="${x#netboot=}"
;;
ip=*)
IPOPTS="${x#ip=}"
;;
boot=*)
BOOT=${x#boot=}
;;
resume=*)
RESUME="${x#resume=}"
;;
noresume)
NORESUME=y
;;
panic=*)
panic="${x#panic=}"
;;
quiet)
quiet=y
;;
ro)
readonly=y
;;
rw)
readonly=n
;;
debug)
debug=y
exec >/tmp/initramfs.debug 2>&1
set -x
;;
debug=*)
debug=y
set -x
;;
break=*)
break=${x#break=}
;;
break)
break=premount
;;
0|1|2|3|4|5|6)
RUNLEVEL=$x
;;
esac
done
for ((t=0;t<32;i++)) ;
do
echo "Mounting the ROOT DEVICE..."
mount -o ro $ROOT /mnt
mountpoint -q /mnt && break
sleep 4
done
killall udevd
umount /proc
umount /sys
exec switch_root /mnt /sbin/init $RUNLEVEL
/bin/sh
2019年2月18日 15:52
All the poses of the program and instruction are very well defined for the individuals. Yes, the visits of the www.assignmentgeek.com.au are shard and punctuated for the people. The exact use is defined for the mutual stance for the people in this ambit.
2019年6月06日 13:45
In this I want to tell you how to remove password in window 10. Click the link if you forget your password in window 10.