linuxrc


Forum: Other Help Topics
Topic: linuxrc
started by: MrUmunhum

Posted by MrUmunhum on Nov. 21 2006,12:47
I am trying to change linuxrc to use bash and not ash.  It is not working.
I have added bash to the /static dir and changed the first line in linuxrc from sh
to bash.

ash only supports a few commands and the parsing is broken.

any ideas?

Posted by ^thehatsrule^ on Nov. 21 2006,14:57
Quote
It is not working.
What goes wrong?

If you have /static/bash then you should also replace the symlink from sh to point to it.  The scripts could be called by sh which would override the shebang.  Of course the easiest way to tell if whatever you're doing will work would be to replace ash completely.

Quote
and the parsing is broken.
parsing of..?

Anyhow, reason for ash: fast(er) boot.

Posted by MrUmunhum on Nov. 21 2006,19:54
Quote (^thehatsrule^ @ Nov. 21 2006,09:57)
Quote
It is not working.
What goes wrong?

If you have /static/bash then you should also replace the symlink from sh to point to it.  The scripts could be called by sh which would override the shebang.  Of course the easiest way to tell if whatever you're doing will work would be to replace ash completely.

Quote
and the parsing is broken.
parsing of..?

Anyhow, reason for ash: fast(er) boot.

Parsing like:

 junk=${CMDLINE}
 junk="${junk##parm=}"      <== fails here
 junk="${junk%%[     ]*}"

What I am doing is making a linuxrc that supports PXE booting with NFS mounting of KNOPPIX FS.

I am currently stick on getting the NFS mount to work.  I have loaded nfs.o,
lockd.o and sunrpc.o, but something is missing and the NFS mount fails.

Since the console to ttyS0 fails, it is hard to debug my code.  Ash is very limited and the messages falls off of the screen.

The failure is a kernel panic after failure to change to /initrd ( I think ).

Posted by mikshaw on Nov. 21 2006,20:31
I think junk="${junk##parm=}" can be rewritten for ash like this:
junk=`echo ${junk} | sed 's/parm=//'`
...or something similar...i just pulled this out of my butt.

You're also going to have trouble with ${junk%%[     ]*}:
junk=`echo ${junk} | sed 's/ *$//'` (guessing again...not sure what "[   ]*" is)

These issues are not a result of ash being broken, but are because bash has added features that are not available in ash.  The string manipulation above is an example of bash-specific script.

Posted by ^thehatsrule^ on Nov. 21 2006,21:03
Ah yes.. the 'bash-isms'

If you really don't care about about speed and efficiency I suppose you could try to use bash instead.

Otherwise, I'd suggest for you to replace whatever scripting you're doing with replacement commands or use another implementation.  If you decide to go this way, you could paste out your script (or snippets of) to show what you're trying to do with the code and we can try to help.

Posted by MrUmunhum on Nov. 21 2006,21:13
Quote (mikshaw @ Nov. 21 2006,15:31)
These issues are not a result of ash being broken, but are because bash has added features that are not available in ash.  The string manipulation above is an example of bash-specific script.

If you do a man on ash and go to 'Parameter Expansion' section, these formats are meant to be supported.  But they doing work.
Posted by ^thehatsrule^ on Nov. 21 2006,21:21
Hm, interesting - my next guess is that the included ash binary is not the same version as the manpage you are looking at, or its not compiled in, etc. (since I haven't seen any startup scripts using it, I wouldn't be surprised).

Guess another alternative is to replace ash with one that works to how you want it to.

Another thing, can you log the boot processes?  Anyways, did you try running a dummy script inside an ash terminal?

Posted by MrUmunhum on Nov. 21 2006,21:23
Quote (^thehatsrule^ @ Nov. 21 2006,16:03)
Ah yes.. the 'bash-isms'

If you really don't care about about speed and efficiency I suppose you could try to use bash instead.

Otherwise, I'd suggest for you to replace whatever scripting you're doing with replacement commands or use another implementation.  If you decide to go this way, you could paste out your script (or snippets of) to show what you're trying to do with the code and we can try to help.

I am trying to use bash because ash is so limited.

Here is my added code:
Quote

case "$CMDLINE" in *nfs=*)
      set -x;
     $INSMOD /modules/sunrpc.o
     $INSMOD /modules/lockd.o
     $INSMOD /modules/nfs.o
     lsmod
     NOIDERAID="yes";
     NOCD="yes";
#      NFS_SERVER="${CMDLINE##*nfs=}";
#      NFS_SERVER="${NFS_SERVER%%[     ]*}";
     echo NFS_Server="${NFS_SERVER}";
     mount  -t nfs 10.1.1.12:/tftpboot/DSL /KNOPPIX
     set +x;  ;; esac

Posted by MrUmunhum on Nov. 21 2006,21:28
Quote (^thehatsrule^ @ Nov. 21 2006,16:21)
Another thing, can you log the boot processes?  Anyways, did you try running a dummy script inside an ash terminal?

What do you mean by an 'ash terminal'?
Posted by mikshaw on Nov. 21 2006,21:45
"aterm -e ash" should give you an ash terminal.

Quote
If you do a man on ash and go to 'Parameter Expansion' section, these formats are meant to be supported.

It might be an older version of ash in DSL?  Just guessing.

Posted by ^thehatsrule^ on Nov. 21 2006,21:52
Code Sample
case "$CMDLINE" in *fromhd=/dev/*) DEVICES="$fromhd";;; esac
Did you try using NFS_SERVER="$nfs" ?

ash terminal, as in starting ash instead of bash i.e. in DSL. (you can just execute ash in any terminal if you'd like).  Those substitutions are probably not supported by the included binary.

Posted by MrUmunhum on Nov. 23 2006,22:41
Ok, guys, I think I have foubnd my first problem, which is adding NFS support to the boot process:

 1) I need to run ifconfig for my eth0. Ash will not let me do this.
 2) Add module support nfs, sunrpc, lockd,3c59x, etc.  This is easy.
 3) mount -t nfs server:/path /locat_dir.  The NFS mount command in DSL is
    broken, You must add the -f flag to get it to work, otherwise the mount
    command hangs.

What I want to try next is using a non-DSL kernel.  Where can I get a kernel binary at the same level ( 2.4.17, I think )?  I can find the source but I don't want to recompile, just more work for a test.  I think the problem is the DSL kernel is calling 'linuxrc' directly using ash and can not be over ridden.

Posted by MrUmunhum on Nov. 23 2006,22:45
Quote (MrUmunhum @ Nov. 21 2006,16:28)
Quote (^thehatsrule^ @ Nov. 21 2006,16:21)
Another thing, can you log the boot processes?  Anyways, did you try running a dummy script inside an ash terminal?

What do you mean by an 'ash terminal'?

Ash will not let me run anything other that build in command!  That is the problem.

I think I have found my first problem, which is adding NFS support to the boot process:

1) I need to run ifconfig for my eth0. Ash will not let me do this.
2) Add module support nfs, sunrpc, lockd,3c59x, etc.  This is easy.
3) mount -t nfs server:/path /locat_dir.  The NFS mount command in DSL is
   broken, You must add the -f flag to get it to work, otherwise the mount
   command hangs.

What I want to try next is using a non-DSL kernel.  Where can I get a kernel binary at the same level ( 2.4.17, I think )?  I can find the source but I don't want to recompile, just more work for a test.  I think the problem is the DSL kernel is calling 'linuxrc' directly using ash and can not be over ridden.

Posted by ^thehatsrule^ on Nov. 24 2006,06:10
That's because ifconfig is a separate program, and you'd have to add that too (no idea how to get networking support then either - probably have to create the device first anyways)

It may be easier to use a premade toolset.. (like that pxe stuff)

And as I pointed out earlier, you could try to just replace ash directly.

Posted by MrUmunhum on Nov. 24 2006,18:35
Quote (^thehatsrule^ @ Nov. 24 2006,01:10)
That's because ifconfig is a separate program, and you'd have to add that too (no idea how to get networking support then either - probably have to create the device first anyways)

It may be easier to use a premade toolset.. (like that pxe stuff)

And as I pointed out earlier, you could try to just replace ash directly.

I have added ifconfig, it is in busybox.  Ash just will not execute it or anything else that is not in it's limited command set.

I have tried to replace ash with bash and that fails as well.

At this point, PXE is gone.  It loaded the kernel and the minirt file system and transfer control over to the kernel.

Posted by ^thehatsrule^ on Nov. 24 2006,19:29
So you added busybox as well?  What did you change to try to execute it?

How did you try to replace the shell?

I meant like the other forum user's post, where PXE loaded the kernel and the minirt which held the knoppix image (you just need more memory to use this though).

Posted by MrUmunhum on Nov. 24 2006,22:28
Quote (^thehatsrule^ @ Nov. 24 2006,14:29)
So you added busybox as well?  What did you change to try to execute it?

How did you try to replace the shell?

I meant like the other forum user's post, where PXE loaded the kernel and the minirt which held the knoppix image (you just need more memory to use this though).

I put busybox in /static along with links for :
Quote

(cd PXE_FS/static/ ln -s       busybox ls      )
(cd PXE_FS/static/ ln -s       busybox mkdir   )
(cd PXE_FS/static/ ln -s       busybox sleep   )
(cd PXE_FS/static/ ln -s       busybox env     )
(cd PXE_FS/static/ ln -s       busybox pwd     )
(cd PXE_FS/static/ ln -s       busybox which   )
(cd PXE_FS/static/ ln -s       busybox ifconfig)
(cd PXE_FS/static/ ln -s       busybox ifup    )
(cd PXE_FS/static/ ln -s       busybox ping    )
(cd PXE_FS/static/ ln -s       busybox route   )
(cd PXE_FS/static/ ln -s       busybox ln      )


The mini24 image is the small FS that is used during the boot up process.  It is not the run level FS, that is what I am trying to use a NFS mount to connect.

I have been doing some reading about linuxrc.  It is call after the kernel gets control.
The code looks like this:
Quote

static int do_linuxrc(void * shell)
{
static char *argv[] = { "linuxrc", NULL, };
extern char * envp_init[];

close(old_fd);
close(root_fd);
close(0);
close(1);
close(2);
setsid();
(void) open("/dev/console",O_RDWR,0);
(void) dup(0);
(void) dup(0);
return execve(shell, argv, envp_init);
}


I have tried changing the '#!' line in linuxrc, Copying bash to linuxrc.
All fail with a kernel panic.

The bottom line is, it is not a DSL problem, it is a kernel problem.  I get  the same results using other kernels, including FC5.

So more of RTFMing!

Posted by ^thehatsrule^ on Nov. 24 2006,22:41
Quote
The mini24 image is the small FS that is used during the boot up process.  It is not the run level FS, that is what I am trying to use a NFS mount to connect.
Yes I know - but it doesn't have to be small.  I was just suggesting what another forum user had completed - it's basically network-toram.  Guess it won't help you if you don't have enough memory anyways.

I'm guessing it's because that bash you're trying to use requires external libraries... you'd have to compile a static executable or something like it (same for busybox)

Also networking support isn't even enabled here, even if you do include ifconfig, you'll have to include the device and drivers/modules.

Posted by MrUmunhum on Nov. 25 2006,00:00
Quote (^thehatsrule^ @ Nov. 24 2006,17:41)
Quote
The mini24 image is the small FS that is used during the boot up process.  It is not the run level FS, that is what I am trying to use a NFS mount to connect.
Yes I know - but it doesn't have to be small.  I was just suggesting what another forum user had completed - it's basically network-toram.  Guess it won't help you if you don't have enough memory anyways.

I'm guessing it's because that bash you're trying to use requires external libraries... you'd have to compile a static executable or something like it (same for busybox)

Also networking support isn't even enabled here, even if you do include ifconfig, you'll have to include the device and drivers/modules.

Yes, I know about the drivers.  I'm not getting to that point yet.  The drivers are included in the mini FS.  It's not so mini any more!
Powered by Ikonboard 3.1.2a
Ikonboard © 2001 Jarvis Entertainment Group, Inc.