From: Mark Knecht <markknecht@gmail.com>
To: Gentoo User <gentoo-user@lists.gentoo.org>
Subject: Re: [gentoo-user] Building an initramfs into the kernel
Date: Fri, 28 Dec 2012 15:07:03 -0800 [thread overview]
Message-ID: <CAK2H+eftWQJKSZ=RLErAGRM6YBRm-hekKCdOtKyWWfOjusg6=A@mail.gmail.com> (raw)
In-Reply-To: <CAK2H+edMp+US8N3BX2fedX9qbW=1jbcruyz5QM4-hQqNQokJJA@mail.gmail.com>
On Thu, Dec 27, 2012 at 3:24 PM, Mark Knecht <markknecht@gmail.com> wrote:
> On Thu, Dec 27, 2012 at 9:33 AM, Mark Knecht <markknecht@gmail.com> wrote:
>> On Wed, Dec 26, 2012 at 3:50 PM, Mark Knecht <markknecht@gmail.com> wrote:
>>> On Wed, Dec 26, 2012 at 3:03 PM, Neil Bothwick <neil@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 #
next prev parent reply other threads:[~2012-12-28 23:08 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-26 15:58 [gentoo-user] Building an initramfs into the kernel Mark Knecht
2012-12-26 17:09 ` Neil Bothwick
2012-12-26 20:48 ` Mark Knecht
2012-12-26 21:49 ` Mark Knecht
2012-12-26 22:09 ` Mark Knecht
2012-12-26 23:03 ` Neil Bothwick
2012-12-26 23:50 ` Mark Knecht
2012-12-27 17:33 ` Mark Knecht
2012-12-27 23:24 ` Mark Knecht
2012-12-28 23:07 ` Mark Knecht [this message]
2012-12-29 0:41 ` Neil Bothwick
2012-12-26 23:02 ` Neil Bothwick
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAK2H+eftWQJKSZ=RLErAGRM6YBRm-hekKCdOtKyWWfOjusg6=A@mail.gmail.com' \
--to=markknecht@gmail.com \
--cc=gentoo-user@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox