http://linux-vserver.org/api.php?action=feedcontributions&user=Jakobsg&feedformat=atomLinux-VServer - User contributions [en]2024-03-29T10:40:56ZUser contributionsMediaWiki 1.20.2http://linux-vserver.org/Upstart_issuesUpstart issues2010-11-01T11:50:58Z<p>Jakobsg: /* Running Ubuntu Lucid */</p>
<hr />
<div>== Running Ubuntu Lucid ==<br />
<br />
There's a inipost-file ( http://static.thedudes.org/initpost ) that can be used when creating hosts, so there's no need for manual tweaking. <br />
Put it in <pre>/usr/lib/util-vserver/distributions/lucid</pre> Install the vserver with --initstyle plain. You still need to look over services when installing since we're tweaking Upstarts normal emits.<br />
<br />
!! Note !! The inipost-file is missing. You can temporarely download it from: http://dl.dropbox.com/u/1171189/initpost<br />
<br />
And more permanently here: http://capa-support.mikrov.dk/downloads/initpost<br />
<br />
You can also have a look at http://wiki.raceme.org/dokuwiki/tof:computer:vserver:upstart_ubuntu_lucid for a manual procedure.<br />
<br />
== Running an upstart based guest ==<br />
<br />
currently upstart based guests need some manual tweaking to make them work inside a vserver guest.<br />
<br />
=== Prepare the host ===<br />
First of all you need to set the init style of your vserver to plain<br />
# echo plain > /etc/vservers/<vservername>/apps/init/style<br />
<br />
Or use '--initstyle plain' when creating the host.<br />
<br />
I'd also strongly recommend to mount <code>/var/run</code> and <code>/var/lock</code> of the guest as tmpfs. So add the following lines to<br />
<code>/etc/vservers/<vservername>/fstab</code><br />
none /var/run tmpfs size=16m,nosuid,mode=0755 0 0<br />
none /var/lock tmpfs size=16m,noexec,nosuid,nodev 0 0<br />
<br />
=== Remove low level services inside the guest ===<br />
Then you need to get rid of anything in <code>/etc/init/</code> that tries to fiddle with your Server's Hardware or other low-level Stuff that's already handled by your host's kernel/system. Having one such scriptlet still enabled might cause the whole upstart system to fail (like not beeing able to open <code>/dev/console</code> or failing to start the udev system).<br />
Just remove these scriptlets, move them out of the way or rename them to something not ending in <code>.conf</code>. Be aware that upstart also parses subfolders of <code>/etc/init/</code> for <code>.conf</code> files.<br />
<br />
This is what I deleted on a basic Ubuntu 9.10 guest:<br />
dmesg.conf<br />
hostname.conf<br />
hwclock-save.conf<br />
hwclock.conf<br />
mountall-net.conf<br />
mountall-reboot.conf<br />
mountall-shell.conf<br />
mountall.conf<br />
network-interface.conf<br />
networking.conf<br />
procps.conf<br />
rsyslog-kmsg.conf<br />
tty1.conf<br />
tty2.conf<br />
tty3.conf<br />
tty4.conf<br />
tty5.conf<br />
tty6.conf<br />
upstart-udev-bridge.conf<br />
<br />
In Ubuntu 10.04 you also want to remove:<br />
console-setup.conf <br />
<br />
=== Services you want to look over ===<br />
There are files in the /etc/init dir that you want to check the startup line of.<br />
It could be waiting for something that will never happend since it is in a VServer and thus never start.<br />
<br />
for example mysql.conf needs a 'net-device-up'-emit also.<br />
by running<br />
vserver <name> exec initctl emit net-device-up<br />
<br />
it will come up like a charm.<br />
Either put this in vserver.conf or remove in from mysql.conf.<br />
<br />
Jobs that doesn't start from scratch:<br />
mysql-server-5.1 (mysql.conf)<br />
<br />
=== Fake low level events inside the guest ===<br />
Finally you need to fake emit the events that some of these scripts would do during regular boot. Probably the cleanest approach is to add a scriptlet <code>vserver.conf</code> to <code>/etc/init/</code> with this content:<br />
start on startup<br />
script<br />
touch /var/run/utmp<br />
chown root:utmp /var/run/utmp<br />
chmod 664 /var/run/utmp<br />
initctl emit virtual-filesystems<br />
initctl emit local-filesystems<br />
initctl emit remote-filesystems<br />
initctl emit filesystem<br />
end script<br />
<br />
The utmp stuff is needed if you mount <code>/var/run</code> as tmpfs and you don't create utmp anywhere else.<br />
<br />
=== Remove console outputs ===<br />
<br />
If your VServer hangs on the command<br />
vserver <name> stop<br />
<br />
and puts out<br />
A timeout occured while waiting for the vserver to finish and it will<br />
be killed by sending a SIGKILL signal. The following process list<br />
might be useful for finding out the reason of this behavior:<br />
<br />
----------------------------------------------------------------------<br />
<pid> <context> <name> ? Ss 0:00 /sbin/init<br />
<pid> <context> <name> ? Ss 0:00 /sbin/init<br />
----------------------------------------------------------------------<br />
<br />
you should run<br />
sed -i 's/^\(console output\)$/#\1/1' /etc/vservers/$name/vdir/etc/init/*<br />
<br />
which will disable all lines with 'console output', and Upstart won't try output to it. Which is a good thing since it doesn't exist.<br />
<br />
=== Adapt /etc/init/rc-sysinit.conf inside the guest ===<br />
<br />
This depends on net-device-up IFACE=lo, remove this from the start line so that it reads:<br/><br />
<code>start on filesystem</code><br />
<br />
This scriptlet tries to parse <code>/proc/cmdline</code> which will not work and probably isn't needed inside a vserver.<br/><br />
Simply comment out or delete the whole <code>for ARG in $(cat /proc/cmdline) do...done</code> loop.<br />
<br />
=== Notes for debugging ===<br />
<br />
First you need to run Upstart with the --debug flag,<br />
one way of doing it is inserting<br />
"--debug"<br />
in INITCMD_START under the xplain-clause inside /usr/lib/util-vserver/vserver.functions (row 316 here)<br />
so it reads INITCMD_START=( /sbin/init "--debug" )<br />
<br />
Second you should enable console output in the rc-files inside /etc/init, if you had commented them out before you could do<br />
sed -i 's/#^\(console output\)$/\1/1' /etc/vservers/$name/vdir/etc/init/*<br />
<br />
Third you need a device to act as console, I used tty0.<br />
cp -a /dev/tty0 /etc/vservers/$name/vdir/dev/console<br />
<br />
If you do things at a console of the machine it will now print out detailed information. More on how to debug a Upstart job you'll find on http://upstart.ubuntu.com/wiki/Debugging.<br />
Notice that if one fails they all fail.<br />
<br />
=== Notes for older kernels ===<br />
If you encounter upstart errors like this:<br />
<br />
$ vserver foo start<br />
init: missing runlevel<br />
Try `init --help' for more information.<br />
<br />
or<br />
<br />
$ vserver foo start<br />
telinit: Failed to connect to socket /com/ubuntu/upstart: Connection refused<br />
<br />
then you're probably running the current stable version <code>2.6.22.19-vs2.2.0.7</code>.<br />
<br />
Upstart's <code>/sbin/init</code> implementation requires to be PID 1. It is linked against NPTL (in contrast to sysvinit), which has a bug in it's caching <code>getpid(2)</code> wrapper. With this kernel version <code>getpid(2)</code> returns the cached PID to init, resulting in init replacing itself with telinit. You can fix this by upgrading to a <code>2.6.26+</code> kernel and a newer vserver patch, or by patching upstart:<br />
<br />
diff --git a/init/main.c b/init/main.c<br />
index bfcd528..c6c9304 100644<br />
--- a/init/main.c<br />
+++ b/init/main.c<br />
@@ -37,6 +37,7 @@<br />
#include <string.h><br />
#include <syslog.h><br />
#include <unistd.h><br />
+#include <syscall.h><br />
<br />
#include <linux/kd.h><br />
<br />
@@ -131,7 +132,7 @@ main (int argc,<br />
}<br />
<br />
/* Check we're process #1 */<br />
- if (getpid () > 1) {<br />
+ if (syscall(SYS_getpid) > 1) {<br />
execv (TELINIT, argv);<br />
/* Ignore failure, probably just that telinit doesn't exist */<br />
<br />
For more information see the man pages of <code>getpid(2)</code> (NOTES) and <code>clone(2)</code> (BUGS).<br />
<br />
=== Init procedure doesn't complete ===<br />
==== SSH ====<br />
If you've completed all above steps and some init scripts doesn't get invoked at all (most notably old SYSV init scripts) you might have encountered same error that I did.<br />
In Lucid guest I had to comment out following line in /etc/init/ssh.conf:<br />
# replaces SSHD_OOM_ADJUST in /etc/default/ssh<br />
oom never<br />
to<br />
# replaces SSHD_OOM_ADJUST in /etc/default/ssh<br />
#oom never<br />
<br />
After commenting out this line initialization completed successfully.<br />
<br />
==== D-BUS ====<br />
When creating guest as chroot some packages you might expect are missing. One of these is D-BUS. Strangely enough the /etc/init/dbus.conf gets installed which prevents Upstart to finish its starting sequence.<br />
<br />
Solution: install dbus package<br />
<br />
sudo aptitude install dbus</div>Jakobsghttp://linux-vserver.org/Upstart_issuesUpstart issues2010-10-01T07:35:26Z<p>Jakobsg: /* Running Ubuntu Lucid */</p>
<hr />
<div>== Running Ubuntu Lucid ==<br />
<br />
There's a inipost-file ( http://static.thedudes.org/initpost ) that can be used when creating hosts, so there's no need for manual tweaking. <br />
Put it in <pre>/usr/lib/util-vserver/distributions/lucid</pre> Install the vserver with --initstyle plain. You still need to look over services when installing since we're tweaking Upstarts normal emits.<br />
<br />
!! Note !! The inipost-file is missing, can someone provide a new one?<br />
<br />
You can also have a look at http://wiki.raceme.org/dokuwiki/tof:computer:vserver:upstart_ubuntu_lucid for a manual procedure.<br />
<br />
== Running an upstart based guest ==<br />
<br />
currently upstart based guests need some manual tweaking to make them work inside a vserver guest.<br />
<br />
=== Prepare the host ===<br />
First of all you need to set the init style of your vserver to plain<br />
# echo plain > /etc/vservers/<vservername>/apps/init/style<br />
<br />
Or use '--initstyle plain' when creating the host.<br />
<br />
I'd also strongly recommend to mount <code>/var/run</code> and <code>/var/lock</code> of the guest as tmpfs. So add the following lines to<br />
<code>/etc/vservers/<vservername>/fstab</code><br />
none /var/run tmpfs size=16m,nosuid,mode=0755 0 0<br />
none /var/lock tmpfs size=16m,noexec,nosuid,nodev 0 0<br />
<br />
=== Remove low level services inside the guest ===<br />
Then you need to get rid of anything in <code>/etc/init/</code> that tries to fiddle with your Server's Hardware or other low-level Stuff that's already handled by your host's kernel/system. Having one such scriptlet still enabled might cause the whole upstart system to fail (like not beeing able to open <code>/dev/console</code> or failing to start the udev system).<br />
Just remove these scriptlets, move them out of the way or rename them to something not ending in <code>.conf</code>. Be aware that upstart also parses subfolders of <code>/etc/init/</code> for <code>.conf</code> files.<br />
<br />
This is what I deleted on a basic Ubuntu 9.10 guest:<br />
dmesg.conf<br />
hostname.conf<br />
hwclock-save.conf<br />
hwclock.conf<br />
mountall-net.conf<br />
mountall-reboot.conf<br />
mountall-shell.conf<br />
mountall.conf<br />
network-interface.conf<br />
networking.conf<br />
procps.conf<br />
rsyslog-kmsg.conf<br />
tty1.conf<br />
tty2.conf<br />
tty3.conf<br />
tty4.conf<br />
tty5.conf<br />
tty6.conf<br />
upstart-udev-bridge.conf<br />
<br />
In Ubuntu 10.04 you also want to remove:<br />
console-setup.conf <br />
<br />
=== Services you want to look over ===<br />
There are files in the /etc/init dir that you want to check the startup line of.<br />
It could be waiting for something that will never happend since it is in a VServer and thus never start.<br />
<br />
for example mysql.conf needs a 'net-device-up'-emit also.<br />
by running<br />
vserver <name> exec initctl emit net-device-up<br />
<br />
it will come up like a charm.<br />
Either put this in vserver.conf or remove in from mysql.conf.<br />
<br />
Jobs that doesn't start from scratch:<br />
mysql-server-5.1 (mysql.conf)<br />
<br />
=== Fake low level events inside the guest ===<br />
Finally you need to fake emit the events that some of these scripts would do during regular boot. Probably the cleanest approach is to add a scriptlet <code>vserver.conf</code> to <code>/etc/init/</code> with this content:<br />
start on startup<br />
script<br />
touch /var/run/utmp<br />
chown root:utmp /var/run/utmp<br />
chmod 664 /var/run/utmp<br />
initctl emit virtual-filesystems<br />
initctl emit local-filesystems<br />
initctl emit remote-filesystems<br />
initctl emit filesystem<br />
end script<br />
<br />
The utmp stuff is needed if you mount <code>/var/run</code> as tmpfs and you don't create utmp anywhere else.<br />
<br />
=== Remove console outputs ===<br />
<br />
If your VServer hangs on the command<br />
vserver <name> stop<br />
<br />
and puts out<br />
A timeout occured while waiting for the vserver to finish and it will<br />
be killed by sending a SIGKILL signal. The following process list<br />
might be useful for finding out the reason of this behavior:<br />
<br />
----------------------------------------------------------------------<br />
<pid> <context> <name> ? Ss 0:00 /sbin/init<br />
<pid> <context> <name> ? Ss 0:00 /sbin/init<br />
----------------------------------------------------------------------<br />
<br />
you should run<br />
sed -i 's/^\(console output\)$/#\1/1' /etc/vservers/$name/vdir/etc/init/*<br />
<br />
which will disable all lines with 'console output', and Upstart won't try output to it. Which is a good thing since it doesn't exist.<br />
<br />
=== Adapt /etc/init/rc-sysinit.conf inside the guest ===<br />
<br />
This depends on net-device-up IFACE=lo, remove this from the start line so that it reads:<br/><br />
<code>start on filesystem</code><br />
<br />
This scriptlet tries to parse <code>/proc/cmdline</code> which will not work and probably isn't needed inside a vserver.<br/><br />
Simply comment out or delete the whole <code>for ARG in $(cat /proc/cmdline) do...done</code> loop.<br />
<br />
=== Notes for debugging ===<br />
<br />
First you need to run Upstart with the --debug flag,<br />
one way of doing it is inserting<br />
"--debug"<br />
in INITCMD_START under the xplain-clause inside /usr/lib/util-vserver/vserver.functions (row 316 here)<br />
so it reads INITCMD_START=( /sbin/init "--debug" )<br />
<br />
Second you should enable console output in the rc-files inside /etc/init, if you had commented them out before you could do<br />
sed -i 's/#^\(console output\)$/\1/1' /etc/vservers/$name/vdir/etc/init/*<br />
<br />
Third you need a device to act as console, I used tty0.<br />
cp -a /dev/tty0 /etc/vservers/$name/vdir/dev/console<br />
<br />
If you do things at a console of the machine it will now print out detailed information. More on how to debug a Upstart job you'll find on http://upstart.ubuntu.com/wiki/Debugging.<br />
Notice that if one fails they all fail.<br />
<br />
=== Notes for older kernels ===<br />
If you encounter upstart errors like this:<br />
<br />
$ vserver foo start<br />
init: missing runlevel<br />
Try `init --help' for more information.<br />
<br />
or<br />
<br />
$ vserver foo start<br />
telinit: Failed to connect to socket /com/ubuntu/upstart: Connection refused<br />
<br />
then you're probably running the current stable version <code>2.6.22.19-vs2.2.0.7</code>.<br />
<br />
Upstart's <code>/sbin/init</code> implementation requires to be PID 1. It is linked against NPTL (in contrast to sysvinit), which has a bug in it's caching <code>getpid(2)</code> wrapper. With this kernel version <code>getpid(2)</code> returns the cached PID to init, resulting in init replacing itself with telinit. You can fix this by upgrading to a <code>2.6.26+</code> kernel and a newer vserver patch, or by patching upstart:<br />
<br />
diff --git a/init/main.c b/init/main.c<br />
index bfcd528..c6c9304 100644<br />
--- a/init/main.c<br />
+++ b/init/main.c<br />
@@ -37,6 +37,7 @@<br />
#include <string.h><br />
#include <syslog.h><br />
#include <unistd.h><br />
+#include <syscall.h><br />
<br />
#include <linux/kd.h><br />
<br />
@@ -131,7 +132,7 @@ main (int argc,<br />
}<br />
<br />
/* Check we're process #1 */<br />
- if (getpid () > 1) {<br />
+ if (syscall(SYS_getpid) > 1) {<br />
execv (TELINIT, argv);<br />
/* Ignore failure, probably just that telinit doesn't exist */<br />
<br />
For more information see the man pages of <code>getpid(2)</code> (NOTES) and <code>clone(2)</code> (BUGS).<br />
<br />
=== Init procedure doesn't complete ===<br />
==== SSH ====<br />
If you've completed all above steps and some init scripts doesn't get invoked at all (most notably old SYSV init scripts) you might have encountered same error that I did.<br />
In Lucid guest I had to comment out following line in /etc/init/ssh.conf:<br />
# replaces SSHD_OOM_ADJUST in /etc/default/ssh<br />
oom never<br />
to<br />
# replaces SSHD_OOM_ADJUST in /etc/default/ssh<br />
#oom never<br />
<br />
After commenting out this line initialization completed successfully.<br />
<br />
==== D-BUS ====<br />
When creating guest as chroot some packages you might expect are missing. One of these is D-BUS. Strangely enough the /etc/init/dbus.conf gets installed which prevents Upstart to finish its starting sequence.<br />
<br />
Solution: install dbus package<br />
<br />
sudo aptitude install dbus</div>Jakobsg