1 |
David Shen <davidshen84@××××××××××.com> posted |
2 |
53e35fd50906261832h34fc472at65cada9042585194@××××××××××.com, excerpted |
3 |
below, on Sat, 27 Jun 2009 09:32:50 +0800: |
4 |
|
5 |
> ##################################################### chmod +x |
6 |
> /usr/src/initramfs/init |
7 |
> |
8 |
> then I use find /usr/src/initramfs/init | cipo -oHnewc | gzip -9 > |
9 |
> /boot/initramfs.gz |
10 |
> |
11 |
> But when I try to boot my system, I got kernel panic, and it says it |
12 |
> cannot find the init script. If I remove the 'initrd' instruction from |
13 |
> the grub.conf file, the error message does different, which means the |
14 |
> system WAS trying to process the initramfs. But I do not know why it |
15 |
> cannot find the init script. |
16 |
|
17 |
*MAJOR**DISCLAIMER:* I've never needed and thus never created and worked |
18 |
with my own initramfs/initrd, here. I run both kernel mdp/RAID and LVM2, |
19 |
but deliberately chose /not/ to put my / and rootbak partitions on LVM, |
20 |
and start the mdp/RAID / directly from the kernel using kernel |
21 |
commandline parameters, to avoid the complexity of a required initramfs/ |
22 |
initrd. Also, I don't have busybox on the system as I don't need it, and |
23 |
I had trouble building it initially, so I just skipped it and put an |
24 |
entry -*sys-apps/busybox in my /etc/portage/profile/packages file so it's |
25 |
no longer part of my profile's system packages. Thus, comments below are |
26 |
simply based on the documentation and general kernel and boot process |
27 |
knowledge. If the documentation's wrong, the comments are likely to be |
28 |
so as well, tho general experience and knowledge goes some way. That's |
29 |
why I had left it until now, preferring to let someone else that actually |
30 |
had initrd/initramfs experience answer. However, since there's been only |
31 |
one reply so far and it didn't solve the problem, maybe my admittedly |
32 |
not-entirely-informed comments below /will/ help... |
33 |
|
34 |
From the separate file part of the link you listed... |
35 |
http://en.gentoo-wiki.com/wiki/Initramfs#Creating_a_Separate_File |
36 |
|
37 |
cd /usr/src/initramfs |
38 |
find . -print0 | cpio -ov -0 --format=newc | / |
39 |
gzip -9 > /boot/my-initramfs.cpio.gz |
40 |
|
41 |
(Note that I used the \<newline> convention for wrapping. The find |
42 |
command continues on the second line, piping into gzip.) |
43 |
|
44 |
Your actual creation of the compressed initrd (initramfs indicates it's |
45 |
appended to the kernel itself, initrd is the older separate file method, |
46 |
which you are using here, so initrd it is) is rather different: |
47 |
|
48 |
find /usr/src/initramfs/init | cipo -oHnewc | gzip -9 > /boot/initramfs.gz |
49 |
|
50 |
Now, presuming the cpio commandline parameters are correct (I didn't |
51 |
doublecheck those), what we have here is that you are telling find to |
52 |
find JUST THAT ONE FILE and create an archive out of it. That one file |
53 |
is the script, by itself. The script is fine, but it won't run BY |
54 |
ITSELF. At the very minimum, it'll need the busybox executable that runs |
55 |
the script based on the shebang (shebang: #!<whatever> as the first line |
56 |
of a script, indicating the executable that should be run to execute the |
57 |
script). However, due to the contents of the script, you'll need the lvm |
58 |
executable, the various device files, etc, as well. |
59 |
|
60 |
Also noting that first shebang line in the script: |
61 |
|
62 |
#!/bin/busybox sh |
63 |
|
64 |
Noting your earlier copy: |
65 |
|
66 |
cp -aL /bin/bb /usr/src/initramfs/bin # copy the busybox |
67 |
|
68 |
So as-is, the kernel won't be able to find the necessary executable |
69 |
called by the shebang, busybox, since you've named it bb instead. You |
70 |
must either change the executable from bb to busybox, or change the |
71 |
shebang line to call bb, not busybox. |
72 |
|
73 |
So there's two things to change in your procedure. First, make sure the |
74 |
shebang line in the script actually corresponds to an executable you'll |
75 |
have in the initrd, in the initrd, changing either the bb executable to |
76 |
busybox, or changing the shebang line of the init script to bb instead of |
77 |
busybox. Second, compress the whole initramfs directory into the initrd, |
78 |
not just that single init shell script, by changing the find command |
79 |
portion of that compression command to see the entire directory contents, |
80 |
not just the single initscript. |
81 |
|
82 |
Whether it actually works then or not, I haven't actually examined the |
83 |
script well enough to be able to say, but if I'm correct, that should at |
84 |
least let the kernel find and start executing its init. (You may or may |
85 |
not need the init=/init kernel commandline bit Branko mentioned. I |
86 |
suspect you won't as I think the kernel checks both paths by default, but |
87 |
I haven't double-checked documentation to be sure, nor tried it myself, |
88 |
tho I /have/ used init=/bin/bash on occasion when the init system was |
89 |
screwed up, and know /that/ works, of course when there's a /bin/bash for |
90 |
it to execute. =:^) |
91 |
|
92 |
-- |
93 |
Duncan - List replies preferred. No HTML msgs. |
94 |
"Every nonfree program has a lord, a master -- |
95 |
and if you use the program, he is your master." Richard Stallman |