aboutsummaryrefslogtreecommitdiff
path: root/README
blob: 5a139a7026a076af16ece03dad6111f34baa9af9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
KVM-Manager

Author: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
Date: 2009-10-08 11:22:14-0400

This is a small set of scripts to make it relatively easy to manage a
stable of kvm instances in a fairly secure and isolated fashion.

The basic model is to use runit to supervise each KVM instance, with a
single, non-privileged user account for each instance. You can login
via ssh as the non-privileged user and, via screen, access the 
instance's console. 

Dependencies:

 runit : for system supervision
 uml-utilities : for tunctl for the tun/tap interface
 kvm : for the virtual machine emulator
 screen : for the detached, logged serial console
 bridge-utils : for configuring a bridge device

Recommendations:

 openssh-server : i've been using ssh to access the vm's serial console

INSTALLATION

 * Install dependencies:

   aptitude install runit uml-utilties kvm screen bridge-utils

 * Copy programs into /usr/local/sbin:
 
   cp {di-maker,kvm-manager,kvm-creator} /usr/local/sbin/

 * Copy screen configuration file into /etc

   cp screenrc.kvm-manager /etc/

 * Configure your host network to use a bridge. If your network adaptor 
   is eth0, you can use the following in /etc/network/interfaces

  auto br0
  iface br0 inet static
    [Put your normal IP config for eth0 here...]
    bridge_ports eth0

INSTALLING DEBIAN ONTO YOUR VIRTUAL SERVER

To create a KVM instance, run:

  kvm-creator create $GUESTNAME $VG [$DISKSIZE [$RAM [$TAP [$MAC] ] ] ]

You can replace "create" with "demo" to see the default values for non-
specified options.

The creator scripts creates a username and home directory, logical volume, and
the required directory in /etc/sv/kvm/GUESTNAME from which the kvm-manager
script is run. After creating your virtual server, you can modify the files in
/etc/sv/kvm/GUESTNAME/env to change initial settings.

You may also add ssh key's to /home/GUESTNAME/.ssh/authorized_keys to provide
additional access to other users.

At this point, your virtual server is created, however, it has no operating system
and it has not been started.

There are two options for installing debian onto the virtual server:

 * netboot
 * iso (like a CD install)

To use netboot, make sure you have a working DHCP server running on your
host server and offering addresses over your bridge interface.

Then, indicate that the server should boot via the network with:

  touch /home/$GUESTNAME/vms/$GUESTNAME/netboot

Alternatively, you can make a debian boot ISO image:

	* Make the directory /usr/local/share/ISOs
	* Create a serial console enabled debian installer.
		* cd /usr/local/share/ISOs
		* di-maker > d-i.iso

Indicate that the server should boot via the CDROM (the equivelant of putting
the installer CD in the drive) with:

  ln -s /usr/local/share/ISOs/d-i.iso /home/$GUESTNAME/vms/$GUESTNAME/cd.iso

STARTING YOUR VIRTUAL SERVER

  update-service --add /etc/sv/kvm/$GUESTNAME

This process adds your virtual server to the runit service directory.

If /home/$GUESTNAME/vms/$GUESTNAME/cd.iso exists, the server will behave as if you
set the CDROM as the boot device in the bios.

If /home/$GUESTNAME/vms/$GUESTNAME/netboot exists, the server will behave as if you
set the network device as the boot device in the bios.

After you have installed your server, be sure to delete these files if they exist or
your server won't boot properly.

ACCESSING YOUR VIRTUAL SERVER

To access the guest's serial console, do:

   ssh -t $GUESTNAME@host.machine screen -x $GUESTNAME

HACKING

All patches, fixes, suggestions welcome!