vzrestore from Ubuntu to CentOS breaks networking

ameir

New Member
Mar 19, 2014
7
0
1
Hello,

I noticed that if I have an Ubuntu container, and later do a vzrestore of a CentOS container, the OSTEMPLATE variable is not changed in the container config. The side effect of that is that when I start the new container, I get:

Code:
root@mc02:~# vzctl start 102
Starting container ...
Container is mounted
Adding IP address(es): 10.0.0.100
/bin/bash: line 504: /etc/network/interfaces: No such file or directory
grep: /etc/network/interfaces: No such file or directory
/bin/bash: line 517: /etc/network/interfaces: No such file or directory
/bin/bash: line 540: /etc/network/interfaces: No such file or directory
/bin/bash: line 547: /etc/network/interfaces: No such file or directory
cp: cannot stat `/etc/network/interfaces': No such file or directory
/bin/bash: line 571: /etc/network/interfaces.bak: No such file or directory
mv: cannot stat `/etc/network/interfaces.bak': No such file or directory
Setting CPU units: 1000
Setting CPUs: 1
Container start in progress...

Of course, /etc/network/interfaces is where network settings are stored in Ubuntu. vzctl is attempting to check the interfaces file, but being on CentOS, it doesn't exist.

If I change:
Code:
OSTEMPLATE="ubuntu-12.04-standard_12.04-1_i386.tar.gz"
to:
Code:
OSTEMPLATE="centos-6-standard_6.3-1_i386.tar.gz"
everything then works perfectly.

Is it possible to get the variable in the config file updated when we pass the -ostemplate parameter? I think that this would be the ideal behavior.

Thanks!
 
Hello,

I noticed that if I have an Ubuntu container, and later do a vzrestore of a CentOS container, the OSTEMPLATE variable is not changed in the container config. ..

not sure if I understand it correctly, pls explain step by step what you have done.
 
In short, if I create a new container with an Ubuntu template, and later do something like:

Code:
pvesh create /nodes/mc02/openvz -restore 1 -force 1 -ostemplate 'xtemplates:vztmpl/centos-6-standard_6.3-1_i386.tar.gz' -vmid 102
everything works fine, with the exception of networking. When I do vzctl start 102 I get the errors I mentioned in my post.

vzctl thinks the container is still Ubuntu, so it tries to modify the appropriate interfaces file. If I change the OSTEMPLATE variable in the config, then things work as expected.

Hopefully that's a bit clearer.
 
this makes not really sense to me. seems I do not understand your use case. if you got ubuntu, you have an ubuntu config.

if you want centos, delete the ubuntu container and create a new centos.
 
I am working on a tool that provisions containers in Proxmox, and I wanted to rely on this for a couple of reasons:

1. Doing a restore is much faster than destroying a container, then creating one
2. I need the vmid to remain the same, and doing a restore guarantees that, while a destroy/create cannot (related to my other thread at http://forum.proxmox.com/threads/18105-Is-relying-on-nextid-for-vmid-via-API-safe?p=92228)

I think that passing -ostemplate to a restore would be ideal, but if there is a way to set OSTEMPLATE via the API, that would work, too (maybe via /nodes/{node}/openvz/{vmid}/config).

This issue also exists if you go to a container and go to the 'Backups' tab and restore a container of a different distro.

I know that this scenario might not be very common, but I think it'd be easy to implement, and make things a bit better than a destroy/create.

Thanks!