1 |
On Thu, Dec 27, 2012 at 3:24 PM, Mark Knecht <markknecht@×××××.com> wrote: |
2 |
> On Thu, Dec 27, 2012 at 9:33 AM, Mark Knecht <markknecht@×××××.com> wrote: |
3 |
>> On Wed, Dec 26, 2012 at 3:50 PM, Mark Knecht <markknecht@×××××.com> wrote: |
4 |
>>> On Wed, Dec 26, 2012 at 3:03 PM, Neil Bothwick <neil@××××××××××.uk> wrote: |
5 |
>>>> On Wed, 26 Dec 2012 14:09:34 -0800, Mark Knecht wrote: |
6 |
>>>> |
7 |
>>>>> At this point I don't know that 1) the image is actually in the |
8 |
>>>>> kernel, or 2) that my "init thingy" ;-) image would work, but at least |
9 |
>>>>> the process of putting it together is verifiable. |
10 |
>>>> |
11 |
>>>> That's why I put in all the debug stuff, so I could watch the progress of |
12 |
>>>> the script as it ran. |
13 |
>>>> |
14 |
>>> |
15 |
>>> |
16 |
>>> OK, I'll look at combining that part my my scripts, or just using yours, etc. |
17 |
>>> |
18 |
>>> Thanks for the help, |
19 |
>>> Mark |
20 |
>> |
21 |
>> Neil, |
22 |
>> One more question if I might. What's the simplest way to regenerate |
23 |
>> the kernel when there are no kernel changes but you have changes to |
24 |
>> the programs that are going into the initramfs? make clean seems like |
25 |
>> overkill to me, and it's very slow to boot. |
26 |
>> |
27 |
> <SNIP> |
28 |
> |
29 |
> Answering self: The Gentoo wiki covered this at the end: |
30 |
> |
31 |
> http://en.gentoo-wiki.com/wiki/Initramfs |
32 |
> |
33 |
> I tried it and it seemed to work, although I've not yet successfully |
34 |
> booted this kernel so there may well be some issues left to deal with. |
35 |
> |
36 |
> Cheers |
37 |
|
38 |
OK, this is all finished up and working now. I'll have to give it some |
39 |
time to make sure nothing weird pops up but it was a good learning |
40 |
experience for me. |
41 |
|
42 |
The two biggest problems I had along way: |
43 |
|
44 |
1) I used an older init script that I had put together a year back |
45 |
with I played with this for an afternoon. I had trouble back then with |
46 |
/dev so I copied over pretty much everything into my initramfs. (As |
47 |
per the Gentoo initramfs wiki) This time around, using that script, I |
48 |
still had troubles until I discovered the |
49 |
|
50 |
mount -t devtmpfs none /dev |
51 |
|
52 |
command in Neil's script. That allowed me to move forward. |
53 |
|
54 |
2) Turns out the config format for copying files is target/source, not |
55 |
source/target like most copies. This resulted in my mdadm.conf file |
56 |
going into the wrong directory. |
57 |
|
58 |
Once I figured those two out the machine booted cleanly. |
59 |
|
60 |
I'm going to continue working on this. I'd like to do a better init |
61 |
script, maybe add some more stuff to play with. That said I'll attach |
62 |
in-line the stuff I ended up with for anyone else who comes across |
63 |
this thread in the future. |
64 |
|
65 |
Cheers, |
66 |
Mark |
67 |
|
68 |
|
69 |
c2stable src # ls -la |
70 |
total 28 |
71 |
drwxr-xr-x 4 root root 4096 Dec 28 15:04 . |
72 |
drwxr-xr-x 14 root root 4096 Dec 25 2011 .. |
73 |
-rw-r--r-- 1 root root 0 Dec 29 2010 .keep |
74 |
-rw-r--r-- 1 root root 574 Dec 28 11:45 initramfs.config |
75 |
-rw-r--r-- 1 root root 562 Dec 28 10:44 initramfs_init_new.sh |
76 |
lrwxrwxrwx 1 root root 19 Dec 27 07:49 linux -> linux-3.6.11-gentoo |
77 |
drwxr-xr-x 24 root root 4096 Dec 28 09:49 linux-3.2.1-gentoo-r2 |
78 |
drwxr-xr-x 24 root root 4096 Dec 28 11:46 linux-3.6.11-gentoo |
79 |
-rw-r--r-- 1 root root 70 Dec 28 06:58 mdadm_initramfs.conf |
80 |
|
81 |
|
82 |
|
83 |
|
84 |
|
85 |
c2stable src # cat initramfs.config |
86 |
dir /bin 755 0 0 |
87 |
file /bin/busybox /bin/busybox 755 0 0 |
88 |
slink /bin/sh busybox 777 0 0 |
89 |
|
90 |
dir /realroot 755 0 0 |
91 |
dir /etc 755 0 0 |
92 |
dir /proc 755 0 0 |
93 |
dir /sys 755 0 0 |
94 |
|
95 |
dir /sbin 755 0 0 |
96 |
file /sbin/mdadm /sbin/mdadm 755 0 0 |
97 |
|
98 |
file /sbin/e2fsck /sbin/e2fsck 755 0 0 |
99 |
dir /lib 755 0 0 |
100 |
file /lib/libext2fs.so /usr/lib64/libext2fs.so 755 0 0 |
101 |
file /etc/mdadm.conf /usr/src/mdadm_initramfs.conf 755 0 0 |
102 |
|
103 |
dir /dev 755 0 0 |
104 |
nod /dev/console 600 0 0 c 5 1 |
105 |
nod /dev/null 666 0 0 c 1 3 |
106 |
nod /dev/tty 666 0 0 c 5 0 |
107 |
nod /dev/urandom 666 0 0 c 1 9 |
108 |
|
109 |
file /init /usr/src/initramfs_init_new.sh 755 0 0 |
110 |
|
111 |
|
112 |
|
113 |
|
114 |
|
115 |
c2stable src # cat initramfs_init_new.sh |
116 |
#!/bin/busybox sh |
117 |
|
118 |
rescue_shell() { |
119 |
echo "Something went wrong. Dropping you to a shell." |
120 |
busybox --install -s |
121 |
exec /bin/sh |
122 |
} |
123 |
|
124 |
# Mount the /proc and /sys filesystems. |
125 |
mount -t proc none /proc |
126 |
mount -t sysfs none /sys |
127 |
mount -t devtmpfs none /dev |
128 |
|
129 |
# Do your stuff here. |
130 |
echo "This script mounts rootfs and boots it up, nothing more!" |
131 |
|
132 |
mdadm --assemble /dev/md3 |
133 |
|
134 |
# Mount the root filesystem. |
135 |
mount -o ro /dev/md3 /realroot || rescue_shell |
136 |
|
137 |
# Clean up. |
138 |
umount /dev |
139 |
umount /proc |
140 |
umount /sys |
141 |
|
142 |
# Boot the real thing. |
143 |
exec switch_root /realroot /sbin/init |
144 |
|
145 |
|
146 |
|
147 |
|
148 |
|
149 |
|
150 |
c2stable src # cat mdadm_initramfs.conf |
151 |
ARRAY /dev/md/3 metadata=1.2 UUID=de47f991:86d98467:0637635b:9c6d0591 |
152 |
c2stable src # |