Table Of Contents

Previous topic

Programs

This Page

PXE Booting

How to use pxe_manager.py

  1. setup configuration file for tftp server and permissions
sudo apt-get install dhcp3-server tftpd-hpa syslinux nfs-kernel-server initramfs-tools
cat /etc/default/tftpd-hpa

the output is

# /etc/default/tftpd-hpa
TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/data/tftpboot"
TFTP_ADDRESS="0.0.0.0:69"
TFTP_OPTIONS="-v --secure"
RUN_DAEMON="yes"
#OPTIONS="-l -s /data/tftpboot"

in order to run without superuser permission, we need change the permissions.

sudo usermod -G tftp YOURNAME        # add your account to tftp group
sudo chgrp tftp /data/tftpboot
sudo chmod g+rw /data/tftpboot
sudo chgrp -R tftp /data/tftpboot/pxelinux.cfg
sudo chmod -R g+rw /data/tftpboot/pxelinux.cfg
sudo chgrp tftp /etc/dhcp3/dhcpd.conf
sudo chmod g+rw /etc/dhcp3/dhcpd.conf
ls -l /data
> drwxrwxrwx 9 root tftp  4096 2011-08-29 11:46 tftpboot
  1. generate a filesystem for pxe boot
./pxe_manager.py --generate-pxe-filesystem /data/tftpboot/root_you
  1. add a host to DB
./pxe_manager.py --auto-add root_you --db=/data/tftpboot/pxe.db
602dhcp7.jsk.t.u-tokyo.ac.jp

After that, you need to restart dhcp service

sudo service dhcp3-server restart
  1. generate a virtualbox image
./pxe_manager.py --generate-virtualbox-image VMNAME --db=/data/tftpboot/pxe.db

The MAC address of VMNAME is estimated from DB, which was generated by –auto-add command. You can use –virtualbox-macaddress option to specify the MAC address directly.

./pxe_manager.py --generate-virtualbox-image VMNAME --virtualbox-macaddress=00:11:22:33:44:55

If you specify a hostname of a physical machine, pxe_manager.py will decide the parameters of vm according to the spec of the machine. The parameters are the number of cpu and the size of memory (80% of the physical machine).

./pxe_manager.py --generate-virtualbox-image VMNAME --refer-physical-machine PHYS_MACHINE

References

Setting up VirtualBox with PXE Boot

  1. Install VirtualBox:
wget -q  http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | sudo apt-key add -
echo "deb http://download.virtualbox.org/virtualbox/debian `lsb_release -cs` contrib non-free" | sudo tee /etc/apt/sources.list.d/virtualbox.list
sudo apt-get update
sudo apt-get install virtualbox-4.1
  1. Configure your OS:
sudo /etc/init.d/vboxdrv setup
  1. Add your user to the vboxusers group in /etc/group
  2. Create a bridge ethernet setup:
sudo apt-get install bridge-utils
  1. Restart networking:
sudo /etc/init.d/networking restart
  1. Start virtualbox, create a new OS with no local hard drive. Set the Network Adapter to:
Attached to: Bridged Adapter Name: eth0 Adapter Type: PCnet-PCI II Click on Cable connected

Make sure to enable 3D acceleration and allocate the right amount of cpu and memory resources.

NOTE: It would be great to have a script that configures the new VM.

Commandline Interface to VirtualBox

  1. listing the registered vms
VBoxManage list vms
"pxetest" {341ef969-487a-4827-a59e-905bb3fb8f7a}
"pxetest2" {904d947a-8723-433b-b27e-5cf9241c523b}
  1. start vm with GUI
virtualbox --startvm VMNAME
  1. start vm without GUI (headless)
VBoxManage startvm VMNAME --type headless
  1. register a new vm (.vms file) to your virtualbox
VBoxManage registervm foo.vms
  1. connect to a headless VM
rdesktop-vrdb HYPERVISORNAME:8888
  1. restart a VM
VBoxManage controlvm VMNAME reset
  1. restart all VMs using vboxapi
import vboxapi
# todo