OpenVZ Forum


Home » General » Support » /dev/pty always gone
/dev/pty always gone [message #26055] Tue, 15 January 2008 00:46 Go to next message
Thomasd is currently offline  Thomasd
Messages: 39
Registered: December 2007
Member
I have a couple VMs that cause always the same problem:

when I try to enter them, I get a dev/pty or dev/pts missing

so, I do vzctl exec <vmid> MAKEDEV /dev/pty

I can enter fine

I stop the VM, restart it...

same problem


How can I make the entries in /dev/ persistant?
Re: /dev/pty always gone [message #26060 is a reply to message #26055] Tue, 15 January 2008 05:36 Go to previous messageGo to next message
vaverin is currently offline  vaverin
Messages: 708
Registered: September 2005
Senior Member
Of course, You can create persistent entries in /dev.
However the ways may be different for various VEs:
- if you do not have udev inside VE -- you can just create according device files directly in /dev/ directory.
- if your VE have running udev in this case you should create device file in some udev's configuration directory.

However I'm not sure that it is the cause of your issue. Could you please check that devpts is mounted inside VE?

Also it may be useful to look here http://wiki.openvz.org/VPS_enter_failed
and please tell us your kernel version.

thank you,
Vasily Averin
Re: /dev/pty always gone [message #26121 is a reply to message #26060] Tue, 15 January 2008 19:22 Go to previous messageGo to next message
Thomasd is currently offline  Thomasd
Messages: 39
Registered: December 2007
Member
This is my kernel version

#uname -r
2.6.18-53.el5.028stab051.1


Devpts is mounted:

# mount
simfs on / type simfs (rw)
/proc on /proc type proc (rw)
/sys on /sys type sysfs (rw)
none on /dev type tmpfs (rw)
none on /dev/pts type devpts (rw)


Is it usually different entries failing:
ptmx and ptyp0 being the most common; sometimes both, sometimes only one.
this is the dev folder of a VM

# ls -l /dev
total 4
lrwxrwxrwx 1 root root     13 Jan 14 19:58 MAKEDEV -> /sbin/MAKEDEV
lrwxrwxrwx 1 root root      4 Jan 14 19:58 X0R -> null
crw------- 1 root root   5, 1 Jan 14 19:58 console
lrwxrwxrwx 1 root root     11 Jan 14 19:58 core -> /proc/kcore
lrwxrwxrwx 1 root root     13 Jan 14 19:58 fd -> /proc/self/fd
prw------- 1 root root      0 Jan 14 19:58 initctl
srw-rw-rw- 1 root root      0 Jan 14 19:58 log
brw-r----- 1 root disk   7, 0 Jan 14 19:58 loop0
brw-r----- 1 root disk   7, 1 Jan 14 19:58 loop1
brw-r----- 1 root disk   7, 2 Jan 14 19:58 loop2
brw-r----- 1 root disk   7, 3 Jan 14 19:58 loop3
brw-r----- 1 root disk   7, 4 Jan 14 19:58 loop4
brw-r----- 1 root disk   7, 5 Jan 14 19:58 loop5
brw-r----- 1 root disk   7, 6 Jan 14 19:58 loop6
brw-r----- 1 root disk   7, 7 Jan 14 19:58 loop7
drwxr-xr-x 2 root root     40 Jan 14 19:58 mapper
drwxr-xr-x 2 root root     60 Jan 14 19:58 net
crw-rw-rw- 1 root root   1, 3 Jan 14 19:58 null
crw-rw---- 1 root lp    99, 0 Jan 14 19:58 parport0
crw-rw---- 1 root lp    99, 1 Jan 14 19:58 parport1
crw-rw---- 1 root lp    99, 2 Jan 14 19:58 parport2
crw-rw---- 1 root lp    99, 3 Jan 14 19:58 parport3
crw------- 1 root root 108, 0 Jan 14 19:58 ppp
crw-rw-rw- 1 root root   5, 2 Jan 15 14:21 ptmx
drwxr-xr-x 2 root root      0 Jan 14 19:58 pts
crw-rw-rw- 1 root tty    2, 0 Jan 14 20:00 ptyp0
drwxr-xr-x 2 root root     40 Jan 14 19:58 shm
lrwxrwxrwx 1 root root     15 Jan 14 19:58 stderr -> /proc/self/fd/2
lrwxrwxrwx 1 root root     15 Jan 14 19:58 stdin -> /proc/self/fd/0
lrwxrwxrwx 1 root root     15 Jan 14 19:58 stdout -> /proc/self/fd/1
crw-rw-rw- 1 root root   5, 0 Jan 14 19:58 tty
-rw-r--r-- 1 root root    512 Jan 14 19:58 urandom
crw-rw-rw- 1 root root   1, 5 Jan 14 19:58 zero


also, it happens on all my VMs, not just one
Re: /dev/pty always gone [message #26135 is a reply to message #26121] Wed, 16 January 2008 07:34 Go to previous messageGo to next message
maratrus is currently offline  maratrus
Messages: 1495
Registered: August 2007
Location: Moscow
Senior Member
Hi,

can you provide us with a little more information

1. What OS on your HN do you use?
2. What kind of templates for your VMs do you use? And where have you got it?
3. Have you upgrade your VM?

And please if you have any additional information concerning your VM please put it here for example 'vzctl --version'

Thank You!
Re: /dev/pty always gone [message #26141 is a reply to message #26135] Wed, 16 January 2008 08:13 Go to previous messageGo to next message
Thomasd is currently offline  Thomasd
Messages: 39
Registered: December 2007
Member
I am using CentOS 5 and vzctl's version is 3.0.22

Now, your question reminds me of something:
This started to happen after I ran vzyum <vm> update, not before; everything was working perfectly about the update.
Re: /dev/pty always gone [message #26155 is a reply to message #26141] Wed, 16 January 2008 12:15 Go to previous messageGo to next message
maratrus is currently offline  maratrus
Messages: 1495
Registered: August 2007
Location: Moscow
Senior Member
Hi,

I have not yet fully understood the problem. I have only suppositions how to workaround it.
But:
1. I suppose that udev package is installed inside your VE.
2. Can you please attach /sbin/start_udev file from your VPS?
3. 'rpm -qf /lib/udev/devices/' from inside VPS.

Thank You!
Re: /dev/pty always gone [message #26188 is a reply to message #26055] Wed, 16 January 2008 18:39 Go to previous messageGo to next message
Thomasd is currently offline  Thomasd
Messages: 39
Registered: December 2007
Member
there you go:
# rpm -qf /lib/udev/devices/
udev-095-14.9.el5


and

]# cat /sbin/start_udev
#!/bin/sh
#
# start_udev
#
# script to initialize /dev by using udev.
#
# Copyright (C) 2004 Greg Kroah-Hartman <greg@kroah.com>
#
# Released under the GPL v2 only.
#
# This needs to be run at the earliest possible point in the boot
# process.
#
# Based on the udev init.d script
#
# Thanks go out to the Gentoo developers for proving
# that this is possible to do.
#
# Yes, it's very verbose, feel free to turn off all of the echo calls,
# they were there to make me feel better that everything was working
# properly during development...
#
# don't use udev if sysfs is not mounted.

sysfs_dir=/sys

export TZ=/etc/localtime

[ -d $sysfs_dir/class ] || exit 1
[ -r /proc/mounts ] || exit 1
[ -x /sbin/udevd ] || exit 1
[ -f /etc/udev/udev.conf ] && . /etc/udev/udev.conf
udev_root=${udev_root-/dev}


. /etc/init.d/functions

prog=udev
bin=/sbin/udev
udevd=/sbin/udevd
MAKEDEV="/sbin/MAKEDEV"

xargs_simple () {
        if [ "$1" = "-n" ]; then
                shift
                MAXNR="$1"
                shift
        else
                MAXNR=100
        fi
        NR=$MAXNR
        ARGS=""
        [ -z "$1" ] && set echo

        while read line; do
                if [ $NR -gt 0 ]; then
                        ARGS="$ARGS $line"
                        NR=$[$NR - 1]
                else
                        "$@" $ARGS
                        NR=$MAXNR
                        ARGS="$line"
                fi
        done
        if [ -n "$ARGS" ]; then
                "$@" $ARGS
        fi
}

make_extra_nodes () {
        ln -snf /proc/self/fd $udev_root/fd
        ln -snf /proc/self/fd/0 $udev_root/stdin
        ln -snf /proc/self/fd/1 $udev_root/stdout
        ln -snf /proc/self/fd/2 $udev_root/stderr
        ln -snf /proc/kcore $udev_root/core

        [ -d $udev_root/pts ] || mkdir -m 0755 $udev_root/pts
        [ -d $udev_root/shm ] || mkdir -m 0755 $udev_root/shm
        [ -a /dev/MAKEDEV ] || ln -s $MAKEDEV /dev/MAKEDEV;

        if [ -x $MAKEDEV ]; then
                for i in /etc/udev/makedev.d/*.nodes; do
                        if [ -f "$i" ]; then
                                cat "$i" | sed -e 's,#.*,,g' | \
                                        xargs_simple -n 100 $MAKEDEV -x
                        fi
                done
        fi
        for devdir in /etc/udev/devices /lib/udev/devices; do
                [ -d "$devdir" ] || continue
                pushd $devdir &> "$udev_root/null"
                set *
                if [ "$1" != "*" ]; then
                        cp -ar "$@" $udev_root/
                        pushd "$udev_root" &> "$udev_root/null"
                        [ -x /sbin/restorecon ] && /sbin/restorecon "$@"
                        popd &> "$udev_root/null"
                fi
                popd &> "$udev_root/null"
        done
}

kill_udevd() {
        if [ -x /sbin/pidof ]; then
                pid=`/sbin/pidof -x udevd`
                [ -n "$pid" ] && kill $pid
        fi
}


wait_for_queue() {
        local timeout=${1:-0}
        local ret=0
        if [ $timeout -gt 0 ]; then
            /sbin/udevsettle --timeout=$timeout
        else
            /sbin/udevsettle
        fi
        ret=$?
        if [ $ret -ne 0 ]; then
                echo -n "Wait timeout. Will continue in the background."
        fi
        return $ret;
}

export ACTION=add
prog=udev
ret=0
STRING=$"Starting $prog: "
# propagate $udev_root from /sys
echo -n "$STRING"

# mount the tmpfs on ${udev_root%/}, if not already done
LANG=C awk "\$2 == \"${udev_root%/}\" && \$3 == \"tmpfs\" { exit 1 }" /proc/mounts && {
        if LANG=C fgrep -q "none ${udev_root%/}/pts " /proc/mounts; then
                PTSDIR=$(mktemp -d)
                mount --move $udev_root/pts "$PTSDIR"
        fi
        if LANG=C fgrep -q "none ${udev_root%/}/shm " /proc/mounts; then
                SHMDIR=$(mktemp -d)
                mount --move $udev_root/shm "$SHMDIR"
        fi
        mount -n -o mode=0755 -t tmpfs none "$udev_root"
        mkdir -m 0755 $udev_root/pts
        mkdir -m 0755 $udev_root/shm
        if [ -n "$PTSDIR" ]; then
                mount --move "$PTSDIR" $udev_root/pts
                rmdir "$PTSDIR"
        fi
        if [ -n "$SHMDIR" ]; then
                mount --move "$SHMDIR" $udev_root/shm
                rmdir "$SHMDIR"
        fi

        ret=$[$ret + $?]
}

# returns OK if $1 contains $2
strstr() {
  [ "${1#*$2*}" = "$1" ] && return 1
  return 0
}

getval() {
    what=$1
    shift
    for arg; do
        if strstr "$arg" "$what="; then
            val=${arg#${what}=*}
            echo $val
            return 0
        fi
    done
    return 1
}

make_extra_nodes
cmdline=$(cat /proc/cmdline)
kill_udevd > "$udev_root/null" 2>&1
if [ -f "/sys/class/tty/console/uevent" ]; then
        # trigger the sorted events
        echo -e '\000\000\000\000' > /proc/sys/kernel/hotplug
        if strstr "$cmdline" modprobedebug; then
                touch /dev/.modprobe_debug
        else
                rm -f /dev/.modprobe_debug
        fi
        /sbin/udevd -d
        ret=$[$ret + $?]
        if strstr "$cmdline" udevdebug; then
                /sbin/udevcontrol log_priority=debug
        fi
        /sbin/udevtrigger
        ret=$[$ret + $?]
        wait_for_queue $(getval udevtimeout $cmdline)
        ret=$[$ret + $?]
else
        echo -n " kernel too old for this udev version "
        /sbin/udevd -d
        ret=10
fi

ret=$[$ret + $?]
[ $ret -eq 0 ] && success $"$STRING" || failure $"$STRING"
echo
exit 0


so, here's what I found:
if I install from one of the CentOS 5 template (either full or minimal, same problem), it will work properly. I can restart the VM many times without problem.
When I run vzyum <vm> update it will trigger the problem and the pty will be missing each time I restart the VM.
Not sure if it matters but I have dag added to my yum repositories:
[dag]
name=Dag RPM Repository for Red Hat Enterprise Linux
baseurl=http://apt.sw.be/redhat/el5/en/i386/dag
gpgcheck=1
enabled=1
Re: /dev/pty always gone [message #26191 is a reply to message #26188] Wed, 16 January 2008 21:09 Go to previous messageGo to next message
maratrus is currently offline  maratrus
Messages: 1495
Registered: August 2007
Location: Moscow
Senior Member
Hi,

is it possible to conduct following experiment?

- stop your VPS
- add necessary devices to /vz/private/<VE_ID>/lib/udev/devices/ like:
mknod --mode <MODE> /vz/private/<VE_ID>/lib/udev/devices/<DEV> <DEV_PARAM>

<MODE> - file mode
<VE_ID> - your VE id
<DEV> - device name
- start VPS
- please check if this device is in /dev inside VE
- try to enter VPS
- if it will be impossible please use strace like:
strace -f vzctl enter <VEID>
to determine necessary device and add it to /vz/private/<VE_ID>/lib/udev/devices/ too.

Re: /dev/pty always gone [message #26193 is a reply to message #26191] Wed, 16 January 2008 23:55 Go to previous messageGo to next message
Thomasd is currently offline  Thomasd
Messages: 39
Registered: December 2007
Member
I did this:

# mknod --mode 666 /vz/private/4010/lib/udev/devices/ptyp0 c 2 0

# ls -l /vz/private/4010/lib/udev/devices/ptyp0
crw-rw-rw- 1 root root 2, 0 Jan 16 15:48 /vz/private/4010/lib/udev/devices/ptyp0

# mknod --mode 666 /vz/private/4010/lib/udev/devices/ptmx c 5 2

# ls -l /vz/private/4010/lib/udev/devices/ptmx
crw-rw-rw- 1 root root 5, 2 Jan 16 15:51 /vz/private/4010/lib/udev/devices/ptmx


and now, it works: I can go in the VE, out, stop it, restart it and go back in. ptyp0 and ptmx are persistent.

I used to make it with MAKEDEV each time; What is it that made MAKEDEV create the devs in a non persistant way vs mknod? (I am not very knowledgeable in this area)
Re: /dev/pty always gone [message #26217 is a reply to message #26193] Thu, 17 January 2008 13:21 Go to previous messageGo to next message
maratrus is currently offline  maratrus
Messages: 1495
Registered: August 2007
Location: Moscow
Senior Member
Hi,

As far as I understand the matter is in the following:

When your VPS booting, one of the init scripts inside VE calls /sbin/start_udev which mounts /dev directory on tmpfs
mount -n -o mode=0755 -t tmpfs none "$udev_root"

So the directory /vz/private/<VE_ID>/dev and /vz/root/<VE_ID>/dev becomes different.
Then start_udev creates additional nodes.
When you create necessary devices like ptmx or ptyp0 (with MAKEDEV) they of course appear in /dev but start_udev mounts /dev on tmpfs so on reboot we lost this files.

P.S. In your case I suppose that after update udev package was installed and it becomes the reason of the problem.
P.S.S. You can conduct such experiment. After your VPS was started enter it. We already see that "mount" command shows such strings
Quote:

# mount
simfs on / type simfs (rw)
/proc on /proc type proc (rw)
/sys on /sys type sysfs (rw)
none on /dev type tmpfs (rw)
none on /dev/pts type devpts (rw)


Let's try to umount /dev/
umount -l /dev
. Then I suppose in /dev we can observe the same like in /vz/private/<VE_ID>/dev/. Then we can try to go out from VE and enter it again. If you create something in /dev it will be persistent and you can find it after reboot and after umount /dev.

By the way you have mentioned that sometimes ptmx sometimes ptyp0 were failed. What does it mean? Sometimes ptmx was in /dev sometimes there was not such file in /dev?

Re: /dev/pty always gone [message #26226 is a reply to message #26055] Thu, 17 January 2008 19:39 Go to previous messageGo to next message
Thomasd is currently offline  Thomasd
Messages: 39
Registered: December 2007
Member
some VM had pts missing, some pty; it was not constant and I'm not sure why at all
Re: /dev/pty always gone [message #26238 is a reply to message #26226] Fri, 18 January 2008 10:31 Go to previous messageGo to next message
maratrus is currently offline  maratrus
Messages: 1495
Registered: August 2007
Location: Moscow
Senior Member
Hi,

I'm not clearly understand you so I have some questions:

-
Quote:

some VM had pts missing, some pty

can you please enumerate such VM in the following way:
[The VPS template] - [what device is missing]
for example,
[fedora-core-6-i386-default] - [ptmx, ptyp0]

-
Quote:

it was not constant and I'm not sure why at all

what does it mean?
a) Let's pick out a certain VPS. We boot it once and ptmx is missing (there is no such file in /dev). So we boot it another time and ptmx appear in /dev.
b) There are two VPSs based on the different templates. We boot each of them and find out that one VPS has ptmx in /dev and another has not.
So in your case a), b) or something else happens? And please show the VPS templates and missing device in your case.

Thank You!
Re: /dev/pty always gone [message #26256 is a reply to message #26238] Fri, 18 January 2008 19:04 Go to previous messageGo to next message
Thomasd is currently offline  Thomasd
Messages: 39
Registered: December 2007
Member
all the VMs are centos-5-i386-minimal and all have problems with both ptmx and ptyp0

What is not consistant is that sometimes, using strace, I see ptmx only is missing, sometimes ptmx and ptyp0. On the same VM, after it got stopped and restarted. I could not find any rule about the consistency.

BUT

since I used mknod, the problem hasn't happened a single time (yet Smile).
when I used MAKEDEV, it would happen every time.


Re: /dev/pty always gone [SOLUTION] [message #26544 is a reply to message #26055] Mon, 28 January 2008 00:09 Go to previous messageGo to next message
asstronaut is currently offline  asstronaut
Messages: 1
Registered: January 2008
Location: Jamaica
Junior Member

I have same trouble and this looks very strange. As solution (inside problematic VZ) simply add the line 'ptmx' in file /etc/udev/makedev.d/50-udev.nodes (for CentOS 5) and is works fine after reboot.
Re: /dev/pty always gone [SOLUTION] [message #26559 is a reply to message #26544] Mon, 28 January 2008 16:22 Go to previous message
maratrus is currently offline  maratrus
Messages: 1495
Registered: August 2007
Location: Moscow
Senior Member
Hi,

undoubtedly this is a decision.

But I would like to add a few words about this issue:

IMHO, it is not very correctly to place additional entries to 50-udev.nodes and this is the reason: in our case the udev package was not installed at first moment. So the problem was appeared when it was be installed during the update and we should be very careful because we want to save our settings. I recommend to create additional file, for example /etc/udev/makedev.d/vz-udev.nodes and
place there necessary devices. So if udev will be installed our devices will be added automatically.

Previous Topic: [SOLVED!] OpenVZ Multicast Questions
Next Topic: disk quota
Goto Forum:
  


Current Time: Fri Mar 29 09:23:15 GMT 2024

Total time taken to generate the page: 0.01856 seconds