diskless initialization before mountall
James Hunt
james.hunt at canonical.com
Wed Apr 13 16:25:49 UTC 2011
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 13/04/11 15:26, Alex Aminoff wrote:
>
> Thank you very much for writing the Upstart cookbook. It would have
> taken me 10x as long to figure out all that information from scattered
> man pages and other references.
Thanks!
>
> We have a diskless setup that we have used for several years for FreeBSD
> and Fedora. I need to port this system to Ubuntu. I have ubuntu booting
> diskless off the NFS server.
>
> The hard part now is to have it run our cross-platform diskless
> initialization script, which is derived from FreeBSD's rc.initdiskless.
> This script sets up in-memory file systems for /etc, /var, and others,
> then copies in appropriate contents. There is a lot of logic for
> configuring individual diskless-booted machines to do particular things,
> so this system also provides configuration management sort of like
> cfengine or similar, especially by building the contents of /etc.
>
> Things just aren't working right. I'm concerned that upstart is reading
> /etc/init/*.conf in parallel with my script replacing /etc with an empty
> in-memory fs and then copying in the contents. In FreeBSD and Fedora it
> was pretty easy to ensure that our script got run before everything
> else: the boot process was basically sequential. However, upstart wants
> to do things in parallel.
That's the best way ;)
>
> I have it working now with a diskless.conf like this:
>
> start on starting mountall
>
> console output
> env INIT_VERBOSE
>
> task
>
> script
> . /etc/rc.initdiskless
> end script
>
That will work. Technically, the latest you could start I think would be:
start on starting rc-sysinit
That way, "diskless" job will run immediately before Upstart allows the
SysV init scripts (/etc/init.d/*) to run. This won't guarantee that some
other *Upstart* .conf file isn't trying to read files from /etc though.
However, if you are building a custom-solution here, presumably you have
control over exactly which .conf files (and /etc/init.d/* scripts) are
installed?
> My questions are:
>
> - How can I get my script to run before anything else that wants to look
> up config in /etc? In particular, what if some script running in
> parallel wants to look up a uid with getent, but there is no
> /etc/nsswitch.conf? What if I want my script to copy per-machine
> configuration into /etc/init?
If you are really keen to run "early", there are a number of techniques
you could employ including:
- - doing your setup in initramfs (before Upstart starts)
- - boot with init=/some/script and have that script do your required
setup. Then have the script "exec /sbin/init".
Does upstart read all its config from
> /etc/init right at the beginning such that copied-in changes will not
> matter?
Upstart loads all valid job configuration files from /etc/init at
startup, but it watches the directory using inotify so Upstart will be
nodified of any changes to existing .conf files immediately, and it will
also load all valid .conf files *created* after it starts. This is
stated in the first line of "man 5 init" - that page is absolutely
essential reading! You may also find upstart-events(7) useful.
>
> - For debugging purposes, I would like to delay the start of plymouth
> until after my stuff is done, so I can see console output.
Plymouth has a text theme (plugin) that essentially would show the
console messages. A simpler way - just press escape when plymouth
starts! There is some info on Plymouth here:
https://wiki.ubuntu.com/Plymouth
At this point
> I have disabled plymouth with plymouth.override, but I don't think that
> is right. Do I change plymouth to "start on (starting mountall and
> started diskless)" ?
>
> - The --verbose flag to init is great and produces wonderful debugging
> output. Unfortunately, it scrolls off the top of the screen before I can
> see much of what I want. Is there a way to have that sent to a log file?
Boot with console=tty[S]0 and then either use a serial console link for
a physical system or facilities in VM systems like qemu/kvm? Or you
could use rsyslog rules to log all upstart syslog entries to some other
(possibly remote) file.
> At one point I thought I saw a boot.log with upstart info in it, but not
> anymore.
This is because you disabled plymouth, which creates /var/log/boot.log
Note that I mount an in-memory fs on /var during
> rc.initdiskless, so upstart would have to re-open its log file if it
> opened it earlier.
Upstart does not open any log files - it uses the standard Unix syslog
interface (via the NIH Utility Library - https://launchpad.net/libnih).
>
> Thank you kindly for any help and advice. If there is a different place
> I should ask please let me know. I posted some of this in the ubuntu
> forums:
>
> http://ubuntuforums.org/showthread.php?p=10672011
>
> - Alex Aminoff
> BaseSpace.net
> National Bureau of Economic Research (nber.org)
>
> P.S. I just had a brainstorm. Would it be totally crazy to mv sbin/init
> to sbin/init.real and then have a small shell script that calls
> rc.initdiskless then runs init?
As already stated, you could do this as long as your script "execs"
Upstart (it must start as PID 1).
>
>
>
>
>
Kind regards,
James.
- --
James Hunt
____________________________________
Ubuntu Foundations Team, Canonical.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk2lzooACgkQYBWEaHcQG9f+WQCfUL1rM5wFGD9rZexr+pbIjBC0
muYAnAmIh1SmMACGqmDem6rY8V7wG8Qt
=ASZI
-----END PGP SIGNATURE-----
More information about the upstart-devel
mailing list