Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 107260 - "xargs" and "find" needed in /bin for diskless boot
Summary: "xargs" and "find" needed in /bin for diskless boot
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] baselayout (show other bugs)
Hardware: All Linux
: High critical (vote)
Assignee: Roy Marples (RETIRED)
URL: http://www.gentoo.org/doc/en/diskless...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-09-26 02:52 UTC by Rabbe Fogelholm
Modified: 2006-04-08 02:22 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rabbe Fogelholm 2005-09-26 02:52:35 UTC
"Diskless Nodes with Gentoo", September 16, 2005 version:

It appears that the commands "xargs" and "find" are needed in /bin for a system
that boots diskless. It may be argued that some of the /etc/init.d scripts
should be rewritten so that they don't use these commands (bootmisc is one of
them). However, a workaround approach is taken in this bug report:

Code Listing 6.1, add these lines after the "rsync" lines:

    # cp -p /usr/bin/find /diskless/192.168.1.21/bin
    # cp -p /usr/bin/xargs /diskless/192.168.1.21/bin
Comment 1 SpanKY gentoo-dev 2005-09-26 05:46:38 UTC
no, localmount runs before bootmisc which means /usr should then be available
Comment 2 Rabbe Fogelholm 2005-09-26 12:13:06 UTC
I think there is a problem in the diskless case. The localmount script does not
mount /usr, it is done by netmount. Assuming that netmount has been moved to the
boot runlevel (as suggested in bug 107262), it will still be the case that
bootmisc runs before netmount and complains that "xargs" and "find" cannot be found.
Comment 3 SpanKY gentoo-dev 2005-09-26 13:41:15 UTC
in that case it's a bug in baselayout, not the documentation
Comment 4 SpanKY gentoo-dev 2005-11-27 10:24:59 UTC
what if you edit the netmount script and add 'before bootmisc' to the depend()
function, and then add netmount to the boot runlevel instead of default ?
Comment 5 Rabbe Fogelholm 2005-12-21 14:42:51 UTC
(In reply to comment #4)
I tried adding "before bootmisc" to the depend() function of netmount and having netmount in the boot runlevel. The boot sequence still has problems:

* Mounting at /proc
* Mounting sysfs at /sys
* Kernel automatically mounted devfs at /dev
* Starting devfsd
* Started device management daemon
* Mounting devpts at /dev/pts
* Activating (possible) swap
* Remounting root file system read/write
* Setting hostname to xxxx
* Mounting local filesystems
* Activating (possibly) more swap
* Setting system clock to hardware clock [Local time]
* Setting DNS domain name to xx.yy.zz
*Starting lo

/etc/init.d/net.lo: line 40: xargs: command not found
/etc/init.d/net.lo: line 61: 1320 Broken pipe LC_ALL=C /bin/sort "$@"

* Bringing up lo
* Starting portmap
* ... some 15 more successful lines ...

Comment 6 Rabbe Fogelholm 2006-03-17 13:24:42 UTC
(In reply to comment #4)

Looking again at this problem several weeks later, I think maybe the least painful solution is to rewrite /etc/init.d/net.lo slightly, without changing its behaviour, so that it does not use `find' and `xargs' at all.

The motivation for doing so is that net.lo may be executed in diskless boot before /usr/bin is available, and it is not trivial to avoid this. At best it could be avoided by editing the dependencies between initscripts but this is not a very desirable thing in the first place and secondly we don't even have a known solution along that line.

There are four occurrences of `xargs' in net.lo. The current coding

  x=$( echo -e "${x// /\n}" | sort | xargs )

could be replaced by

  x=$( echo -e "${x// /\n}" | sort | tr '\n' ' ' | sed -e 's/ $//' )

Then there is one occurrence of `find'. The current coding

  MODULES=( $( find ${MODULES_DIR}/ -maxdepth 1 -type f ! -name ".*" | sort ) )

could be replaced by e. g.

  MODULES=( $( for Z in $( ls -1 ${MODULES_DIR}); do [ -f ${MODULES_DIR}/${Z} ] && echo ${MODULES_DIR}/${Z}; done | sort ) )

This code is of course less neat than the current code, so probably it is a good idea to keep the old code behind a '#' and insert a note as to why this equivalent but more ugly code is in fact used.

Comment 7 Rabbe Fogelholm 2006-03-17 14:01:21 UTC
(In reply to comment #4)

With the `bootmisc' script it is a slightly different story. It uses `find' to traverse various file trees so writing a replacement is not as simple as in the case of net.lo.

My solution so far is to add a "need netmount" dependence to the bootmisc script and to add a file named /etc/runlevels/boot/.critical containing the lines

  checkroot
  hostname
  modules
  checkfs
  localmount
  clock

This file is interpreted by the get_critical_services function of /sbin/rc and the important point is that the list does NOT include `bootmisc'. Unless the .critical file is present `bootmisc' will run before netmount despite the "need netmount" dependence and there will be complaints that `find' and `xargs' are not found.
Comment 8 Rabbe Fogelholm 2006-03-19 13:34:28 UTC
(In reply to comment #6)

Ahemm .. with ls -1 already producing lexicographic order there is of course no need to invoke /bin/sort. Thus

  MODULES=( $( for Z in $( ls -1 ${MODULES_DIR}); do [ -f ${MODULES_DIR}/${Z} ] && echo ${MODULES_DIR}/${Z}; done) )

should be sufficient.
Comment 9 SpanKY gentoo-dev 2006-03-20 19:11:49 UTC
> Ahemm .. with ls -1 already producing lexicographic order there is of course
> no need to invoke /bin/sort.

the -1 option does not require the output to be sorted
Comment 10 Rabbe Fogelholm 2006-03-21 05:04:44 UTC
(In reply to comment #9)

No, that's right, sorting will be "according to the collating sequence in the current locale" as longs as none of -SUXcftuv (no more I hope) are given. And the -1 can be dropped; I threw it in as an indication that creating multi-column output is not of interest here although really that does not happen anyway.

But, the important point IMHO is that net.lo must not depend on utilities in /usr/bin, unless we can document a reasonable way to do diskless boot with net.lo in its current /usr/bin dependent shape.

For some time to come I have access to a couple of machines (one Gentoo 2006.0, one diskless with a PXE card) where I can do tests. My best working solution so far is not so neat: re-code of net.lo, adding a dependency in bootmisc, and supplying a customized file /etc/runlevels/boot/.critical. I'd be happy to test any suggestions towards a more neat solution.
Comment 11 Roy Marples (RETIRED) gentoo-dev 2006-03-21 15:12:33 UTC
net.lo in baselayout-1.12.0_pre16 doesn't use find or xargs.
iirc two modules do, doubt that you'll be bridging ;) In any case, xargs has been replaced with the tr '\n' ' ' trick and that will be out in pre17

No idea what todo about bootmisc at this time. vapier, thoughts?
Comment 12 SpanKY gentoo-dev 2006-03-21 20:05:16 UTC
if 1.12.x has the fixes and it isnt trivial to backport to 1.11.x, then i guess just mark as FIXED
Comment 13 Todd Lee 2006-03-22 13:24:22 UTC
Is it a problem to just use an linuxrc type script to premount /usr? We just added an "init=linuxrc" line to the PXE default setup. The linuxrc script is simple:

---------
#!/bin/sh
mount -t proc none /proc
CMDLINE=`cat /proc/cmdline`
mount /usr
umount /proc
exec /sbin/init ${CMDLINE}
---------

We have 100 computing nodes setup like this.
Comment 14 Roy Marples (RETIRED) gentoo-dev 2006-04-08 02:22:14 UTC
pre17 is now out.