Page 1 of 1

initrd busybox linuxrc shell

Posted: 26 Nov 2022, 11:16
by rych
Which shell does the linuxrc run in? Is it some kind of Ash shell? I can see the current initrd includes bash, could I use it? Would this code even be legit inside linuxrc, in particular pushd/pod, `$()`, `<()`?

Code: Select all

pushd /target
cp -auv /source/. .
rm -v $(grep -v -F -x -f <(find /source -type f -printf '%P\n') <(find . -type f -printf '%P\n'))
find . -empty -type d -delete
popd

initrd busybox linuxrc shell

Posted: 27 Nov 2022, 05:40
by ncmprhnsbl
what shell is active at initrd time is a good question ... linuxrc calls #!/bin/sh which i'm led to believe defaults to ash in busybox...
presumably, changing linuxrc to #!/bin/bash might offer more features..
given that ash, bash and find are the busybox versions of those, there may be limitations..
you should be able to find out by calling these directly in the live system by: eg. /mnt/live/bin/bash

initrd busybox linuxrc shell

Posted: 28 Nov 2022, 07:39
by rych
ncmprhnsbl wrote:
27 Nov 2022, 05:40
presumably, changing linuxrc to #!/bin/bash might offer more features
Changing the top line of linurxc from #!/bin/sh to #!/bin/bash didn't seem to break anything, and no new warnings/errors on the boot console. So I'll go with that, as the the sh shell doesn't have pushd/popd for example, and in general I think bash is more modern?

Sorry for messing with something above by level and for uneducated questions, but what's the reason for the / to be /mnt/live at that stage? For example, if we do mkdir /Temp around line#205 before "# Find modules:" in linuxrc, why must it end up being in /mnt/live/Temp :) ? Interesting trickery, but why isn't it remounted to be the expected /Temp when finished?

initrd busybox linuxrc shell

Posted: 22 Dec 2022, 01:57
by Rava
rych wrote:
28 Nov 2022, 07:39
Interesting trickery, but why isn't it remounted to be the expected /Temp when finished?
I am no core developer so I cannot answer the question nor explain the reasons for why it is done so.
All I know is that the basic temporary folder in Linux is /tmp and not /Temp .

That might be the reason for what you called "interesting trickery", but be aware that this is just an educated guess on my part.