On Thu, Dec 27, 2012 at 3:24 PM, Mark Knecht <markkne...@gmail.com> wrote:
> On Thu, Dec 27, 2012 at 9:33 AM, Mark Knecht <markkne...@gmail.com> wrote:
>> On Wed, Dec 26, 2012 at 3:50 PM, Mark Knecht <markkne...@gmail.com> wrote:
>>> On Wed, Dec 26, 2012 at 3:03 PM, Neil Bothwick <n...@digimed.co.uk> wrote:
>>>> On Wed, 26 Dec 2012 14:09:34 -0800, Mark Knecht wrote:
>>>>
>>>>> At this point I don't know that 1) the image is actually in the
>>>>> kernel, or 2) that my "init thingy" ;-) image would work, but at least
>>>>> the process of putting it together is verifiable.
>>>>
>>>> That's why I put in all the debug stuff, so I could watch the progress of
>>>> the script as it ran.
>>>>
>>>
>>>
>>> OK, I'll look at combining that part my my scripts, or just using yours, 
>>> etc.
>>>
>>> Thanks for the help,
>>> Mark
>>
>> Neil,
>>    One more question if I might. What's the simplest way to regenerate
>> the kernel when there are no kernel changes but you have changes to
>> the programs that are going into the initramfs? make clean seems like
>> overkill to me, and it's very slow to boot.
>>
> <SNIP>
>
> Answering self: The Gentoo wiki covered this at the end:
>
> http://en.gentoo-wiki.com/wiki/Initramfs
>
> I tried it and it seemed to work, although I've not yet successfully
> booted this kernel so there may well be some issues left to deal with.
>
> Cheers

OK, this is all finished up and working now. I'll have to give it some
time to make sure nothing weird pops up but it was a good learning
experience for me.

The two biggest problems I had along way:

1) I used an older init script that I had put together a year back
with I played with this for an afternoon. I had trouble back then with
/dev so I copied over pretty much everything into my initramfs. (As
per the Gentoo initramfs wiki) This time around, using that script, I
still had troubles until I discovered the

mount -t devtmpfs none /dev

command in Neil's script. That allowed me to move forward.

2) Turns out the config format for copying files is target/source, not
source/target like most copies. This resulted in my mdadm.conf file
going into the wrong directory.

Once I figured those two out the machine booted cleanly.

I'm going to continue working on this. I'd like to do a better init
script, maybe add some more stuff to play with. That said I'll attach
in-line the stuff I ended up with for anyone else who comes across
this thread in the future.

Cheers,
Mark


c2stable src # ls -la
total 28
drwxr-xr-x  4 root root 4096 Dec 28 15:04 .
drwxr-xr-x 14 root root 4096 Dec 25  2011 ..
-rw-r--r--  1 root root    0 Dec 29  2010 .keep
-rw-r--r--  1 root root  574 Dec 28 11:45 initramfs.config
-rw-r--r--  1 root root  562 Dec 28 10:44 initramfs_init_new.sh
lrwxrwxrwx  1 root root   19 Dec 27 07:49 linux -> linux-3.6.11-gentoo
drwxr-xr-x 24 root root 4096 Dec 28 09:49 linux-3.2.1-gentoo-r2
drwxr-xr-x 24 root root 4096 Dec 28 11:46 linux-3.6.11-gentoo
-rw-r--r--  1 root root   70 Dec 28 06:58 mdadm_initramfs.conf





c2stable src # cat initramfs.config
dir /bin 755 0 0
file /bin/busybox /bin/busybox 755 0 0
slink /bin/sh busybox 777 0 0

dir /realroot 755 0 0
dir /etc 755 0 0
dir /proc 755 0 0
dir /sys 755 0 0

dir /sbin 755 0 0
file /sbin/mdadm /sbin/mdadm 755 0 0

file /sbin/e2fsck /sbin/e2fsck 755 0 0
dir /lib 755 0 0
file /lib/libext2fs.so /usr/lib64/libext2fs.so 755 0 0
file /etc/mdadm.conf /usr/src/mdadm_initramfs.conf 755 0 0

dir /dev 755 0 0
nod /dev/console 600 0 0 c 5 1
nod /dev/null 666 0 0 c 1 3
nod /dev/tty 666 0 0 c 5 0
nod /dev/urandom 666 0 0 c 1 9

file /init /usr/src/initramfs_init_new.sh 755 0 0





c2stable src # cat initramfs_init_new.sh
#!/bin/busybox sh

rescue_shell() {
    echo "Something went wrong. Dropping you to a shell."
    busybox --install -s
    exec /bin/sh
}

# Mount the /proc and /sys filesystems.
mount -t proc none /proc
mount -t sysfs none /sys
mount -t devtmpfs none /dev

# Do your stuff here.
echo "This script mounts rootfs and boots it up, nothing more!"

mdadm --assemble /dev/md3

# Mount the root filesystem.
mount -o ro /dev/md3 /realroot  || rescue_shell

# Clean up.
umount /dev
umount /proc
umount /sys

# Boot the real thing.
exec switch_root /realroot /sbin/init






c2stable src # cat mdadm_initramfs.conf
ARRAY /dev/md/3 metadata=1.2 UUID=de47f991:86d98467:0637635b:9c6d0591
c2stable src #

Reply via email to