Guest User

kvm->lxc

a guest
May 14th, 2011
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.69 KB | None | 0 0
  1. set -x
  2. if [ ! -f debian-6.0.1a-i386-netinst.iso ];then
  3.     wget http://cdimage.debian.org/debian-cd/current/i386/iso-cd/debian-6.0.1a-i386-netinst.iso
  4. fi
  5. if [ ! -f debian.qcow2 ];then
  6.     kvm-img create debian.qcow2 -f qcow2 10G
  7. fi
  8. echo "Installing the OS in the kvm instance, say yes to everything, choose your own passwords and choose SSH server on tasksel screen"
  9. #kvm debian.qcow2 -cdrom debian-6.0.1a-i386-netinst.iso -no-reboot -m 1G
  10. echo "Installed, booting"
  11. kvm -m 1G -net nic -net user,hostfwd=::2200-:22,hostfwd=::8000-:80 debian.qcow2 &
  12. sleep 20
  13.  
  14. ETC_NETWORK_INTERFACES="
  15. auto lo
  16. iface lo inet loopback
  17.  
  18. auto br0
  19. iface br0 inet dhcp
  20.    bridge_ports eth0
  21.    bridge_fd 0
  22.    bridge_maxwait 0
  23. "
  24. COMMAND="apt-get install debootstrap lxc bridge-utils           ;
  25.    echo 'cgroup          /cgroup         cgroup  defaults        0       0' >> /etc/fstab;
  26.    mkdir -p /cgroup;mount none -t cgroup /cgroup               ;
  27.    echo \"$ETC_NETWORK_INTERFACES\" > /etc/network/interfaces  ;
  28.    lxc-create -t debian --name test1                           ;
  29.    echo \"lxc.network.type=veth\"  >> /var/lib/lxc/test1/config;
  30.    echo \"lxc.network.flags=up\"   >> /var/lib/lxc/test1/config;
  31.    echo \"lxc.network.link=br0\"   >> /var/lib/lxc/test1/config;
  32.    /etc/init.d/networking restart;
  33. "
  34.  
  35. echo "Configuring the server, please type guest root password"
  36. ssh -p 2200 root@localhost "$COMMAND"
  37. echo "Done, now log in through ssh,\`ssh -p 2200 root@localhost\` , and do \`lxc-start --name test1\`, the ssh will go unresponsive the moment the lxc guest acquires IP by DHCP, this is caused by the host(kvm) network failure as we depend on hosts network for the ssh console ssh->kvm->lxc-shell"
Advertisement
Add Comment
Please, Sign In to add comment