“Broken” Files In VPS Container

Posted by Vanessa | Tagged under , | Posted on Sun May, 2010

1

I came across a VPS that was recently moved to another node and noticed that Apache wasn’t starting due to missing modules.  When I saw that the modules folder in Apache was linked to /usr/lib64, I checked that folder to see that the httpd directory was there, but not really “there”. It looked like this:

?---------  ? ?    ?       ?            ? httpd

Question marks in the file name and descriptor, clearly indicating that the VPS container was missing something. Well, I went onto the parent node and into /vz/private/VEID/fs/root/usr/lib64 and the files were there, along with some strange broken symlink that looks like this:

lrwxrwxrwx   1 root root   72 Mar  8  2009 ._vzlnk_. -> ////centos/5/x86_64/httpd-2.2.3-11.el5_2.centos.4.x86_64/usr/lib64/httpd

To fix one instance, I removed the broken symlink and that fixed the problem. I also tried to fix this on another container by copying over the httpd folder in the lib64 directory and that did the trick as well, but I assume it’s the broken symlink that caused the problem.

Further troubleshooting indicated that the container was somehow using a different OS template than what it was on the previous server, which was causing Virtuozzo to be unable to find some files. If this is the case, you can edit /etc/vz/conf/$VEID.conf and change the ostemplate value to what it should be, then restart the container.

If that doesn’t fix it, you’ll probably still need to remove all those bad symlinks. Here’s a simple script stolen from here that should remove all these for you:

#!/bin/bash
VEID=101 # Replace with your container ID
for i in `find /vz/private/$VEID/fs/root/ -noleaf -type l -print | perl -nle ‘-e || print’|grep ._vzlnk_.`
do
ln -sf `ls -ga $i|grep ._vzlnk_.|awk ‘{print $10}’|sed ‘s/\/\/\//\/vz\/template/’` $i
done