Re: [vserver] Running Linux Vserver on Wheezy Host and Guests

From: <senrabdet_at_aol.com>
Date: Sat 10 Aug 2013 - 16:21:54 BST
Message-Id: <8D063F47ABBA8E6-1C24-EEB4@webmail-d245.sysops.aol.com>

Hi All:

Progress! Thanks to Adrian, Ben & Andrew. Got Wheezy Guest with Gnome to run on Wheezy Host. Have been stuck on this for a long time, so am really psyched (and thanks thanks thanks) to be able to continue to use Vserver on Wheezy. Some notes:

1) Did fresh Wheezy install
2) Per http://repo.psand.net/info/, followed instructions with one addition. After installing "util-vserver", also installed "util-vserver-tools". Not sure if need to do both, but adding in the "apt-get install -y util-vserver-tools" made a lot of difference (was missing vserver-build scripts otherwise).
3) Had had lots of trouble getting Gnome to go into Wheezy guest (had been using Squeeze hosts and guests)....per Adrian's suggestion shown below (after these notes), replaced mountkernfs with dummyservices, and used header from Adrian's suggestion to replace headers in mountdevsubfs.sh and udev. Not sure if I'm causing myself problems down stream, but suddenly Gnome installed(!).

So using Adrian's "update-rc.d dummyservices defaults" approach shown below (his "typed this up from memory" pretty impressive), replaced each script/script header and voila. The reason to only replace headers in mountdevsubfs.sh and udev (I think, though would like to know if I'm wrong on this) is that mountdevsubfs.sh and udev scripts have additional code that is needed.

PS: have been messing around getting Vserver to work with pacemaker/heartbeat, and header/LSB stuff also a problem there so if make progress will pass it along.

FYI: here is a copy of each script that seems to work so far...

1) dummservices (was mountkernfs)

#! /bin/sh
### BEGIN INIT INFO
# Provides: mountkernfs
# Required-Start:
# Required-Stop:
# Should-Start:
# Default-Start: S
# Default-Stop:
# Short-Description: Make ignorant dependency builders happy
# Description: Dependencies are not always what the should be like in our setup
### END INIT INFO

2) mountdevsubfs.sh (again, only replaced header to leave remaining script intact)

#! /bin/sh
### BEGIN INIT INFO
# Provides: mountdevsubfs
# Required-Start:
# Required-Stop:
# Should-Start:
# Default-Start: S
# Default-Stop:
# Short-Description: Make ignorant dependency builders happy
# Description: Dependencies are not always what the should be like in our setup
### END INIT INFO
#
# This script gets called multiple times during boot
#

PATH=/sbin:/bin
TTYGRP=5
TTYMODE=620
[ -f /etc/default/devpts ] && . /etc/default/devpts

KERNEL="$(uname -s)"

. /lib/init/vars.sh
. /lib/init/tmpfs.sh

. /lib/lsb/init-functions
. /lib/init/mount-functions.sh

# May be run several times, so must be idempotent.
# $1: Mount mode, to allow for remounting and mtab updating
mount_filesystems () {
        MNTMODE="$1"

        # Mount a tmpfs on /run/shm
        mount_shm "$MNTMODE"

        # Mount /dev/pts
        if [ "$KERNEL" = Linux ]
        then
                if [ ! -d /dev/pts ]
                then
                        mkdir --mode=755 /dev/pts
                        [ -x /sbin/restorecon ] && /sbin/restorecon /dev/pts
                fi
                domount "$MNTMODE" devpts "" /dev/pts devpts "-onoexec,nosuid,gid=$TTYGRP,mode=$TTYMODE"
        fi
}

case "$1" in
  "")
        echo "Warning: mountdevsubfs should be called with the 'start' argument." >&2
        mount_filesystems mount_noupdate
        ;;
  start)
        mount_filesystems mount_noupdate
        ;;
  mtab)
        mount_filesystems mtab
        ;;
  restart|reload|force-reload)
        mount_filesystems remount
        ;;
  stop)
        # No-op
        ;;
  *)
        echo "Usage: mountdevsubfs [start|stop]" >&2
        exit 3
        ;;
esac

3) udev (again, only replaced header and left rest of script intact)

#!/bin/sh -e
### BEGIN INIT INFO
# Provides: udev
# Required-Start:
# Required-Stop:
# Default-Start: S
# Default-Stop:
# Short-Description: Make ignorant dependency builders happy
# Description: Dependencies are not always what the should be like in our setup
### END INIT INFO

# we need to unmount /dev/pts/ and remount it later over the tmpfs
unmount_devpts() {
  if mountpoint -q /dev/pts/; then
    umount -n -l /dev/pts/
  fi

  if mountpoint -q /dev/shm/; then
    umount -n -l /dev/shm/
  fi
}

# mount a tmpfs over /dev, if somebody did not already do it
mount_tmpfs() {
  if grep -E -q "^[^[:space:]]+ /dev (dev)?tmpfs" /proc/mounts; then
    mount -n -o remount,${dev_mount_options} -t tmpfs tmpfs /dev
    return
  fi

  if ! mount -n -o $dev_mount_options -t tmpfs tmpfs /dev; then
    log_failure_msg "udev requires tmpfs support, not started"
    log_end_msg 1
  fi

  return 0
}

create_dev_makedev() {
  if [ -e /sbin/MAKEDEV ]; then
    ln -sf /sbin/MAKEDEV /dev/MAKEDEV
  else
    ln -sf /bin/true /dev/MAKEDEV
  fi
}

# If the initramfs does not have /run, the initramfs udev database must
# be migrated from /dev/.udev/ to /run/udev/.
move_udev_database() {
  [ -e "$udev_root/.udev/" ] || return 0
  [ ! -e /run/udev/ ] || return 0
  [ -e /run/ ] || return 0
  mountpoint -q /run/ || return 0

  mv $udev_root/.udev/ /run/udev/ || true
}

supported_kernel() {
  case "$(uname -r)" in
    2.[012345].*|2.6.[0-9]|2.6.[0-9][!0-9]*) return 1 ;;
    2.6.[12][0-9]|2.6.[12][0-9][!0-9]*) return 1 ;;
    2.6.3[0-1]|2.6.3[0-1][!0-9]*) return 1 ;;
  esac
  return 0
}

# shell version of /usr/bin/tty
my_tty() {
  [ -x /bin/readlink ] || return 0
  [ -e /proc/self/fd/0 ] || return 0
  readlink --silent /proc/self/fd/0 || true
}

warn_if_interactive() {
  if [ "$RUNLEVEL" = "S" -a "$PREVLEVEL" = "N" ]; then
    return
  fi

  TTY=$(my_tty)
  if [ -z "$TTY" -o "$TTY" = "/dev/console" -o "$TTY" = "/dev/null" ]; then
    return
  fi

  printf "\n\n\nIt has been detected that the command\n\n\t$0 $*\n\n"
  printf "has been run from an interactive shell.\n"
  printf "It will probably not do what you expect, so this script will wait\n"
  printf "60 seconds before continuing. Press ^C to stop it.\n"
  printf "RUNNING THIS COMMAND IS HIGHLY DISCOURAGED!\n\n\n\n"
  sleep 60
}

##############################################################################

[ -x /sbin/udevd ] || exit 0

PATH="/sbin:/bin"

# defaults
tmpfs_size="10M"
udev_root="/dev"

if [ -e /etc/udev/udev.conf ]; then
  . /etc/udev/udev.conf
fi

. /lib/lsb/init-functions

if ! supported_kernel; then
  log_failure_msg "udev requires a kernel >= 2.6.32, not started"
  log_end_msg 1
fi

if [ ! -e /proc/filesystems ]; then
  log_failure_msg "udev requires a mounted procfs, not started"
  log_end_msg 1
fi

if ! grep -q '[[:space:]]tmpfs$' /proc/filesystems; then
  log_failure_msg "udev requires tmpfs support, not started"
  log_end_msg 1
fi

if [ ! -d /sys/class/ ]; then
  log_failure_msg "udev requires a mounted sysfs, not started"
  log_end_msg 1
fi

if [ ! -e /sys/kernel/uevent_helper ]; then
  log_failure_msg "udev requires hotplug support, not started"
  log_end_msg 1
fi

if ! ps --no-headers --format args ax | egrep -q '^\['; then
  log_warning_msg "udev does not support containers, not started"
  exit 0
fi

if [ -d /sys/class/mem/null -a ! -L /sys/class/mem/null ] || \
   [ -e /sys/block -a ! -e /sys/class/block ]; then
  log_warning_msg "CONFIG_SYSFS_DEPRECATED must not be selected"
  log_warning_msg "Booting will continue in 30 seconds but many things will be broken"
  sleep 30
fi

##############################################################################

# this is experimental and may not work well
if [ "$UDEV_DISABLED" = "yes" ]; then
  udev_root=/etc/udev/.dev
  export UDEV_ROOT=$udev_root
fi

udev_root=${udev_root%/}

dev_mount_options='mode=0755'
if [ "$tmpfs_size" ]; then
  dev_mount_options="size=${tmpfs_size},${dev_mount_options}"
fi

if [ "$udev_root" != "/dev" ]; then
  log_warning_msg "udev_root != /dev/"

case "$1" in
    start)
    if init_is_upstart 2>/dev/null; then
        exit 1
    fi
    if mountpoint -q $udev_root/; then
        log_failure_msg "$udev_root is already mounted"
        log_end_msg 1
    fi

    echo > /sys/kernel/uevent_helper

    mount -n -o $dev_mount_options -t tmpfs tmpfs $udev_root

    log_daemon_msg "Starting the hotplug events dispatcher" "udevd"
    if udevd --daemon; then
        log_end_msg $?
    else
        log_warning_msg $?
        log_warning_msg "Waiting 15 seconds and trying to continue anyway"
        sleep 15
    fi

    /lib/udev/write_dev_root_rule

    log_action_begin_msg "Synthesizing the initial hotplug events"
    if udevadm trigger --action=add; then
        log_action_end_msg $?
    else
        log_action_end_msg $?
    fi

    ;;
    stop)
    # make sure a manual invocation of the init script doesn't stop an
    # upstart-controlled instance of udev
    if init_is_upstart 2>/dev/null && status udev | grep -q start; then
        exit 0
    fi
    log_daemon_msg "Stopping the hotplug events dispatcher" "udevd"
    if start-stop-daemon --stop --name udevd --user root --quiet --oknodo --retry 5; then
        log_end_msg $?
    else
        log_end_msg $?
    fi

    log_action_begin_msg "Unmounting $udev_root"
    # unmounting with -l should never fail
    if umount -n -l $udev_root; then
        log_action_end_msg $?
    else
        log_action_end_msg $?
    fi
    ;;

    restart)
    if init_is_upstart 2>/dev/null; then
        exit 1
    fi
    log_daemon_msg "Stopping the hotplug events dispatcher" "udevd"
    if start-stop-daemon --stop --name udevd --user root --quiet --oknodo --retry 5; then
        log_end_msg $?
    else
        log_end_msg $? || true
    fi

    log_daemon_msg "Starting the hotplug events dispatcher" "udevd"
    if udevd --daemon; then
        log_end_msg $?
    else
        log_end_msg $?
    fi
    ;;

    reload|force-reload)
    udevadm control --reload-rules
    ;;

    status)
    status_of_proc /sbin/udevd udevd && exit 0 || exit $?
    ;;

    *)
    echo "Usage: /etc/init.d/udev {start|stop|restart|reload|force-reload|status}" >&2
    exit 1
    ;;
esac

  exit 0
fi # udev_root != /dev

##############################################################################

# When modifying this script, do not forget that between the time that the
# new /dev has been mounted and udevadm trigger has been run there will be
# no /dev/null. This also means that you cannot use the "&" shell command.

case "$1" in
    start)
    if init_is_upstart 2>/dev/null; then
        exit 1
    fi
    if mountpoint -q $udev_root/; then
        TMPFS_MOUNTED=1
    elif [ -e "$udev_root/.udev/" ]; then
        log_warning_msg ".udev/ already exists on the static $udev_root"
    fi

    if [ ! -e "$udev_root/.udev/" -a ! -e "/run/udev/" ]; then
        warn_if_interactive
    fi

    echo > /sys/kernel/uevent_helper

    move_udev_database

    if [ -z "$TMPFS_MOUNTED" ]; then
        unmount_devpts
        mount_tmpfs
        [ -d /proc/1 ] || mount -n /proc
    fi

    # clean up parts of the database created by the initramfs udev
    udevadm info --cleanup-db

    # set the SELinux context for devices created in the initramfs
    [ -x /sbin/restorecon ] && /sbin/restorecon -R /dev

    # /dev/null must be created before udevd is started
    /lib/udev/create_static_nodes || true

    log_daemon_msg "Starting the hotplug events dispatcher" "udevd"
    if udevd --daemon; then
        log_end_msg $?
    else
        log_warning_msg $?
        log_warning_msg "Waiting 15 seconds and trying to continue anyway"
        sleep 15
    fi

    /lib/udev/write_dev_root_rule

    log_action_begin_msg "Synthesizing the initial hotplug events"
    if udevadm trigger --action=add; then
        log_action_end_msg $?
    else
        log_action_end_msg $?
    fi

    create_dev_makedev

    # wait for the udevd childs to finish
    log_action_begin_msg "Waiting for /dev to be fully populated"
    if udevadm settle; then
        log_action_end_msg 0
    else
        log_action_end_msg 0 'timeout'
    fi
    ;;

    stop)
    log_daemon_msg "Stopping the hotplug events dispatcher" "udevd"
    if start-stop-daemon --stop --name udevd --user root --quiet --oknodo --retry 5; then
        log_end_msg $?
    else
        log_end_msg $?
    fi
    ;;

    restart)
    if init_is_upstart 2>/dev/null; then
        exit 1
    fi
    log_daemon_msg "Stopping the hotplug events dispatcher" "udevd"
    if start-stop-daemon --stop --name udevd --user root --quiet --oknodo --retry 5; then
        log_end_msg $?
    else
        log_end_msg $? || true
    fi

    log_daemon_msg "Starting the hotplug events dispatcher" "udevd"
    if udevd --daemon; then
        log_end_msg $?
    else
        log_end_msg $?
    fi
    ;;

    reload|force-reload)
    udevadm control --reload-rules
    ;;

    status)
    status_of_proc /sbin/udevd udevd && exit 0 || exit $?
    ;;

    *)
    echo "Usage: /etc/init.d/udev {start|stop|restart|reload|force-reload|status}" >&2
    exit 1
    ;;
esac

exit 0

-----Original Message-----
From: Adrian Reyer <are@lihas.de>
To: vserver <vserver@list.linux-vserver.org>
Sent: Thu, Aug 8, 2013 4:46 pm
Subject: Re: [vserver] Running Linux Vserver on Wheezy Host and Guests

Hi senrabdet,

On Thu, Aug 08, 2013 at 03:44:44PM -0400, senrabdet@aol.com wrote:
> Q: I'm given to understand this is "doable", but is anyone running Wheezy
guests on a Wheezy host with GUI's installed on the guests? It's at that point
I get stuck....suggestions on what to try here?

I have only one VServer on wheezy running a desktop environment. And
that one has been upgraded from squeeze.

> insserv: Service mountkernfs has to be enabled to start service keyboard-setup
> update-rc.d: error: insserv rejected the script header

There's the issue:
you could either try and remove 'Required-Start: mountkernfs' from
/etc/init.d/keyboard-setup which might be tricky as it is just aout to
be installed, or you might try and provide a very basic
/etc/init.d/dummyservices similar to this (just c&p):
cat <<EOF >/etc/init.d/dummyservices
#! /bin/sh
### BEGIN INIT INFO
# Provides: mountkernfs
# Required-Start:
# Required-Stop:
# Should-Start:
# Default-Start: S
# Default-Stop:
# Short-Description: Make ignorant dependency builders happy
# Description: Dependencies are not always what the should be like in our
setup
### END INIT INFO
exit 0
EOF
chmod +x /etc/init.d/dummyservices
update-rc.d dummyservices default

Untested, just typed by heart.

Regards,
        Adrian

-- 
LiHAS - Adrian Reyer - Hessenwiesenstraße 10 - D-70565 Stuttgart
Fon: +49 (7 11) 78 28 50 90 - Fax:  +49 (7 11) 78 28 50 91
Mail: lihas_at_lihas.de - Web: http://lihas.de
Linux, Netzwerke, Consulting & Support - USt-ID: DE 227 816 626 Stuttgart
 
Received on Sat Aug 10 16:22:08 2013
[Next/Previous Months] [Main vserver Project Homepage] [Howto Subscribe/Unsubscribe] [Paul Sladen's vserver stuff]
Generated on Sat 10 Aug 2013 - 16:22:08 BST by hypermail 2.1.8