public inbox for gentoo-user@lists.gentoo.org
 help / color / mirror / Atom feed
From: Mark Knecht <markknecht@gmail.com>
To: gentoo-user@lists.gentoo.org
Subject: Re: [gentoo-user] Making a init thingy. Step two I guess.
Date: Sat, 17 Sep 2011 15:48:22 -0700	[thread overview]
Message-ID: <CAK2H+eex7g=1BK5mTAuy_9PhLWh-xDGyeJTujb_X6Yr3w6V4jg@mail.gmail.com> (raw)
In-Reply-To: <4E751EDB.4070303@gmail.com>

On Sat, Sep 17, 2011 at 3:27 PM, Dale <rdalek1967@gmail.com> wrote:
> Mark Knecht wrote:
>>
>> While I was out walking my dog I sort of remembered that there are
>> just a few apps I had to build static, or at least that I build
>> static. One, I think was grub. The first and only time I did it I had
>> to do it 3 or 4 times before I got everything I needed working
>> correctly. This page which is like the first one Google comes up with
>> talks about that stuff, although you have to sort of dig it out and
>> read between the lines.
>>
>> http://en.gentoo-wiki.com/wiki/Initramfs
>>
>> And, I think with the ldd command as long as you include the libraries
>> ldd points at in your equivalent /lib directory within the initramfs
>> then that works for most apps and keeps the initramfs smaller.
>>
>> HTH,
>> Mark
>>
>>
>
> I think there are only a few that has that flag, at least that I would put
> in the init thingy anyway.  Maybe this is something that the devs will work
> on if it can be done.  May be a big if there.
>
> That is the guide I am trying to go by but I think I am missing something.
>  This is the script they have posted:
>
> #!/bin/busybox sh
>
> # Mount the /proc and /sys filesystems.
> mount -t proc none /proc
> mount -t sysfs none /sys
>
> # Do your stuff here.
> echo "This script mounts rootfs and boots it up, nothing more!"
>
> # Mount the root filesystem.
> mount -o ro /dev/sda1 /mnt/root
>
> # Clean up.
> umount /proc
> umount /sys
>
> # Boot the real thing.
> exec switch_root /mnt/root /sbin/init
>
> That doesn't really make much sense to me.  First it mounts the stuff then
> umounts it right after that.  Huh?  Is the relevant part the "mount -o ro
> /dev/sda1 /mnt/root" ?  Then the exec switch_root part after that?  The rest
> seems to cancel each other out.
>
> Looking forward to that light bulb moment here.  ;-)
>
> Dale

Yup, that's what it does... ;-)

As you know, I'm a user type, not a sys admin or anything like that,
so I have no real training in how the Linux initialization process
really works. It's my uninformed opinion that the kernel in the early
stages needs /proc and /sys to basically run. I don't know what it
does with them but they need to be mounted so that the kernel can see
them. Remember, this isn't necessarily the same as what we see within
those directories once we really boot, it's just something for the
kernel to use for a while. The kernel does what it needs to do, then
unmounts them and lets things proceed.

If it helps here's an init file from the one I did to figure my mdadm
RAID boot problems here:

c2stable / # cat /usr/src/initramfs/init
#!/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

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

mdadm --assemble --name=c2stable:3 /dev/md3

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

# Clean up.
umount /proc
umount /sys

# Boot the real thing.
exec switch_root /mnt/root /sbin/init
c2stable / #

If I remember correctly I couldn't figure out what the right dev
number was at the time, so I built the initramfs without the mdadm
command, then used mdadm commands within the initramfs process using
the busybox shell. When I figured it out I used the updated init file
to prove it worked.

That could all be wrong - it was over a year ago - but that's what I
remember. Adding the busybox part at the top - the rescue shell part -
was REALLY useful.

HTH,
Mark



  parent reply	other threads:[~2011-09-17 22:49 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-17 20:02 [gentoo-user] Making a init thingy. Step two I guess Dale
2011-09-17 20:27 ` Mark Knecht
2011-09-17 20:44   ` Dale
2011-09-17 20:51     ` Michael Mol
2011-09-17 20:56       ` Mark Knecht
2011-09-17 21:17         ` Dale
2011-09-17 21:32           ` Mark Knecht
2011-09-17 22:27             ` Dale
2011-09-17 22:45               ` Michael Mol
2011-09-18  2:13                 ` Dale
2011-09-18  2:20                   ` Michael Mol
2011-09-18  3:56                     ` Pandu Poluan
2011-09-18 15:16                   ` Mark Knecht
2011-09-17 22:48               ` Mark Knecht [this message]
2011-09-17 20:54     ` Mark Knecht
2011-09-17 21:11       ` Dale
2011-09-17 21:12       ` pk
2011-09-17 23:00   ` Alan McKinnon
2011-09-18  2:15     ` Dale

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+eex7g=1BK5mTAuy_9PhLWh-xDGyeJTujb_X6Yr3w6V4jg@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