1. You need to have the OS template first on the server node, Usually
this might be located under the path /vz/template/cache/

If you need some other OS template download it to the node.

2. Stop the vps on which you need to rebuild the OS
vzctl stop <vpsid>

3. Backup the dir from the loacation /vz/private for the vpsid

cd /vz/private
mv <veid> <veid.old>

4.create new directory
mkdir veid
untar the ostemplate insited the directory newly created for the vpsid
ie under the path /vz/private/<veid>

tar -zxf /vz/template/cache/template---tar.gz (the location
differs as from were you take the os template )


5. Open the config file

vi /etc/sysconfig/vz-scripts/<veid>.conf

edit the OS template line with the required os template
6. Start the vps
vzctl start <veid>

7. to set the password
vzctl set <veid> --userpasswd root:new password

Note : Always take back ups before edit any configuration files.