Essential Openvz commands

1. Command to list the running VPSs in a node

# vzlist

Example:

# vzlist
 CTID NPROC STATUS IP_ADDR HOSTNAME
 106 104 running xx.xx.xx.xx server1.test.com 
 107 46 running xx.xx.xx.xx server2.test.com 
 108 83 running xx.xx.xx.xx server3.test.com
 109 86 running xx.xx.xx.xx server4.test.com

2. This command lists all (running and stopped) the VPSs in a node.

# vzlist -a

Example:

# vzlist -a
 CTID NPROC STATUS IP_ADDR HOSTNAME
 106 104 running xx.xx.xx.xx server1.test1.com 
 107 46 running xx.xx.xx.xx server2.test2.com 
 108 83 running xx.xx.xx.xx server3.test3.com
 109 86 running xx.xx.xx.xx server4.test4.com
 110 - stopped xx.xx.xx.xx server5.test5.com

Read more

Share

Cloning Openvz Proxmox PVE container guest machine

  1. I first created a ‘template’ vm containing all stuff I need and using a temporarily ip adres.
  2. In the network config file of eth0 (/etc/sysconfig/network-scripts/ifcfg-eth0) I comment out the HWADDRESS line, else it will not come up with another mac address…
  3. Stop this ‘template’ vm as it is just used for cloning.
  4. Create a backup : vzdump –dumpdir /path/to/backupdir –snapshot 101
  5. Restore in new container : vzrestore /path/to/backupdir/backupfile_of_container_101 102 or vzrestore –storage ‘storagename’ /path/to/backupdir/backupfile_of_container_101 102
  6. Create a new mac for eth0 : vzctl set 102 –netif_add eth0
  7. Modify the hostname in the proxmox webinterface.
  8. Bootup the vm and open a vnc console.
  9. Change the ip address in /etc/sysconfig/network-scripts/ifcfg-eth0
  10. Go to /etc/ssh and remove all keys : rm -f /etc/ssh/*key*
  11. Restart the ssh server so it will regenerate keys : service sshd restart
Share

Allow NFS attachment on Proxmox OpenVZ containers

Prepare the container

To allow a container to use NFS filesystem, you will need to start it with “nfs” feature enabled. If the container is running while you set the –features nfs:on, you will need to reboot it.

# vzctl set 101 --features "nfs:on" --save
# vzctl start 101

After this you may see nfs in /proc/filesystems

# vzctl exec 101 cat /proc/filesystems
 ext3
 ext2
nodev rpc_pipefs
nodev proc
nodev nfs
nodev sysfs
nodev tmpfs
nodev devpts
Share

Fix Date Time on PVE OpenVZ Guest machine

  1. Stop VE vzctl stop 101
  2. in HD node, run:
  3. vzctl set 101 –capability sys_time:on –save
  4. Start VE: vzctl start 101
  5. Enter VE: vzctl enter 101
  6. mv /etc/localtime /etc/localtime.old
  7. ln -s /usr/share/zoneinfo/Asia/Dhaka /etc/localtime
  8. date 092115442006 (09 = Month, 21 = day, 15 = hour, 44=minutes, 2006 = year)

Run date to check your time is right. That’s it!

Share