FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Gentoo > Gentoo User

 
 
LinkBack Thread Tools
 
Old 09-17-2011, 08:44 PM
Dale
 
Default Making a init thingy. Step two I guess.

Mark Knecht wrote:

On Sat, Sep 17, 2011 at 1:02 PM, Dale<rdalek1967@gmail.com> wrote:

OK. Sort of dealt with the LVM part so now to step two. I'm trying to
follow this:

http://en.gentoo-wiki.com/wiki/Initramfs

Then I get confused. I get to Applications and I'm sort of lost here. In
there it talks about copying nano and its friends over to the init
directory. Then below that it says to use busybox. Well, which is it? Do
I do both of those or just one?


It's been a while for me but I believe it's both. I think busybox is
the thing that gives you command line tools like cd, ls, pwd, etc.
However you also can include applications in your initramfs that give
you more access to the hardware or the net.


That's what I was thinking to. I know busybox does a LOT of things but
I didn't think it was a nano replacement either. OK. I got both of
those in there at least. First problem dealt with I guess. Wonder what
else I should put in there too. < scratches head >





I also tried to figure out Dracut but it seems like a work in progress or
something. I can't seem to find any Gentoo docs for it. I found a Redhat
doc but that's not exactly Gentoo.

Am I starting to work on this to soon? Maybe wait a while longer until some
more stuff gets sorted out?

Dang, I'm full of questions today. ;-)

Dale

I'm just reading some Dracut stuff myself. I figured I might as well
get educated. I likely won't actually build it and try it for a few
days at the soonest, but it's good to get prepared. Cheers to you for
doing that.

- Mark



Yea, it's either learn this or find a new distro. Still haven't ruled
out the later tho. Just going to try at least.


Dale

:-) :-)
 
Old 09-17-2011, 08:51 PM
Michael Mol
 
Default Making a init thingy. Step two I guess.

On Sat, Sep 17, 2011 at 4:44 PM, Dale <rdalek1967@gmail.com> wrote:
> Mark Knecht wrote:
>> On Sat, Sep 17, 2011 at 1:02 PM, Dale<rdalek1967@gmail.com> *wrote:
> That's what I was thinking to. *I know busybox does a LOT of things but I
> didn't think it was a nano replacement either. *OK. *I got both of those in
> there at least. *First problem dealt with I guess. *Wonder what else I
> should put in there too. < scratches head >

Anything that makes life convenient, I'd guess.

I'd look at stuffing these in there:
* screen
* file
* ssh
* links/lynx/w3m

You'd also need the .so files those depend on. I don't know how to
identify those.

--
:wq
 
Old 09-17-2011, 08:54 PM
Mark Knecht
 
Default Making a init thingy. Step two I guess.

On Sat, Sep 17, 2011 at 1:44 PM, Dale <rdalek1967@gmail.com> wrote:
> Mark Knecht wrote:
>>
>> On Sat, Sep 17, 2011 at 1:02 PM, Dale<rdalek1967@gmail.com> *wrote:
>>>
>>> OK. *Sort of dealt with the LVM part so now to step two. *I'm trying to
>>> follow this:
>>>
>>> http://en.gentoo-wiki.com/wiki/Initramfs
>>>
>>> Then I get confused. *I get to Applications and I'm sort of lost here.
>>> *In
>>> there it talks about copying nano and its friends over to the init
>>> directory. *Then below that it says to use busybox. *Well, which is it?
>>> *Do
>>> I do both of those or just one?
>>>
>> It's been a while for me but I believe it's both. I think busybox is
>> the thing that gives you command line tools like cd, ls, pwd, etc.
>> However you also can include applications in your initramfs that give
>> you more access to the hardware or the net.
>
> That's what I was thinking to. *I know busybox does a LOT of things but I
> didn't think it was a nano replacement either. *OK. *I got both of those in
> there at least. *First problem dealt with I guess. *Wonder what else I
> should put in there too. < scratches head >
>

Right. I don't think it replaces nano. If you want to edit in that
environment than I think you need to include an editor.

Note that one of the initramfs requirements for applications is that
they need to be built as 'static'. (I think) so that they don't
require libraries or other things that aren't yet mounted.

>>
>>> I also tried to figure out Dracut but it seems like a work in progress or
>>> something. *I can't seem to find any Gentoo docs for it. *I found a
>>> Redhat
>>> doc but that's not exactly Gentoo.
>>>
>>> Am I starting to work on this to soon? *Maybe wait a while longer until
>>> some
>>> more stuff gets sorted out?
>>>
>>> Dang, I'm full of questions today. *;-)
>>>
>>> Dale
>>
>> I'm just reading some Dracut stuff myself. I figured I might as well
>> get educated. I likely won't actually build it and try it for a few
>> days at the soonest, but it's good to get prepared. Cheers to you for
>> doing that.
>>
>> - Mark
>>
>
> Yea, it's either learn this or find a new distro. *Still haven't ruled out
> the later tho. *Just going to try at least.
>
> Dale

Nahh...you're smarted than becoming an Ubuntu guy. Of course, if I'm
wrong maybe you'll become an Ubuntu guy... ;-)

- Mark
 
Old 09-17-2011, 08:56 PM
Mark Knecht
 
Default Making a init thingy. Step two I guess.

On Sat, Sep 17, 2011 at 1:51 PM, Michael Mol <mikemol@gmail.com> wrote:
> On Sat, Sep 17, 2011 at 4:44 PM, Dale <rdalek1967@gmail.com> wrote:
>> Mark Knecht wrote:
>>> On Sat, Sep 17, 2011 at 1:02 PM, Dale<rdalek1967@gmail.com> *wrote:
>> That's what I was thinking to. *I know busybox does a LOT of things but I
>> didn't think it was a nano replacement either. *OK. *I got both of those in
>> there at least. *First problem dealt with I guess. *Wonder what else I
>> should put in there too. < scratches head >
>
> Anything that makes life convenient, I'd guess.
>
> I'd look at stuffing these in there:
> * screen
> * file
> * ssh
> * links/lynx/w3m
>
> You'd also need the .so files those depend on. I don't know how to
> identify those.
>
> --
> :wq
>
>

Supposedly

ldd /usr/bin/screen
ldd /usr/bin/file
ldd /usr/bin/ssh

etc.

I think that's what I did when I built one a while back...

- Mark
 
Old 09-17-2011, 09:11 PM
Dale
 
Default Making a init thingy. Step two I guess.

Mark Knecht wrote:

On Sat, Sep 17, 2011 at 1:44 PM, Dale<rdalek1967@gmail.com> wrote:


That's what I was thinking to. I know busybox does a LOT of things but I
didn't think it was a nano replacement either. OK. I got both of those in
there at least. First problem dealt with I guess. Wonder what else I
should put in there too.< scratches head>


Right. I don't think it replaces nano. If you want to edit in that
environment than I think you need to include an editor.

Note that one of the initramfs requirements for applications is that
they need to be built as 'static'. (I think) so that they don't
require libraries or other things that aren't yet mounted.


I noticed that in the command for busybox. Trick is remembering it.
:/ Oh, looky here:


[ebuild R ] app-editors/nano-2.2.5 USE="justify ncurses nls spell
unicode -debug -minimal -slang"


No static build for nano. Bummer. It couldn't be that easy huh? :-(


Yea, it's either learn this or find a new distro. Still haven't ruled out
the later tho. Just going to try at least.

Dale

Nahh...you're smarted than becoming an Ubuntu guy. Of course, if I'm
wrong maybe you'll become an Ubuntu guy... ;-)

- Mark



I'm not sure at times. It seems as times goes by, the reasons I left
Mandrake are coming to Gentoo. The only thing is, I only updated
Mandrake once every few months and VERY little to compile either. Plus,
I had powstatd for my UPS as well. I like it a LOT more than upsmon and
such.


I made it to the init script part and I'm clueless. Let me see if I got
this right. I copy the script but I don't see where it mounts /usr and
/var anywhere. Do I need to add that to the script or does something
figure this out later? Isn't that the point of the script, to mount
/usr and /var?


Progress, ever so sloooooooowly. o_O

Dale

:-) :-)
 
Old 09-17-2011, 09:12 PM
pk
 
Default Making a init thingy. Step two I guess.

On 2011-09-17 22:54, Mark Knecht wrote:

>> That's what I was thinking to. I know busybox does a LOT of things but I
>> didn't think it was a nano replacement either. OK. I got both of those in
>> there at least. First problem dealt with I guess. Wonder what else I
>> should put in there too. < scratches head >

http://linux.die.net/man/1/busybox

> Right. I don't think it replaces nano. If you want to edit in that
> environment than I think you need to include an editor.

cat & (s)ed (included in busybox) works fine if you want to edit text
files...
https://www.ibm.com/developerworks/aix/library/au-textedit.html

Best regards

Peter K
 
Old 09-17-2011, 09:17 PM
Dale
 
Default Making a init thingy. Step two I guess.

Mark Knecht wrote:

On Sat, Sep 17, 2011 at 1:51 PM, Michael Mol<mikemol@gmail.com> wrote:

On Sat, Sep 17, 2011 at 4:44 PM, Dale<rdalek1967@gmail.com> wrote:

Mark Knecht wrote:

On Sat, Sep 17, 2011 at 1:02 PM, Dale<rdalek1967@gmail.com> wrote:

That's what I was thinking to. I know busybox does a LOT of things but I
didn't think it was a nano replacement either. OK. I got both of those in
there at least. First problem dealt with I guess. Wonder what else I
should put in there too.< scratches head>

Anything that makes life convenient, I'd guess.

I'd look at stuffing these in there:
* screen
* file
* ssh
* links/lynx/w3m

You'd also need the .so files those depend on. I don't know how to
identify those.

--
:wq



Supposedly

ldd /usr/bin/screen
ldd /usr/bin/file
ldd /usr/bin/ssh

etc.

I think that's what I did when I built one a while back...

- Mark




Yep, that's how the howto says it too. It seems to work.

root@fireball / # ldd /bin/nano
linux-vdso.so.1 => (0x00007fffc25ff000)
libncursesw.so.5 => /lib64/libncursesw.so.5 (0x00007f25fb500000)
libc.so.6 => /lib64/libc.so.6 (0x00007f25fb171000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007f25faf6d000)
/lib64/ld-linux-x86-64.so.2 (0x00007f25fb75f000)
root@fireball / #

So, I copied those over too.

Adding ssh and screen are good ideas. I very rarely use file. Still
might tho. Interesting:


root@fireball / # ldd /usr/bin/screen
linux-vdso.so.1 => (0x00007fffe1573000)
libcrypt.so.1 => /lib64/libcrypt.so.1 (0x00007f921dfca000)
libncursesw.so.5 => /lib64/libncursesw.so.5 (0x00007f921dd6b000)
libpam.so.0 => /lib64/libpam.so.0 (0x00007f921db5c000)
libc.so.6 => /lib64/libc.so.6 (0x00007f921d7cd000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007f921d5c9000)
/lib64/ld-linux-x86-64.so.2 (0x00007f921e230000)
root@fireball / # ldd /usr/bin/ssh
linux-vdso.so.1 => (0x00007fffc6bff000)
libcrypto.so.1.0.0 => /usr/lib64/libcrypto.so.1.0.0
(0x00007ff6aa7b9000)

libdl.so.2 => /lib64/libdl.so.2 (0x00007ff6aa5b5000)
libz.so.1 => /lib64/libz.so.1 (0x00007ff6aa39d000)
libresolv.so.2 => /lib64/libresolv.so.2 (0x00007ff6aa186000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007ff6a9f69000)
libc.so.6 => /lib64/libc.so.6 (0x00007ff6a9bda000)
/lib64/ld-linux-x86-64.so.2 (0x00007ff6aab73000)
root@fireball / #

Those seem to have a bit in common and no static flag for either.

Dale

:-) :-)
 
Old 09-17-2011, 09:32 PM
Mark Knecht
 
Default Making a init thingy. Step two I guess.

On Sat, Sep 17, 2011 at 2:17 PM, Dale <rdalek1967@gmail.com> wrote:
> Mark Knecht wrote:
>>
>> On Sat, Sep 17, 2011 at 1:51 PM, Michael Mol<mikemol@gmail.com> *wrote:
>>>
>>> On Sat, Sep 17, 2011 at 4:44 PM, Dale<rdalek1967@gmail.com> *wrote:
>>>>
>>>> Mark Knecht wrote:
>>>>>
>>>>> On Sat, Sep 17, 2011 at 1:02 PM, Dale<rdalek1967@gmail.com> * *wrote:
>>>>
>>>> That's what I was thinking to. *I know busybox does a LOT of things but
>>>> I
>>>> didn't think it was a nano replacement either. *OK. *I got both of those
>>>> in
>>>> there at least. *First problem dealt with I guess. *Wonder what else I
>>>> should put in there too.< *scratches head>
>>>
>>> Anything that makes life convenient, I'd guess.
>>>
>>> I'd look at stuffing these in there:
>>> * screen
>>> * file
>>> * ssh
>>> * links/lynx/w3m
>>>
>>> You'd also need the .so files those depend on. I don't know how to
>>> identify those.
>>>
>>> --
>>> :wq
>>>
>>>
>> Supposedly
>>
>> ldd /usr/bin/screen
>> ldd /usr/bin/file
>> ldd /usr/bin/ssh
>>
>> etc.
>>
>> I think that's what I did when I built one a while back...
>>
>> - Mark
>>
>>
>
> Yep, that's how the howto says it too. *It seems to work.
>
> root@fireball / # ldd /bin/nano
> * * * *linux-vdso.so.1 => *(0x00007fffc25ff000)
> * * * *libncursesw.so.5 => /lib64/libncursesw.so.5 (0x00007f25fb500000)
> * * * *libc.so.6 => /lib64/libc.so.6 (0x00007f25fb171000)
> * * * *libdl.so.2 => /lib64/libdl.so.2 (0x00007f25faf6d000)
> * * * */lib64/ld-linux-x86-64.so.2 (0x00007f25fb75f000)
> root@fireball / #
>
> So, I copied those over too.
>
> Adding ssh and screen are good ideas. *I very rarely use file. *Still might
> tho. Interesting:
>
> root@fireball / # ldd /usr/bin/screen
> * * * *linux-vdso.so.1 => *(0x00007fffe1573000)
> * * * *libcrypt.so.1 => /lib64/libcrypt.so.1 (0x00007f921dfca000)
> * * * *libncursesw.so.5 => /lib64/libncursesw.so.5 (0x00007f921dd6b000)
> * * * *libpam.so.0 => /lib64/libpam.so.0 (0x00007f921db5c000)
> * * * *libc.so.6 => /lib64/libc.so.6 (0x00007f921d7cd000)
> * * * *libdl.so.2 => /lib64/libdl.so.2 (0x00007f921d5c9000)
> * * * */lib64/ld-linux-x86-64.so.2 (0x00007f921e230000)
> root@fireball / # ldd /usr/bin/ssh
> * * * *linux-vdso.so.1 => *(0x00007fffc6bff000)
> * * * *libcrypto.so.1.0.0 => /usr/lib64/libcrypto.so.1.0.0
> (0x00007ff6aa7b9000)
> * * * *libdl.so.2 => /lib64/libdl.so.2 (0x00007ff6aa5b5000)
> * * * *libz.so.1 => /lib64/libz.so.1 (0x00007ff6aa39d000)
> * * * *libresolv.so.2 => /lib64/libresolv.so.2 (0x00007ff6aa186000)
> * * * *libpthread.so.0 => /lib64/libpthread.so.0 (0x00007ff6a9f69000)
> * * * *libc.so.6 => /lib64/libc.so.6 (0x00007ff6a9bda000)
> * * * */lib64/ld-linux-x86-64.so.2 (0x00007ff6aab73000)
> root@fireball / #
>
> Those seem to have a bit in common and no static flag for either.
>
> Dale

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
 
Old 09-17-2011, 10:27 PM
Dale
 
Default Making a init thingy. Step two I guess.

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

:-) :-)
 
Old 09-17-2011, 10:45 PM
Michael Mol
 
Default Making a init thingy. Step two I guess.

On Sat, Sep 17, 2011 at 6:27 PM, Dale <rdalek1967@gmail.com> wrote:
> Mark Knecht wrote:
> 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. *;-)

Here's how I read it.

First, it mounts /proc and /sys, since just about anything is going to
need at least one of those.

Second, it mounts your (desired) / filesystem at /mnt/root.

Third, it unmounts /proc and /sys.

Fourth, it switches out / with the filesystem it already mounted at
/mnt/root. This is similar (idential) to chroot. At the _same_ time,
it launches your init script.

Your init script launches and sees a / without a /proc or a /sys. The
/ it sees is what _was_ /mnt/root only moments before. The stuff that
was originally at / is no longer accessible. (Which, incidentally, is
why you unmount /proc and /sys; nothing would be able to get to those
particular mounted filesystems, since everything else gets to see the
world with /mnt/root/ as the /.

Your init script (the one at /sbin/init), seeing itself in a fresh,
needs-to-be-booted system, mounts /proc, /sys, etc...everything the
init script is configured to do.

--
:wq
 

Thread Tools




All times are GMT. The time now is 02:41 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org