How to Reset root password in Proxmox VE 7

First, boot the system in the rescue kernel. I am assuming your boot partition is separated then the home partition, like in my case. Here are the list of commands I have used:

# mount /dev/md126 /mnt
# mount /dev/md127 /mnt/boot
# mount --bind /dev /mnt/dev
# mount --bind /dev/pts /mnt/dev/pts
# mount --bind /proc /mnt/proc
# mount --bind /sys /mnt/sys
# chroot /mnt
# passwd

Now, make sure to reset the password properly. Once done. Umount all the partition and boot in regular mode:

# umount /mnt/boot
# umount /mnt/sys
# umount /mnt/proc
# umount /mnt/dev/pts
# umount /mnt/dev
# umount /mnt
# reboot

It should be it.

How to Mount qcow2 KVM/Xen/VMware VM Image

To mount qcow2, you need to mount this image as a ‘Network Block Device’.

First, enable NBD

modprobe nbd max_part=8

Now, connect the qcow2 as an NBD device

qemu-nbd --connect=/dev/nbd0 /vz/vmprivate/v1002/harddisk.hdd

Now to mount the partition, first detect the partition

fdisk /dev/nbd0 -l

Now, you may mount the partition

mount /dev/nbd0p1 /mnt

Once, all the jobs are done, you may unmount, disconnect, and remove the NBD kernel module

umount /mnt
qemu-nbd --disconnect /dev/nbd0
rmmod nbd

KVM VM Not starting – could not get access to acl tech driver ‘ebiptables’

Issue

KVM VM not starting with the following error when you try to start:

could not get access to acl tech driver 'ebiptables'

There is a nwfilter module for libvirt. If for some reason, it comes up with an issue, the above error would appear. To fix this, you need to update (If any update is available) / reinstall (If no update is available) the following module using Yum:

libvirt-daemon-config-nwfilter

The command would be like the following:

yum update libvirt-daemon-config-nwfilter

That shall fix the issue.

Could not make the Query. Virtualizor Error

Today, when I opened a Virtualizor panel for a VM node, I found an issue like the following:

Could not make the Query.
SELECT tasks.actid, tasks.action, users.uid, users.email FROM `tasks` LEFT JOIN users on tasks.uid = users.uid WHERE action NOT IN ('vpsbackups_plan_email', 'send_background_mail', 'backuply_vpsbackups_plan_email') ORDER BY tasks.actid DESC LIMIT 10
Array
(
    [0] => HY000
    [1] => 144
    [2] => Table './virtualizor/tasks' is marked as crashed and last (automatic?) repair failed

Issue was the tasks table is marked as crashed. To solve this, we need to repair the table tasks.

First, find the password for database ‘virtualizor’ using the following command:

[root@sg40 ~]# grep dbpass /usr/local/virtualizor/universal.php
$globals['dbpass'] = 'gziqr4y989';

Now connect to the mysql using the password:

/usr/local/emps/bin/mysql -u root -p virtualizor

Now repair the table:

use virtualizor;
REPAIR TABLE tasks;

Now the virtualizor shall work.

ERROR: Cannot open TUN/TAP dev /dev/net/tun: No such file or directory (errno=2) – LXC/LXD

If you are seeing the above error in LXC, you need to do two things.

  1. Make sure the LXC container is running on privileged mode.
  2. Run the following commands inside the container:
mknod /dev/net/tun c 10 200

Now, you may run the OpenVPN command to start the VPN client:

openvpn --pull-filter ignore redirect-gateway --config ovpn.ovpn

# assumming your vpn config file is ovpn.ovpn

How to Set Timezone in LXC/LXD container CentOS 7

LXC should take the UTC as the default timezone for the guest. To set a custom timezone, you need to manually run this:

ln -sf /usr/share/zoneinfo/Asia/Dhaka /etc/localtime

In our case, we set the Asia/Dhaka as the default timezone. For Ubuntu based systems, you may use ‘tzdata’ package.

How To Run a Command in All OpenVZ Containers

You can run single command in a container using the following:

vzctl exec 201 service httpd status

How to find out all the VZ containers:

vzlist -a

The other way? Yes, there is. VZ list is stored inside a file /proc/vz/veinfo, and we can use it with the help of shell to run command in each VZ as following:

for i in `cat /proc/vz/veinfo | awk '{print $1}'|egrep -v '^0$'`; \
do echo "Container $i"; vzctl exec $i <your command goes here>; done

An example, can be the following:

for i in `cat /proc/vz/veinfo | awk '{print $1}'|egrep -v '^0$'`; \
do echo "Container $i"; vzctl exec $i service httpd status; done

This should show all the httpd status of the VZ.