Difference between revisions of "Virtualization (LXC Containers)"

From CSCWiki
Jump to navigation Jump to search
(documenting LXC (in progress))
Line 1: Line 1:
 
= Linux Containers =
 
= Linux Containers =
   
As of Fall 2009, we use [http://lxc.sourceforge.net/ Linux containers] to maintain a few virtual machines, most notably [[Machine_List#caffeine|caffeine]], which is hosted on [[Machine_List#glomag|glomag]]. The various commands to manipulate Linux containers are prefixed with "lxc-"; see their individual manpages for usage. To start caffeine, run the following command as root on glomag:
+
As of Fall 2009, we use [http://lxc.sourceforge.net/ Linux containers] to maintain a few virtual machines, most notably [[Machine_List#caffeine|caffeine]], which is hosted on [[Machine_List#glomag|glomag]]. The various commands to manipulate Linux containers are prefixed with "lxc-"; see their individual manpages for usage.
  +
  +
To manage containers, use the <tt>lxc-*</tt> tools, which require root privilege. Some examples (replace <tt>caffeine</tt> with the appropriate container name):
  +
  +
# check if caffeine is running
  +
lxc-info -n caffeine
  +
  +
# start caffeine in the background
  +
lxc-start -d -n caffeine
  +
  +
# stop caffeine gracefully
  +
lxc-halt -n caffeine
  +
  +
# stop caffeine forcefully
  +
lxc-stop -n caffeine
  +
  +
# launch a TTY console for the container
  +
lxc-console -n caffeine
  +
  +
To install Linux container support on a recent Debian (squeeze or newer) system:
  +
* Install the <tt>lxc</tt> and <tt>bridge-utils</tt> packages.
  +
* Create a bridged network interface (this can be configured in <tt>/etc/network/interfaces</tt> as though it were a normal Ethernet device, with the additional <tt>bridge_ports</tt> parameter. This is usually called <tt>br0</tt> (can be created manually with <tt>brctl</tt>). LXC will create a virtual Ethernet device and add it to the bridge when each container starts.
  +
  +
To start caffeine, run the following command as root on glomag:
   
 
lxc-start -d -n caffeine
 
lxc-start -d -n caffeine
   
Containers are stored on the host filesystem in /var/lib/lxc (root filesystems are symlinked to the appropriate directory on /vm). mspang originally set this up, so he probably knows more about it than anyone else.
+
Containers are stored on the host filesystem in /var/lib/lxc (root filesystems are symlinked to the appropriate directory on /vm).
   
 
= VServer =
 
= VServer =

Revision as of 16:52, 14 March 2012

Linux Containers

As of Fall 2009, we use Linux containers to maintain a few virtual machines, most notably caffeine, which is hosted on glomag. The various commands to manipulate Linux containers are prefixed with "lxc-"; see their individual manpages for usage.

To manage containers, use the lxc-* tools, which require root privilege. Some examples (replace caffeine with the appropriate container name):

# check if caffeine is running
lxc-info -n caffeine

# start caffeine in the background
lxc-start -d -n caffeine

# stop caffeine gracefully
lxc-halt -n caffeine

# stop caffeine forcefully
lxc-stop -n caffeine

# launch a TTY console for the container
lxc-console -n caffeine

To install Linux container support on a recent Debian (squeeze or newer) system:

  • Install the lxc and bridge-utils packages.
  • Create a bridged network interface (this can be configured in /etc/network/interfaces as though it were a normal Ethernet device, with the additional bridge_ports parameter. This is usually called br0 (can be created manually with brctl). LXC will create a virtual Ethernet device and add it to the bridge when each container starts.

To start caffeine, run the following command as root on glomag:

lxc-start -d -n caffeine

Containers are stored on the host filesystem in /var/lib/lxc (root filesystems are symlinked to the appropriate directory on /vm).

VServer

Linux-VServer Homepage

vserver $NAME build -m debootstrap --hostname magic --interface $IFACE:$IP/24 -- -d lenny

To have a vserver autostart, create a file called /etc/vservers/$VSERVER/apps/init/mark with content:

default