Converting an openvz to lxc container

To properly migrate an old openvz container to a new lxc container can be a bit tricky, but I finally succeeded to find a proper way with a minimal downtime.

In my examples the container ID is 108.

It starts with a vzdump of the current container:

vzdump 108 --remove 1 --mode snapshot --compress lzo --storage backup09 --node clust-10 --bwlimit 0 --size 8192

–remove 1 says it’s allowed to remove the previous dump, if there is any
–mode snapshot says it’s making a live dump of a running container (no downtime)
–compress lzo is a light but efficient compress method
–bwlimit 0 is important if you can handle speeds over 80000 kb/s, which is default bwlimit
–size 8192 will fix input/output errors on certain lvm storages with low free diskspace

Above command will result in a file which you can use later in the pct restore command:

pct restore 108 $(ls -1r /mnt/pve/backup09/dump/vzdump-openvz*108* | head -n1) --storage ssd --onboot 1 --net1 name=eth0,bridge=vmbr0 --net2 name=eth2,bridge=vmbr2

This command will restore the back-up in to a new lxc container on the new node. The command will extract the last found dump of that container ID to the storage called ‘ssd’ (in our case the CEPH filesystem). It will also add some network devices and change the setting to start at boot.

Above command you can run during daytime, because some containers will take hours to pack and unpack, it can be handy to do so.

After that you can mount the new container with:

pct mount 108

Now you can access the files directly on this path:


This makes it possible to update certain files, to make sure you start the container with the latest data.

So next we are going to stop the old container:

vzctl stop 108

After that we need to rsync the data from the old node to the new node, like:

rsync --stats -avz /var/lib/vz/private/108/home/ root@
rsync --stats -avz /var/lib/vz/private/108/var/lib/mysql/ root@
rsync --stats -avz /var/lib/vz/private/108/var/log/ root@
rsync --stats -avz /var/lib/vz/private/108/etc/ root@

You can see that is the IP of the new node. It will rsync all the data in just a couple of minutes, of course depending on the age of the dump.

After adding the network interfaces (if not done already by the restore command), you can unmount and start the new lxc container on the new node:

pct unmount 108
pct start 108

If you are lucky everything starts and works like a charm 🙂

Got error ‘Primary script unknown’ after update PHP-FPM + Apache 2.4

After a update_versions in DirectAdmin I got this error on a sites error log:

[client] AH01071: Got error 'Primary script unknown\n'

The URL it self gave:

File not found.

Yesterday everything was working fine. After updating Apache 2.4.x and PHP-FPM (5.6) I figured it had to do something with those services.

But the app (CodeEgniter) was running in a subfolder. The main folder contained a WordPress install and was working fine.

So after some time I tried to play with the .htaccess file, and I succeeded. I changed this old .htaccess:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
RewriteBase /fc2/

To this new variation:

RewriteBase /fc2/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /fc2/index.php [L]

Don’t ask me why, but the Primary script unknown is gone.

So in this case it had nothing to do with ProxyHandler, ProxyPass or other configuration issues between PHP-FPM and Apache. Just a little .htaccess error which results in a bug.

Install SpamFighter and BlockCracking with Exim and dkim

This is what I use to set-up my DirectAdmin boxes with Exim, SpamAssassin, SpamFighter, BlockCracking and dkim.

cd /usr/local/directadmin/custombuild 

./build set clamav yes
./build set exim yes
./build set eximconf yes
./build set eximconf_release 4.4
./build set blockcracking yes
./build set easy_spam_fighter yes
./build set spamassassin yes
./build set sa_update daily

./build update
./build exim
./build clamav
./build spamassassin
./build exim_conf

wget -O /etc/exim.dkim.conf

service exim restart

After that you can use the file /etc/virtual/domainips to set the interface IP for exim:


MySQL automatic restore script

We had a .sql export from a MySQL databaseserver from all the databases. In our case the filenames were made up like:


So I wrote a little bash script to recreate all the databases and import it’s data:



for file in `ls $folder/mysqldump-*.sql`
echo $file
IFS='-' read -r -a array <<< "$file"
echo ${array[2]}
echo "create database ${array[2]}" | mysql -u da_admin -ppassword
mysql -u da_admin -pnAcQKhIK ${array[2]} < $file


After a little while all databases were full with content again 🙂

Install Dutch Language in DirectAdmin Enhanced skin

I use this code to install the Dutch Language (Nederlandse taal) on all my servers. It will get automatically updated if there is a new version available.

cd /usr/local/directadmin/data/skins/
unzip -o
chown -R diradmin:diradmin enhanced/images/
chown -R diradmin:diradmin enhanced/lang/
chown diradmin:diradmin enhanced/files_custom.conf
chmod -R 755 enhanced/images/
chmod -R 755 enhanced/lang/
chmod 755 enhanced/files_custom.conf
rm -f

After running this code you can select the Dutch Language (nl) in the Modify User page in DirectAdmin.

How to reinstall the default Enhanced skin

If you need to reinstall the default DirectAdmin skin Enhanced you can use this code:

rm -f /usr/local/directadmin/data/skins/enhanced
cd /usr/local/directadmin/data/skins/
mkdir -p enhanced
tar -xzf enhanced.tar.gz

After this code the enhanced skin will be updated and be default again. Please not that you update DirectAdmin before reinstalling (and updating) the default Enhanced skin.

Rebuild your DirectAdmin user cache

In some particular cases I was unable to find my users using the DirectAdmin UI. Since then I use this little script to rebuild the user cache of the “Show All Users” list.


cd /usr/local/directadmin/data/users

for r in `ls */reseller.conf | cut -d/ -f1`; do
echo “fixing Reseller $r …”;

echo -n ” > $r/users.list

for u in `grep “^creator=$r$” */user.conf | cut -d/ -f1`; do
ISUSER=`grep -c usertype=user $u/user.conf`
if [ “$ISUSER” = “1” ]; then
echo $u >> $r/users.list

After using this script all users will be shown again in DirectAdmin.

Remove e-mail sent count from e-mailaccount

If you want to reset the e-mail acount of a DirectAdmin account it’s pretty simple, you can just hit the reset button. But there are no such buttons for the e-mail accounts itself. So you can use this little line in SSH to remove the e-mail sent acount of a particular e-mail account:

rm -f /etc/virtual/

Notice this line concerns So you have to change the part and the info part.

Adding domain pointer with e-mail and SSL options

If you add a domain pointer to a DirectAdmin domain, you can not set-up the e-mail accounts and SSL certificates by default. Almost all the options are not available.

To fix this you can remove the domain pointer and add the domain as a normal domain to the account. It has to be the same account due to permissions.

Then, remove the private_html folder, symlink it to the public_html and set the correct permissions with this piece of code:

rm -rf /home/user/domains/
ln -s /home/user/domains/ /home/user/domains/
chown -h user:user /home/user/domains/

Now you have the same effect of the normal Domain Pointer in DirectAdmin, but you are able to use the interface for all other DirectAdmin options!