* [gentoo-user] Making a init thingy. Step two I guess. @ 2011-09-17 20:02 Dale 2011-09-17 20:27 ` Mark Knecht 0 siblings, 1 reply; 19+ messages in thread From: Dale @ 2011-09-17 20:02 UTC (permalink / raw To: gentoo-user 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? 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 :-) :-) ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [gentoo-user] Making a init thingy. Step two I guess. 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 23:00 ` Alan McKinnon 0 siblings, 2 replies; 19+ messages in thread From: Mark Knecht @ 2011-09-17 20:27 UTC (permalink / raw To: gentoo-user 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. > 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 ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [gentoo-user] Making a init thingy. Step two I guess. 2011-09-17 20:27 ` Mark Knecht @ 2011-09-17 20:44 ` Dale 2011-09-17 20:51 ` Michael Mol 2011-09-17 20:54 ` Mark Knecht 2011-09-17 23:00 ` Alan McKinnon 1 sibling, 2 replies; 19+ messages in thread From: Dale @ 2011-09-17 20:44 UTC (permalink / raw To: gentoo-user 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 :-) :-) ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [gentoo-user] Making a init thingy. Step two I guess. 2011-09-17 20:44 ` Dale @ 2011-09-17 20:51 ` Michael Mol 2011-09-17 20:56 ` Mark Knecht 2011-09-17 20:54 ` Mark Knecht 1 sibling, 1 reply; 19+ messages in thread From: Michael Mol @ 2011-09-17 20:51 UTC (permalink / raw To: gentoo-user 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 ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [gentoo-user] Making a init thingy. Step two I guess. 2011-09-17 20:51 ` Michael Mol @ 2011-09-17 20:56 ` Mark Knecht 2011-09-17 21:17 ` Dale 0 siblings, 1 reply; 19+ messages in thread From: Mark Knecht @ 2011-09-17 20:56 UTC (permalink / raw To: gentoo-user 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 ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [gentoo-user] Making a init thingy. Step two I guess. 2011-09-17 20:56 ` Mark Knecht @ 2011-09-17 21:17 ` Dale 2011-09-17 21:32 ` Mark Knecht 0 siblings, 1 reply; 19+ messages in thread From: Dale @ 2011-09-17 21:17 UTC (permalink / raw To: gentoo-user 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 :-) :-) ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [gentoo-user] Making a init thingy. Step two I guess. 2011-09-17 21:17 ` Dale @ 2011-09-17 21:32 ` Mark Knecht 2011-09-17 22:27 ` Dale 0 siblings, 1 reply; 19+ messages in thread From: Mark Knecht @ 2011-09-17 21:32 UTC (permalink / raw To: gentoo-user 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 ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [gentoo-user] Making a init thingy. Step two I guess. 2011-09-17 21:32 ` Mark Knecht @ 2011-09-17 22:27 ` Dale 2011-09-17 22:45 ` Michael Mol 2011-09-17 22:48 ` Mark Knecht 0 siblings, 2 replies; 19+ messages in thread From: Dale @ 2011-09-17 22:27 UTC (permalink / raw To: gentoo-user 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 :-) :-) ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [gentoo-user] Making a init thingy. Step two I guess. 2011-09-17 22:27 ` Dale @ 2011-09-17 22:45 ` Michael Mol 2011-09-18 2:13 ` Dale 2011-09-17 22:48 ` Mark Knecht 1 sibling, 1 reply; 19+ messages in thread From: Michael Mol @ 2011-09-17 22:45 UTC (permalink / raw To: gentoo-user 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 ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [gentoo-user] Making a init thingy. Step two I guess. 2011-09-17 22:45 ` Michael Mol @ 2011-09-18 2:13 ` Dale 2011-09-18 2:20 ` Michael Mol 2011-09-18 15:16 ` Mark Knecht 0 siblings, 2 replies; 19+ messages in thread From: Dale @ 2011-09-18 2:13 UTC (permalink / raw To: gentoo-user Michael Mol wrote: > 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. > Ahhhhh. I see now. So, it mounts proc and sys but that is in the init then it mounts the real root outside the init. Then it umounts the proc and sys under the init and then switches to the real root and starts init there. Where does /usr and /var come in here? Isn't the init supposed to mount that too? Do I add that myself? If so, when to fsck get ran? Dale :-) :-) ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [gentoo-user] Making a init thingy. Step two I guess. 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 1 sibling, 1 reply; 19+ messages in thread From: Michael Mol @ 2011-09-18 2:20 UTC (permalink / raw To: gentoo-user On Sat, Sep 17, 2011 at 10:13 PM, Dale <rdalek1967@gmail.com> wrote: > Michael Mol wrote: [snippage] > Ahhhhh. I see now. So, it mounts proc and sys but that is in the init then > it mounts the real root outside the init. Then it umounts the proc and sys > under the init and then switches to the real root and starts init there. > > Where does /usr and /var come in here? Isn't the init supposed to mount > that too? Do I add that myself? If so, when to fsck get ran? From the look of it, yeah, it'd be your responsibility to do that in the "# Do your stuff here." area. Probably why the script has a line that says: echo "This script mounts rootfs and boots it up, nothing more!" -- :wq ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [gentoo-user] Making a init thingy. Step two I guess. 2011-09-18 2:20 ` Michael Mol @ 2011-09-18 3:56 ` Pandu Poluan 0 siblings, 0 replies; 19+ messages in thread From: Pandu Poluan @ 2011-09-18 3:56 UTC (permalink / raw To: gentoo-user [-- Attachment #1: Type: text/plain, Size: 909 bytes --] On Sep 18, 2011 9:22 AM, "Michael Mol" <mikemol@gmail.com> wrote: > > On Sat, Sep 17, 2011 at 10:13 PM, Dale <rdalek1967@gmail.com> wrote: > > Michael Mol wrote: > > [snippage] > > > Ahhhhh. I see now. So, it mounts proc and sys but that is in the init then > > it mounts the real root outside the init. Then it umounts the proc and sys > > under the init and then switches to the real root and starts init there. > > > > Where does /usr and /var come in here? Isn't the init supposed to mount > > that too? Do I add that myself? If so, when to fsck get ran? > > From the look of it, yeah, it'd be your responsibility to do that in > the "# Do your stuff here." area. > > Probably why the script has a line that says: echo "This script mounts > rootfs and boots it up, nothing more!" > Of course, you have to remember to mount usr in /mnt/root instead of in / That switch_root thing, you know. Rgds, [-- Attachment #2: Type: text/html, Size: 1260 bytes --] ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [gentoo-user] Making a init thingy. Step two I guess. 2011-09-18 2:13 ` Dale 2011-09-18 2:20 ` Michael Mol @ 2011-09-18 15:16 ` Mark Knecht 1 sibling, 0 replies; 19+ messages in thread From: Mark Knecht @ 2011-09-18 15:16 UTC (permalink / raw To: gentoo-user On Sat, Sep 17, 2011 at 7:13 PM, Dale <rdalek1967@gmail.com> wrote: <SNIP> > > Ahhhhh. I see now. So, it mounts proc and sys but that is in the init then > it mounts the real root outside the init. Then it umounts the proc and sys > under the init and then switches to the real root and starts init there. > > Where does /usr and /var come in here? Isn't the init supposed to mount > that too? Do I add that myself? If so, when to fsck get ran? > > Dale Hi Dale, Let's take a look at the script I sent you yesterday, copied here again. This system uses a RAID6 for root. This RAID6 is built using metadata type 1.2. (The newest at the time) Since the kernel only assembles metadata type 0.9 automatically I had to use the initramfs to do the assembly and mount. 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 / # There are really just 3 interesting parts to this: 1) The rescue_shell function 2) The assembly command 3) The mount command When you read through the script you see I do the assembly and then the mount. If the mount command fails then I drop into the rescue shell which is a simple Linux environment where I can run mdadm by hand to figure out what went wrong. If the mount succeeds then the script just continues and Linux boots. The only difference concerning your /usr question would be change the mount command to something like: mount -o ro /dev/sdaX /usr || rescue_shell Does this make basic sense? One point about static flag. Normally I don't build mdadm with static enabled: c2stable ~ # emerge -pv mdadm These are the packages that would be merged, in order: Calculating dependencies... done! [ebuild R ] sys-fs/mdadm-3.1.4 USE="-static" 282 kB Total: 1 package (1 reinstall), Size of downloads: 282 kB c2stable ~ # but for the version I put in the initramfs I did enable it. Cheers, Mark ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [gentoo-user] Making a init thingy. Step two I guess. 2011-09-17 22:27 ` Dale 2011-09-17 22:45 ` Michael Mol @ 2011-09-17 22:48 ` Mark Knecht 1 sibling, 0 replies; 19+ messages in thread From: Mark Knecht @ 2011-09-17 22:48 UTC (permalink / raw To: gentoo-user 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 ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [gentoo-user] Making a init thingy. Step two I guess. 2011-09-17 20:44 ` Dale 2011-09-17 20:51 ` Michael Mol @ 2011-09-17 20:54 ` Mark Knecht 2011-09-17 21:11 ` Dale 2011-09-17 21:12 ` pk 1 sibling, 2 replies; 19+ messages in thread From: Mark Knecht @ 2011-09-17 20:54 UTC (permalink / raw To: gentoo-user 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 ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [gentoo-user] Making a init thingy. Step two I guess. 2011-09-17 20:54 ` Mark Knecht @ 2011-09-17 21:11 ` Dale 2011-09-17 21:12 ` pk 1 sibling, 0 replies; 19+ messages in thread From: Dale @ 2011-09-17 21:11 UTC (permalink / raw To: gentoo-user 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 :-) :-) ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [gentoo-user] Making a init thingy. Step two I guess. 2011-09-17 20:54 ` Mark Knecht 2011-09-17 21:11 ` Dale @ 2011-09-17 21:12 ` pk 1 sibling, 0 replies; 19+ messages in thread From: pk @ 2011-09-17 21:12 UTC (permalink / raw To: gentoo-user 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 ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [gentoo-user] Making a init thingy. Step two I guess. 2011-09-17 20:27 ` Mark Knecht 2011-09-17 20:44 ` Dale @ 2011-09-17 23:00 ` Alan McKinnon 2011-09-18 2:15 ` Dale 1 sibling, 1 reply; 19+ messages in thread From: Alan McKinnon @ 2011-09-17 23:00 UTC (permalink / raw To: gentoo-user On Sat, 17 Sep 2011 13:27:45 -0700 Mark Knecht <markknecht@gmail.com> wrote: > > 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. True. Busybox is a tiny userland implementing most of the common options for most of the common Unix commands. When you log into your ADSL router/modem and get a shell, it's probably busybox running there, not GNU util-linux stuff. Binary distros often put busybox in their initrds as it doubles up as a rescue environment and busybox is many times smaller than the full GNU stuff. It's up to you if you want to do that or not; if all you use an initrd for is a convenient place to store drivers to be able to mount /usr, then you will have no need for busybox in it. -- Alan McKinnnon alan.mckinnon@gmail.com ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [gentoo-user] Making a init thingy. Step two I guess. 2011-09-17 23:00 ` Alan McKinnon @ 2011-09-18 2:15 ` Dale 0 siblings, 0 replies; 19+ messages in thread From: Dale @ 2011-09-18 2:15 UTC (permalink / raw To: gentoo-user Alan McKinnon wrote: > On Sat, 17 Sep 2011 13:27:45 -0700 > Mark Knecht<markknecht@gmail.com> wrote: > >>> 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. > True. > > Busybox is a tiny userland implementing most of the common options for > most of the common Unix commands. When you log into your ADSL > router/modem and get a shell, it's probably busybox running there, > not GNU util-linux stuff. > > Binary distros often put busybox in their initrds as it doubles up as a > rescue environment and busybox is many times smaller than the full GNU > stuff. It's up to you if you want to do that or not; if all you use an > initrd for is a convenient place to store drivers to be able to > mount /usr, then you will have no need for busybox in it. > Unless something goes wrong. You know how I am. Murphy's law and all. lol Dale :-) :-) ^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2011-09-18 15:17 UTC | newest] Thread overview: 19+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 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
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox