OpenVZ Forum


Home » Mailing lists » Users » init output
init output [message #24822] Tue, 11 December 2007 07:19 Go to next message
Dietmar Maurer is currently offline  Dietmar Maurer
Messages: 52
Registered: March 2007
Member
From: openvz.org
Hi all,

is it possible to capture the output of the init process (to se what
happens on VE startup)?

- Dietmar
Re: init output [message #24828 is a reply to message #24822] Tue, 11 December 2007 08:04 Go to previous messageGo to next message
dev is currently offline  dev
Messages: 1693
Registered: September 2005
Location: Moscow
Senior Member

From: openvz.org
you can run VE /sbin/init with environment variable CONSOLE set to some file.
in this case it's output will get into file.
# man init

Thanks,
Kirill



Dietmar Maurer wrote:
> Hi all,
> 
> is it possible to capture the output of the init process (to se what
> happens on VE startup)?
> 
> - Dietmar
> 
> 
>
AW: init output [message #24833 is a reply to message #24828] Tue, 11 December 2007 09:08 Go to previous messageGo to next message
Dietmar Maurer is currently offline  Dietmar Maurer
Messages: 52
Registered: March 2007
Member
From: openvz.org
But I cant do that with current vzctl, instead I need to modify the
source?

env.c 301: char *envp[] = {"HOME=/", "TERM=linux",
"CONSOLE=/var/log/init.log", NULL}; 

Is that the way to do it?

- Dietmar

> you can run VE /sbin/init with environment variable CONSOLE 
> set to some file.
> in this case it's output will get into file.
> # man init
Re: AW: init output [message #24835 is a reply to message #24833] Tue, 11 December 2007 09:22 Go to previous messageGo to next message
dev is currently offline  dev
Messages: 1693
Registered: September 2005
Location: Moscow
Senior Member

From: openvz.org
or you can replace /sbin/init with some script adding this to env
and running original init binary.

Kirill

Dietmar Maurer wrote:
> But I cant do that with current vzctl, instead I need to modify the
> source?
> 
> env.c 301: char *envp[] = {"HOME=/", "TERM=linux",
> "CONSOLE=/var/log/init.log", NULL}; 
> 
> Is that the way to do it?
> 
> - Dietmar
> 
> 
>>you can run VE /sbin/init with environment variable CONSOLE 
>>set to some file.
>>in this case it's output will get into file.
>># man init
> 
> 
>
RE: init output [message #24859 is a reply to message #24835] Tue, 11 December 2007 12:36 Go to previous messageGo to next message
Dietmar Maurer is currently offline  Dietmar Maurer
Messages: 52
Registered: March 2007
Member
From: openvz.org
OK, tried it both ways, but output is truncated by vzctl stop.

For example the following init script:

-----------------
#!/bin/sh

# file must be there - create it
echo >/var/log/init.log
export CONSOLE=/var/log/init.log
exec /sbin/init.org

-----------------

then I start the VE and try to view the log:

> vzctl start 777

> tail -100f /var/lib/vz/root/777/var/log/init.log
stty: standard input: Inappropriate ioctl for device
/etc/rcS.d/S03udev: line 265: echo: write error: Operation not permitted
Activating swap...done.
mount: permission denied
Cleaning up ifupdown....
....


That works quite good so far, but when I stop the VE the file gets
truncated:

tail: /var/lib/vz/root/777/var/log/init.log: file truncated

Any idea why? I already searched the sysvinit code sources, but found
nothing there.

- Dietmar

 
> or you can replace /sbin/init with some script adding this to 
> env and running original init binary.
> 
> Kirill
> 
> Dietmar Maurer wrote:
> > But I cant do that with current vzctl, instead I need to modify the 
> > source?
> > 
> > env.c 301: char *envp[] = {"HOME=/", "TERM=linux", 
> > "CONSOLE=/var/log/init.log", NULL};
> >
RE: init output [message #24861 is a reply to message #24859] Tue, 11 December 2007 12:51 Go to previous messageGo to next message
Dietmar Maurer is currently offline  Dietmar Maurer
Messages: 52
Registered: March 2007
Member
From: openvz.org
> tail: /var/lib/vz/root/777/var/log/init.log: file truncated
> 
> Any idea why? I already searched the sysvinit code sources, 
> but found nothing there.

'vzctl stop' does not work at all with my modified init - no processes
killed.

- Dietmar
AW: init output [message #24863 is a reply to message #24861] Tue, 11 December 2007 13:02 Go to previous messageGo to next message
Dietmar Maurer is currently offline  Dietmar Maurer
Messages: 52
Registered: March 2007
Member
From: openvz.org
Ah, got it - its because i need to pass correct parameters to init.

- Dietmar 

> -----Ursprüngliche Nachricht-----
> Von: users-bounces@openvz.org 
> [mailto:users-bounces@openvz.org] Im Auftrag von Dietmar Maurer
> Gesendet: Dienstag, 11. Dezember 2007 13:52
> An: users@openvz.org; Kirill Korotaev
> Betreff: RE: [Users] init output
> 
>  
> > tail: /var/lib/vz/root/777/var/log/init.log: file truncated
> > 
> > Any idea why? I already searched the sysvinit code sources, 
> but found 
> > nothing there.
> 
> 'vzctl stop' does not work at all with my modified init - no 
> processes killed.
> 
> - Dietmar
> 
>
Re: init output [message #24869 is a reply to message #24861] Tue, 11 December 2007 14:29 Go to previous messageGo to next message
rkagan is currently offline  rkagan
Messages: 11
Registered: May 2006
Location: Moscow
Junior Member
From: openvz.org
On Tue, Dec 11, 2007 at 01:51:30PM +0100, Dietmar Maurer wrote:
>  
> > tail: /var/lib/vz/root/777/var/log/init.log: file truncated
> > 
> > Any idea why? I already searched the sysvinit code sources, 
> > but found nothing there.
> 
> 'vzctl stop' does not work at all with my modified init - no processes
> killed.

vzctl stop effectively calls 'init 0'.  Now that /sbin/init is your
script, it unconditionally truncates the log file, and then calls
/sbin/init.orig again without arguments.

To get what you want you need a slightly more elaborate script,
something like the following (untested):

#!/bin/sh

# file must be there - create it if we're pid 1
[ $$ = 1 ] && echo >/var/log/init.log
export CONSOLE=/var/log/init.log
exec /sbin/init.org "$@"


That said, I do think we need to implement some sort of serial
console-like device for VEs.  We'll see what can be done here.

Roman.
AW: init output [message #24872 is a reply to message #24869] Tue, 11 December 2007 16:23 Go to previous message
Dietmar Maurer is currently offline  Dietmar Maurer
Messages: 52
Registered: March 2007
Member
From: openvz.org
> To get what you want you need a slightly more elaborate 
> script, something like the following (untested):
> 
> #!/bin/sh
> 
> # file must be there - create it if we're pid 1 [ $$ = 1 ] && 
> echo >/var/log/init.log export CONSOLE=/var/log/init.log exec 
> /sbin/init.org "$@"
> 
> 
> That said, I do think we need to implement some sort of 
> serial console-like device for VEs.  We'll see what can be done here.

I already have a working init wrapper which uses a named pipe, and an
additional
logging process to read that named pipe and writes it into a file.

(init uses open without O_APPEND, so setting CONSOLE=filename will never
work)

Will post my script here as soon as it gets more stable.

- Dietmar
Previous Topic: OpenVZ specific patchset
Next Topic: Kernel 2.6.18-openvz-13-39.1d1-amd64 oops
Goto Forum:
  


Current Time: Wed Dec 19 04:14:52 GMT 2018