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

Continue reading “Essential Openvz commands” »

Share

NFS fix on LXC Host Server

NFS client on LXC seems do not work. Why? The problem is apparmor on the real machine that block any appempt to mount NFS volumes.
In order to try to minimize the security changes on apparmor I add the following lines in/etc/apparmor.d/lxc/lxc-default

# allow nfs mount everywhere

mount fstype=rpc_pipefs, 
mount fstype=nfs,

Then

$ /etc/init.d/apparmor reload

And now I was able to restart nfs-common and nfs-kernel-server without errors !

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