<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Andrius Sutas&#039;s blog &#187; Uncategorized</title>
	<atom:link href="http://sutas.eu/category/uncategorized/feed/" rel="self" type="application/rss+xml" />
	<link>http://sutas.eu</link>
	<description>Science is interesting!</description>
	<lastBuildDate>Thu, 10 Nov 2011 11:29:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Setting up LXC on Debian squeeze</title>
		<link>http://sutas.eu/setting-up-lxc-on-debian-squeeze/</link>
		<comments>http://sutas.eu/setting-up-lxc-on-debian-squeeze/#comments</comments>
		<pubDate>Sun, 06 Nov 2011 18:46:23 +0000</pubDate>
		<dc:creator>Andrius Šutas</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://sutas.eu/?p=217</guid>
		<description><![CDATA[This is a step-by-step tutorial on how to install LXC on Debian Squeeze (and possibly other versions). I wrote this down as a reminder to myself because I was unable to find one consistent example source that worked for me. &#8230; <a href="http://sutas.eu/setting-up-lxc-on-debian-squeeze/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This is a step-by-step tutorial on how to install LXC on Debian Squeeze (and possibly other versions). I wrote this down as a reminder to myself because I was unable to find one consistent example source that worked for me. I will not talk what LXC is or why is it good, it has been already done in numerous places.<span id="more-217"></span></p>
<h1>Installation</h1>
<ul>
<li>Installing required packages:</li>
<pre># apt-get install bridge-utils debootstrap</pre>
<li>Setting up a bridge interface:</li>
<p>As I already had bridge set up for OpenVPN, so I skipped this step.<br />
For the most basic bridge add following configuration to <em><strong>/etc/network/interfaces</strong></em>:</p>
<pre># Bridge setup
iface br0 inet static
        bridge_ports eth0 eth1
        address 192.168.0.2
        broadcast 192.168.0.255
        netmask 255.255.255.0
        gateway 192.168.0.1</pre>
<p><em>bridge_ports</em> &#8211; specify physical interfaces to be added to br0. You should not put any lines to configure the interfaces that will be used by the bridge, as this will be setup automatically by the scripts when bringing the bridge up.
</ul>
<ul>
<li>Installing LXC:<br />
Assuming you&#8217;re running Debian Stable (squeeze (v6.0) at the time of writing), then the candidate LXC version should be <i>&lt;0.7.3</i>:</p>
<pre>apt-cache policy lxc | grep -i candidate</pre>
<p>All versions up to <i>0.7.3</i> (see: <a href="http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=601422" target="_blank">bug #601422</a>) by default uses debian lenny distribution for the VM containers. If you are ok with that, go directly to &#8220;Using lenny for the container&#8221;, otherwise, see below &#8220;Using squeeze for the container&#8221;.</p>
<ul>
<li>Using squeeze for the container:</li>
<p>The one possible way to get LXC <i>&gt;=0.7.3</i> with squeeze is to use <i>testing</i> repository, as <a href="http://packages.debian.org/search?suite=squeeze-backports&#038;keywords=lxc" target="_blank">backports</a> do not include LXC yet. This is more a hack, than a good solution, but because LXC does not have many dependencies it works just fine for our purposes.<br />
Add default release parameter for apt:</p>
<pre># echo "echo "APT::Default-Release \"stable\";" >> /etc/apt/apt.conf.d/70debconf</pre>
<p>Add <i>testing</i> repositories to your sources list:</p>
<pre># echo "deb ftp://ftp.lt.debian.org/debian/ testing main non-free contrib" >> /etc/apt/sources.list
# echo "deb-src ftp://ftp.lt.debian.org/debian/ testing main non-free contrib" >> /etc/apt/sources.list</pre>
<p>Alternatively you can use any <i>testing</i> mirror. Now all is left to do, is to install LXC itself:</p>
<pre># apt-get update &#038;&#038; apt-get -t testing install lxc</pre>
<p>Just to be sure your <i>stable</i> system does not &#8220;drift&#8221; into <i>testing</i> packages, you can remove the testing repositories from <i>sources.list</i>. As newer LXC package moves into <i>stable</i>, apt should automatically catch that and update accordingly without braking any dependencies.</p>
<li>Using lenny for the container:</li>
<p>For using lenny as a VM container simply install LXC tools from <i>stable</i> repository:</p>
<pre># apt-get update &#038;&#038; apt-get install lxc</pre>
</ul>
<p>After isntalling LXC tools, it is time to set up cgroups:</p>
<pre># echo "cgroup /sys/fs/cgroup cgroup defaults 0 0" >> /etc/fstab
# mount cgroup
</pre>
<p>And a quick check to ensure everything is ok so far:</p>
<pre># lxc-checkconfig</pre>
<p>In output you should see everything enabled apart &#8220;Cgroup memory controller&#8221;. If you want memory control via cgroups then the Kernel recompilation is needed, which is beyond the scope of this tutorial.
</li>
</ul>
<h1>Creating your first VM</h1>
<ul>
<li>Creating root filesystem:<br />
Create directory for VM and install Debian base system using lxc template:</p>
<pre>
# mkdir -p /lxc/vm0
# /usr/lib/lxc/templates/lxc-debian -p /lxc/vm0/
</pre>
<p>This will take longer to complete only the first time you run it, as the subsequent template creations will use debootstrap&#8217;s cache. </p>
<ul>
<li>Error &#8220;Failed getting release file&#8221;<br />
If you get this error during first install, simply change mirror in <strong>/usr/lib/lxc/templates/lxc-debian</strong> file and repeat steps, e.g.:</p>
<pre>MIRROR=${MIRROR:-ftp://ftp.lt.debian.org/debian/}</pre>
</li>
</ul>
</li>
<li>Configuring VM:<br />
We are nearly done. The last step is to configure our VM container. Edit the file <strong>/lxc/vm0/config</strong> while taking special attention to parameters:</p>
<pre>
lxc.network.ipv4 = 192.168.0.123/24
lxc.network.hwaddr = 4a:59:43:49:79:bf
lxc.network.link = br0
lxc.network.type = veth
lxc.network.veth.pair = veth_vm0
</pre>
<p>Notes: </p>
<ol>
<li>IP (in <i>lxc.network.ipv4</i>) must end with CIDR notation of subnet. &#8220;/24&#8243; means subnet mask of &#8220;255.255.255.0&#8243;</li>
<li>MAC (in <i>lxc.network.hwaddr</i>) address must not be <a href="http://en.wikipedia.org/wiki/Multicast_address#Ethernet" target="_blank">multicast</a></li>
<li>Name of interface (in <i>lxc.network.veth.pair</i>) can be anything, but I prefer convention &#8220;veth_VM-NAME&#8221;</li>
</ol>
<p>Do not forget to configure VM&#8217;s interface in file <strong>/lxc/vm0/rootfs/etc/network/interfaces</strong> to something like:</p>
<pre>
auto eth0
iface eth0 inet static
        address 192.168.0.123
        netmask 255.255.255.0
        gateway 192.168.0.1
</pre>
</li>
<li>Starting VM:<br />
Now the final step is to power on and start using your VM:</p>
<pre>
lxc-start -n vm0 -f /lxc/vm0/config
</pre>
<p>You will be attached to a VM console where you can login with user <strong>root:root</strong>. <font color="red">Do not forget to change the root&#8217;s password or disable the account altogether!</font>
</li>
</ul>
<h1>Other:</h1>
<ul>
<li>Stopping VM:</li>
<pre>lxc-stop -n vm0</pre>
<li>Attaching to VM&#8217;s console:</li>
<pre>lxc-console -n vm0</pre>
<li> Auto-starting VMs when host starts:
<ul>
<li>LXC &lt;0.7.5:<br />
Create config symlink:</p>
<pre># ln -s /lxc/vm0/conf /etc/lxc/vm0.conf</pre>
<p>Then edit file <strong>/etc/default/lxc</strong> and include something like:</p>
<pre>
RUN=yes
CONF_DIR=/etc/lxc
CONTAINERS="vm0"
</pre>
</li>
<li>LXC &gt;=0.7.5:
<pre># ln -s /lxc/vm0/config /etc/lxc/auto/vm0.conf</pre>
</li>
</ul>
</li>
<li> Cloning VM:<br />
This can be achieved by simply copying VM&#8217;s directory with:</p>
<pre># cp -r /lxc/vm0 /lxc/new_vm</pre>
<p>After that do not forget to change <strong>/lxc/new_vm/config</strong> and <strong>/lxc/new_vm/rootfs/etc/network/interfaces</strong> files to reflect new changes of <i>name</i>, <i>IP/MAC address</i> and <i>rootfs location</i>.
</li>
<li>Sharing (binding) host&#8217;s directory in VM:<br />
In VM&#8217;s config include <i>lxc.mount.entry</i>, e.g. for VM running Apache:</p>
<pre>lxc.mount.entry = /var/www /lxc/vm0/rootfs/var/www none defaults,bind 0 0</pre>
</li>
</ul>
<h1>References</h1>
<ol>
<li><a href="http://wiki.debian.org/LXC" target="_blank">http://wiki.debian.org/LXC</a></li>
<li><a href="http://www.jotschi.de/?p=554" target="_blank">http://www.jotschi.de/?p=554</a></li>
<li><a href="http://lxc.teegra.net/" target="_blank">http://lxc.teegra.net/</a></li>
<li><a href="http://nigel.mcnie.name/blog/a-five-minute-guide-to-linux-containers-for-debian#id3" target="_blank">http://nigel.mcnie.name/blog/a-five-minute-guide-to-linux-containers-for-debian#id3</a></li>
<li><a href="http://jim.studt.net/depository/index.php/using-linux-containers-with-debian-lenny " target="_blank">http://jim.studt.net/depository/index.php/using-linux-containers-with-debian-lenny<br />
</a></li>
<li><a href="http://alfie.ist.org/blog/2011/03/23" target="_blank">http://alfie.ist.org/blog/2011/03/23</a></li>
<li><span class="mh-email">http<a href='http://www.google.com/recaptcha/mailhide/d?k=01GgL5Bhsw7CwDVf1wfnKCJg==&amp;c=tAhcfm_3DHc7I8WTjmP9AyUrB-sABYkI0Q3NuU3lK_HHYwRSRPOOyGhhkoST7bM5qPrCDNih78HonbQGRCrT5f551zX0l_zMPvzju2hQ1JE=' onclick="window.open('http://www.google.com/recaptcha/mailhide/d?k=01GgL5Bhsw7CwDVf1wfnKCJg==&amp;c=tAhcfm_3DHc7I8WTjmP9AyUrB-sABYkI0Q3NuU3lK_HHYwRSRPOOyGhhkoST7bM5qPrCDNih78HonbQGRCrT5f551zX0l_zMPvzju2hQ1JE=', '', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=300'); return false;" title="Reveal this e-mail address">...</a>@lists.sourceforge.net/msg00783.html</span></li>
<li><a href="http://ubuntuforums.org/showthread.php?t=1476832" target="_blank">http://ubuntuforums.org/showthread.php?t=1476832</a></li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://sutas.eu/setting-up-lxc-on-debian-squeeze/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Detexify &#8211; LaTeX symbol classifier</title>
		<link>http://sutas.eu/detexify-latex-symbol-classifier/</link>
		<comments>http://sutas.eu/detexify-latex-symbol-classifier/#comments</comments>
		<pubDate>Wed, 09 Mar 2011 03:32:33 +0000</pubDate>
		<dc:creator>Andrius Šutas</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Detexify]]></category>
		<category><![CDATA[latex]]></category>
		<category><![CDATA[symbols]]></category>

		<guid isPermaLink="false">http://sutas.lt/?p=203</guid>
		<description><![CDATA[Quick post of something useful I found recently: Anyone who works with LaTeX knows how time-consuming it can be to find a symbol in symbols-a4.pdf that you just can&#8217;t memorize. Detexify is an attempt to simplify this search.]]></description>
			<content:encoded><![CDATA[<p>Quick post of something useful I found recently:<br />
Anyone who works with LaTeX knows how time-consuming it can be to find a symbol in <a href='http://ftp.linux.ee/pub/tex-archive/info/symbols/comprehensive/symbols-a4.pdf' >symbols-a4.pdf</a> that you just can&#8217;t memorize. <a href="http://detexify.kirelabs.org/classify.html">Detexify</a> is an attempt to simplify this search. </p>
]]></content:encoded>
			<wfw:commentRss>http://sutas.eu/detexify-latex-symbol-classifier/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

