Cloning an existing virtualbox VM for remote desktop connection

Objective: cloning an existing virtualbox VM for remote desktop connection
Environment: Linux host server running Fedora 9 and Virtualbox 2.2.2r46594


1. shutdown existing VM vm1
# VBoxManage controlvm vm1 acpipowerbutton

2. clone vm1 to vm2
# cd /root/.VirtualBox/HardDisks
# VBoxManage clonehd vm1.vdi vm2.vdi

3. add one more VM and use the existing filechange memory setting for vm2
use virtualbox command on Linux host to add one more VM, use the existing vdi file vm2.vdi. Change settings such as network card (NAT or Bridge), Memory usage and different vrdp port etc

4. enable mutli connection  for vrdp
# VBoxManage modifyvm vm2 --vrdpmulticon on

5. enable pam for external vrdp authentication
for Fedora 9, you need to do this:

# ln -sf /lib/ /lib/

then external authentication can use PAM to authenticate normal user accounts on Fedora 9 VirtualBox host server.

6. create username and password on Linux host for vm2 vrdp authentication
# useradd vm2user
# passwd vm2user

7. startup vm2
# VBoxManage startvm vm2 --type vrdp

8. use remote desktop connection on Windows client pc to connect to vm2
configure mstsc to save username and password for vm2 connection.

9. compress vdi file size

use dd to create empty zero file on Linux/Windows host
dd if=/dev/zero of=temp1 bs=1M
rm -f temp1 or del temp1(Windows)
VBoxManage modifyhd vdifilename --compact