initramfs的init示例 - digwtx's Blog

initramfs的init示例

digwtx posted @ 2009年7月22日 04:07 in 未分类 , 2286 阅读

 

#!/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

 

 

Avatar_small
Christian Behan 说:
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.

Avatar_small
remove password in w 说:
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.

Avatar_small
penn foster login 说:
2022年8月25日 23:17

Penn Foster offers practical, affordable programs for high school, college, and career school. Your education is here. penn foster student login Learn about our programs today. If you are a current Penn Foster student and would like to access your course materials and take exams, click here to login. Penn Foster Student Login. It is so easy to find your way around the PennFoster website.

Avatar_small
Jon Webb 说:
2022年9月11日 13:20

Each language learner will surely employ a unique system for memorizing word forms, retaining their meanings, and recalling how to use words. Depending on the context, each word will have a specific appropriate interpretation. Simple support techniques that can be used on internet-connected gadgets are being developed as technology advances. To make it simpler to meet the diverse needs of each user, the company's founder develops a variety of support solutions. Therefore, this is the reason <a href="https://wordsfromletters.co/">words from letters</a> exists.

Avatar_small
backrooms game 说:
2022年9月12日 15:25

I'll explain how to do it in this article for Windows 10. If you lose your Windows 10 password, click the link.

Avatar_small
gumore 说:
2022年9月12日 15:27

It is so easy to find your way around the PennFoster website. [URL=https://backroomsgame.io]backrooms game[/URL]

Avatar_small
gumore 说:
2022年9月12日 15:27

nice! [backrooms game](https://backroomsgame.io)

Avatar_small
volleysearch 说:
2022年9月27日 17:25

The island's scenic highlands and quiet villages give way to lively resort cities along its rocky coast, providing a wide variety of [url=https://driving-directions.co]driving directions[/url] experiences for visitors. Whether you come to the island to relax in the sun, see its stunning scenery, or experience the cuisine and culture, you will come away with unforgettable memories.

Avatar_small
five nights at fredd 说:
2022年10月05日 15:03

In this tutorial, I'll show you how to set up a VPN on Windows 10. Use this page if you've forgotten your Windows 10 password.

Avatar_small
bubble shooter 说:
2022年11月18日 11:06

thanks, i was looking for this code

Avatar_small
moto x3m 说:
2022年12月29日 16:40

If all bloggers wrote like you, the internet would be a better place.

Avatar_small
spacebar clicker 说:
2023年3月15日 15:01

y business is very happy we found this during my search for some thing concerning this

Avatar_small
tunnel rush 说:
2023年4月04日 09:59

This is often seen with live distributions of Linux that run entirely on memory. A live distribution of Linux unmounts the disc and then loads it into memory, so trying out a new OS or repairing another doesn't hurt the installed system.

Avatar_small
wunschtaria 说:
2023年6月21日 17:48

Here, I will explain how to delete a Windows 10 password. If you have Windows 10 and have forgotten your password, click here. <a href="https://basketball-stars.co/">basketball stars</a>

Avatar_small
free games 说:
2023年7月12日 17:01

This is common in memory-only Linux distributions, known as "live" versions. In order to avoid damaging the existing operating system, a live distribution of Linux first unmounts the disc and then loads it into memory.

Avatar_small
drift hunters 说:
2023年7月26日 17:28

Fans of racing video games shouldn't miss this

Avatar_small
cookie clicker 说:
2023年11月08日 23:09

It was a really helpful and very informative blog. It really helps me a lot but if you want to also learn something new and interesting.

Avatar_small
geometry dash 说:
2024年4月11日 11:05

You’ve done such an amazing job. I really love your article.

Avatar_small
fireboy and watergir 说:
2024年4月25日 17:12

What is the next part to write about?

Avatar_small
1000 kwh battery 说:
2024年7月04日 19:37

Cool you make, the data is truly salubrious further surprising, I'll give you an alliance point with my scene. youibot autonomous mobile robots amr amr robot


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter
Host by is-Programmer.com | Power by Chito 1.3.3 beta | © 2007 LinuxGem | Design by Matthew "Agent Spork" McGee