OpenVZ Ubuntu 9.10 Templates

Note: This blog post has been completely re-written, thanks to Stephane Graber (see coment #1).

Although Ubuntu has been working well in OpenVZ, recently the boot scripts are no longer working.

You may make a template as outlined here, but the guest will not start properly.

Fortunately they can be started by writing an init script.

Save the following script, in your Ubuntu 9.10 VE (NOT the host node) as /etc/init/openvz.conf

# OpenVZ – Fix init sequence to have OpenVZ working with upstart

description “Fix OpenVZ”

start on startup

task
pre-start script
mount -t proc proc /proc
mount -t devpts devpts /dev/pts
mount -t sysfs sys /sys
mount -t tmpfs varrun /var/run
mount -t tmpfs varlock /var/lock
mkdir -p /var/run/network
touch /var/run/utmp
chmod 664 /var/run/utmp
chown root.utmp /var/run/utmp
if [ "$(find /etc/network/ -name upstart -type f)" ]; then
chmod -x /etc/network/*/upstart || true
fi
end script

script
start networking
initctl emit filesystem –-no-wait
initctl emit local-filesystems –-no-wait
initctl emit virtual-filesystems –-no-wait
init 2
end script

Note: you need two “– -” with the “initctl emit filesystem –-no-wait” lines

This init script works perfectly with my ubuntu templates, if you have difficulty, see Stephane Graber’s comment.

This entry was posted in Linux. Bookmark the permalink.

16 Responses to OpenVZ Ubuntu 9.10 Templates

  1. I’ve developed that simple init script for upstart to fix that kind of issue, works great here:

    # OpenVZ – Fix init sequence to have OpenVZ working with upstart

    description “Fix OpenVZ”

    start on startup

    task
    pre-start script
    mount -t proc proc /proc
    mount -t devpts devpts /dev/pts
    mount -t sysfs sys /sys
    mount -t tmpfs varrun /var/run
    mount -t tmpfs varlock /var/lock
    mkdir -p /var/run/network
    cat /proc/mounts > /etc/mtab
    touch /var/run/utmp
    chmod 664 /var/run/utmp
    chown root.utmp /var/run/utmp
    if [ "$(find /etc/network/ -name upstart -type f)" ]; then
    chmod -x /etc/network/*/upstart || true
    fi
    end script

    script
    start networking
    initctl emit filesystem –no-wait
    initctl emit local-filesystems –no-wait
    initctl emit virtual-filesystems –no-wait
    init 2
    end script

  2. Pingback: Bodhi.Zazen: OpenVZ Ubuntu 9.10 Templates | TuxWire : The Linux Blog

  3. bodhi.zazen says:

    THANK YOU Stephane Graber !!!

    If you look at my templates, I do some of this already, in particular:

    ln -s /proc/mounts /etc/mtab

    So …

    I made an upstart script, /etc/init/openvz.conf

    # OpenVZ – Fix init sequence to have OpenVZ working with upstart

    description “Fix OpenVZ”

    start on startup

    task
    pre-start script
    mount -t proc proc /proc
    mount -t devpts devpts /dev/pts
    mount -t sysfs sys /sys
    mount -t tmpfs varrun /var/run
    mount -t tmpfs varlock /var/lock
    mkdir -p /var/run/network
    touch /var/run/utmp
    chmod 664 /var/run/utmp
    chown root.utmp /var/run/utmp
    if [ "$(find /etc/network/ -name upstart -type f)" ]; then
    chmod -x /etc/network/*/upstart || true
    fi
    end script

    script
    start networking
    initctl emit filesystem – -no-wait
    initctl emit local-filesystems – -no-wait
    initctl emit virtual-filesystems – -no-wait
    init 2
    end script

    Note: you need two – - with the “initctl emit filesystem – -no-wait” lines

  4. Pingback: Windows 7 is ‘Restrictive’ for Netbooks and Claims as Linux Rival

  5. Bodhi,

    Copying the script that you posted into /etc/init/openvz.conf doesn’t work on boot. The commands are right and work if exec on the host node. So am I missing some kind of step?

  6. bodhi.zazen says:

    Those commands are for the Guest (VPS) not the host node.

    I use my own templates for Ubuntu, as outlined here :

    http://blog.bodhizazen.net/linux/openvz-ubuntu-templates/

    Stephane Graber posted his script, which I modified.

    Without further information I would be guessing.

    1. Make sure the script is on the GUEST VS in /etc/init/ (NOT /etc/init.d )

    2. The script does not need to be executable, but it does need to end with a .conf (thus I called it openvz.conf )

    3. When copy – paste from WordPress, some of the special symbols get changed, so confirm the syntax especially watch two – - .

    4. I you wish, I posted the script here :

    Note updated links

    http://bodhizazen.net/adblock/openvz.conf.ubuntu-9.10

    you can, in the guest

    cd /etc/init/
    wget http://bodhizazen.net/adblock/openvz.conf.ubuntu-9.10

    5. Run the script manually and see if you get errors :

    service openvz start

  7. Pingback: Bodhi.Zazen: Download Ubuntu 9.10 OpenVZ Templates | L&C Tech Talk

  8. Philon says:

    Thanks! That just saved my day… I tried Copy&Paste first, but did not work with the double –. The wget worked just fine…

  9. Alexander says:

    I upgraded a container running Ubuntu 9.04 and afterwards, I was getting errors about tty devices and networking didn’t work. After several hours of trying to hunt down the sources of the problems, I came across your blog. You instructions on how to create a 9.10 template and this config file fixed all the problems my container had. Thanks you!!

  10. SOL-Invictus says:

    Thanks for your bug-report and this helpful blog-entry. i managed to apt-get dist-upgrade from ubuntu 9.04 to 9.10 and get it working again and get rid of this message:

    # vzctl enter 1234
    enter into VE 1234 failed
    Unable to open pty: No such file or directory

    when i wanted to dist-upgrade to ubuntu 10.04 sadly i got this problem again. i wrote about the problem on https://bugs.launchpad.net/openvz-kernel/+bug/436130 also.

    this is a serious problem and very easy to reproduce:
    on an openvz host try to install one of the ubuntu templates from here: http://wiki.openvz.org/Download/template/precreated
    i tried with ubuntu-9.10-x86.tar.gz and ubuntu-9.04-i386-minimal.tar.gz

    when you change the /etc/apt/sources.list to the next distribution and perform an apt-get update && apt-get dist-upgrade the container will hang on next reboot,

    # vzctl enter 1234
    enter into VE 1234 failed
    Unable to open pty: No such file or directory

    the dist-upgrade to ubuntu 9.10 was working with the script from here, but not anymore with the dist-upgrade to ubuntu 10.04.

  11. SOL-Invictus says:

    Stephane Graber already has a fix for his script for Ubuntu 10.04 Lucid, as written in the bug-report (https://bugs.launchpad.net/openvz-kernel/+bug/436130 ) :
    “Simply edit /etc/init/openvz.conf and remove the two mount lines
    for /proc and /sys”

    Thanks! :)

  12. bodhi.zazen says:

    I have not looked at 10.04 much yet, but appreciate your bug report as well as Stephane Graber , his patience , and his Upstart scripts, which I have shamelessly copied.

    I did have to modify his script for 9.10, and will look at 10.04 in the next few weeks.

  13. Miha says:

    For the past couple of days I’m trying to creade a fresh Lucid template but without much success. The updated openvz.conf seems to get me a bit closer but still no luck.
    I’m getting following in the init.log
    libudev: init: hwclock main process (20) terminated with status 77
    init: ureadahead main process (21) terminated with status 5
    libudev: udev_monitor_new_from_netlink: error getting socket: Invalid argument
    mountall:mountall.c:3181: Assertion failed in main: udev_monitor = udev_monitor_new_from_netlink (udev, “udev”)
    init: openvz pre-start process (17) terminated with status 1
    init: mountall main process (27) killed by ABRT signal
    General error mounting filesystems.
    A maintenance shell will now be started.
    CONTROL-D will terminate this shell and reboot the system.

    The problematic one being udev one..
    It seems that this is reported https://bugs.launchpad.net/ubuntu/+source/mountall/+bug/516684 but marked as won’t fix as same as https://bugs.launchpad.net/ubuntu/+source/mountall/+bug/436130

    Ubuntu devs are becoming a bit too arrogant for my taste. Which is unfortunate if one likes in general what they’ve done.

  14. bodhi.zazen says:

    From my experience with karmic, IMO, it is frustrating to try to use openvz ubuntu templates during the development cycle.

    The ubuntu developers have decided not to support the openvz kernel in lucid and it seems they are not concerned with openvz guests either.

    I suspect this may also affect other similar technologies such as LXC, Xen, and VServer.

    For now my advice is to stay with supported OS such as Debian or Centos.

    Once Lucid is released I may look at creating a 10.04 openvz template.

  15. LS says:

    How to upgrade intalled disk template with Ubuntu 9.04 to 10.04 (beta) and run this as OpenVZ guest system – see this manual, it’s works but with some langs :(

    http://ubuntuforums.org/showthread.php?t=1461992

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>