initrd busybox linuxrc shell

Technical issues/questions of an intermediate or advanced nature.
rych
Warlord
Warlord
Posts: 622
Joined: 04 Jan 2014, 04:27
Distribution: Porteus 5.0 x64 OpenBox
Location: NZ
Contact:

initrd busybox linuxrc shell

Post#1 by rych » 26 Nov 2022, 11:16

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

User avatar
ncmprhnsbl
DEV Team
DEV Team
Posts: 3924
Joined: 20 Mar 2012, 03:42
Distribution: v5.0-64bit
Location: australia
Contact:

initrd busybox linuxrc shell

Post#2 by ncmprhnsbl » 27 Nov 2022, 05:40

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
Forum Rules : https://forum.porteus.org/viewtopic.php?f=35&t=44

rych
Warlord
Warlord
Posts: 622
Joined: 04 Jan 2014, 04:27
Distribution: Porteus 5.0 x64 OpenBox
Location: NZ
Contact:

initrd busybox linuxrc shell

Post#3 by rych » 28 Nov 2022, 07:39

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?

User avatar
Rava
Contributor
Contributor
Posts: 5401
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

initrd busybox linuxrc shell

Post#4 by Rava » 22 Dec 2022, 01:57

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.
Cheers!
Yours Rava

Post Reply