<?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>v13 - random words</title>
	<atom:link href="http://www.v13.gr/blog/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://www.v13.gr/blog</link>
	<description>Pseudo-random groups of words that compose what we call knowledge</description>
	<lastBuildDate>Mon, 09 Apr 2012 11:05:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.5</generator>
		<item>
		<title>Linux Containers: Easy LXC</title>
		<link>http://www.v13.gr/blog/?p=192</link>
		<comments>http://www.v13.gr/blog/?p=192#comments</comments>
		<pubDate>Sun, 25 Mar 2012 16:32:01 +0000</pubDate>
		<dc:creator>v13</dc:creator>
				<category><![CDATA[Administration]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[LXC]]></category>

		<guid isPermaLink="false">http://www.v13.gr/blog/?p=192</guid>
		<description><![CDATA[Linux containers (a.k.a. LXC) rock. It&#8217;s the ultimate way of having multiple Linux boxes with minimal requirements. Here&#8217;s how I do it under Debian (and the script I&#8217;m using): Requirements This guide is for Debian  testing as of 25 March 2012. However it should work for other cases as well. The procedure creates a minimal [...]]]></description>
			<content:encoded><![CDATA[<p>Linux containers (a.k.a. LXC) rock. It&#8217;s the ultimate way of having multiple Linux boxes with minimal requirements.</p>
<p>Here&#8217;s how I do it under Debian (and the script I&#8217;m using):</p>
<h2>Requirements</h2>
<p>This guide is for Debian  testing as of 25 March 2012. However it should work for other cases as well.</p>
<p>The procedure creates a minimal installation which can then be fully  customized by hand or with puppet. The procedure installs Debian under  Debian but should be easy to change for other distributions as well  (especially Ubuntu).</p>
<h3>Packages</h3>
<p>You will need to install:</p>
<ul>
<li>lxc &#8211; The linux containers package</li>
<li>bridge-utils &#8211; For bridging network interfaces</li>
<li>uml-utilities &#8211; For tun/tap interfaces</li>
<li>cdebootstrap &#8211; For the bootstrapping of the virtual machines</li>
<li>puppet (optional) &#8211; for managing multiple machines</li>
</ul>
<h3>Networking</h3>
<p>I prefer networking between lxc installations to be separate from my normal network. It is trivial however to bridge with the outside network as well.</p>
<p>Add the following to /etc/network/interfaces:</p>
<pre class="brush: plain; title: ;">
auto virtlxc
iface virtlxc inet manual
 tunctl_user     root
 up              ip link set virtlxc up
 down            ip link set virtlxc down

auto brvirt
iface brvirt inet static
 bridge_ports            virtlxc
 bridge_maxwait          0
 bridge_stp              off
 address                 10.3.1.1
 netmask                 255.255.255.0
 dns-search              virt.local
</pre>
<p>Then add the following to /etc/hosts:</p>
<pre class="brush: plain; title: ;">
10.3.1.1    deb0 deb0.virt deb0.virt.local
10.3.1.11    deb1 deb1.virt deb1.virt.local
10.3.1.12    deb2 deb2.virt deb2.virt.local
10.3.1.13    deb3 deb3.virt deb3.virt.local
10.3.1.14    deb4 deb4.virt deb4.virt.local
</pre>
<p>Add as many entries as you like. There should be one entry per virtual machine. It doesn&#8217;t matter if you have more entries than virtual machines since you may use them in the future. The first (deb) entry is for the local machine.</p>
<p>Bring up the brvirt and virtlxc interfaces and keep reading (ifup virtlxc; ifup brvirt).</p>
<p>You may also want to run something like this to provide network access to the virtual machines (assuming that eth0 is the interface the connects you to the rest of the world):</p>
<pre class="brush: plain; title: ;">
echo 1 &gt; /proc/sys/net/ipv4/ip_forward
iptables -I POSTROUTING -o eth0 -s 10.3.1.0/24 -j MASQUERADE
</pre>
<h2>Create the virtual machine</h2>
<p>Get the following script and change the desired variables at the beginning as follows (assuming that you followed the network configuration):</p>
<ul>
<li>SUITE: The Debian suite to use (e.g. squeeze)</li>
<li>MIRROR: A mirror to download debian from. If you use approx like me then you want to use the local machine (i.e. 10.3.1.1)</li>
<li>VIRTUSER: A username you want to have created in the virtual machine. After that you may ssh as that user.</li>
<li>LOCALUSERS: A space separated list of local users to get ssh public keys from and put then in VIRTUSER&#8217;s authorized_keys file to allow ssh.</li>
<li>PUPPETMASTER: Leave it empty if you don&#8217;t have a puppet master.</li>
<li>DNSSERVER: The DNS server to use. By default it is the local machine.</li>
</ul>
<p>Each virtual machine should get a unique MAC address. The MAC addresses are auto-generated from the current y/m/d/H/M, so you should not create more than one virtual machines every minute. You&#8217;re free to change this of course.</p>
<p>Now run the script at the end of the page and let it create a virtual machine:</p>
<pre class="brush: plain; title: ;">
./easylxc deb1
</pre>
<p>The installation will happen under /var/lib/lxc (the default for lxc). You may visit that and fix things by hand if you (i.e.) manage to lock yourself out.</p>
<p>The virtual machine can be started with:</p>
<pre class="brush: plain; title: ;">
lxc-start -n deb4
- or -
lxc-start -n deb4 -d
</pre>
<p>However, a bug/feature of rxvt will prevent that for succeeding. In that case you can run:</p>
<pre class="brush: plain; title: ;">
sudo lxc-start -n deb4
- or -
sudo lxc-start -n deb4 -d
</pre>
<p>Inside the virtual machine you will be able to su to root by using &#8220;su&#8221; without password. You will be also able to ssh as root (using the same ssh keys).</p>
<h2>Hints&#8217;n'tips</h2>
<p>I strongly suggest using approx and changing the MIRROR variable as needed. It will speed the creation of many machines by orders of magnitude since there will be no network delays.</p>
<h2>The script</h2>
<pre class="brush: bash; title: ;">
#!/bin/bash

if [ -z &quot;$1&quot; ] ; then
	echo &quot;Pass the name of the machine as the first parameter&quot;
	exit 1
fi

# The name of the container to create. Also used as the hostname
NAME=&quot;$1&quot;

# The name of the parent (local) machine without the domain
PARENTNAME=&quot;deb0&quot;

# Distribution
SUITE=&quot;squeeze&quot;

# The domain to be used by the virtual machines.
DOMAIN=&quot;virt.hell.gr&quot;

# The network prefix (first 3 octets - it is assumed to be a /24 network)
NETPREFIX=&quot;10.3.1&quot;

# Since we use approx, this is the approx server. If not, add a mirror.
MIRROR=&quot;http://ftp.debian.org/debian/&quot;

# The gateway address for the virtual machine. This is most probably the
# address of the bridge interface.
GW=&quot;$NETPREFIX.1&quot;

# The bridge interface to use for networking
BRIDGEIF=&quot;brvirt&quot;

# The username of the user to create inside the container
VIRTUSER=&quot;v13&quot;

# A list of local users that will have ssh access to the container
# They need to have a public key in the local machine
LOCALUSERS=&quot;v13 root&quot;

# The puppet master. This must be the hostname of the master (not an IP addr).
# No puppet if this is empty.
PUPPETMASTER=&quot;&quot;

# The DNS server to use.
DNSSERVER=&quot;$GW&quot;

IPADDR2=$(getent hosts $NAME.$DOMAIN | awk '{print $1}')

if [ &quot;x$IPADDR2&quot; = &quot;x169.254.1.1&quot; ] ; then
	IPADDR2=&quot;&quot;
fi

if [ -z &quot;$IPADDR2&quot; ] ; then
	echo &quot;Could not resolve $NAME.$DOMAIN&quot;
	exit 1
fi

IPADDR=&quot;$IPADDR2/24&quot;

MAC=$(date &quot;+4a:%y:%m:%d:%H:%M&quot;)

lxc-stop -n $NAME
lxc-destroy -n $NAME

export SUITE
export MIRROR

R0=/var/lib/lxc/$NAME
R=$R0/rootfs

mkdir $R0 $R

# Install base system
echo cdebootstrap -f standard $SUITE $R $MIRROR
cdebootstrap -f standard $SUITE $R $MIRROR

CFG=$R0/config

# Create config file
cat &lt;&lt; _KOKO &gt; $CFG
# Auto-generated by: $*
# at $(date)

## Container
lxc.utsname		= $NAME
lxc.rootfs		= $R
lxc.tty			= 6
lxc.pts			= 1024

## Network
lxc.network.type	= veth
lxc.network.hwaddr	= $MAC
lxc.network.link	= $BRIDGEIF
lxc.network.veth.pair	= veth-$NAME

## Capabilities
lxc.cap.drop		= mac_admin
lxc.cap.drop		= mac_override
lxc.cap.drop		= sys_admin
lxc.cap.drop		= sys_module

## Devices
# Allow all device
lxc.cgroup.devices.allow	= a
# Deny all device
lxc.cgroup.devices.deny		= a
# Allow to mknod all devices (but not using them)
lxc.cgroup.devices.allow	= c *:* m
lxc.cgroup.devices.allow	= b *:* m

# /dev/console
lxc.cgroup.devices.allow	= c 5:1 rwm
# /dev/fuse
lxc.cgroup.devices.allow	= c 10:229 rwm
# /dev/null
lxc.cgroup.devices.allow	= c 1:3 rwm
# /dev/ptmx
lxc.cgroup.devices.allow	= c 5:2 rwm
# /dev/pts/*
lxc.cgroup.devices.allow	= c 136:* rwm
# /dev/random
lxc.cgroup.devices.allow	= c 1:8 rwm
# /dev/rtc
lxc.cgroup.devices.allow	= c 254:0 rwm
# /dev/tty
lxc.cgroup.devices.allow	= c 5:0 rwm
# /dev/urandom
lxc.cgroup.devices.allow	= c 1:9 rwm
# /dev/zero
lxc.cgroup.devices.allow	= c 1:5 rwm
# /dev/net/tun
lxc.cgroup.devices.allow        = c 10:200 rwm

## Limits
#lxc.cgroup.cpu.shares                  = 1024
#lxc.cgroup.cpuset.cpus                 = 0
#lxc.cgroup.memory.limit_in_bytes       = 256M
#lxc.cgroup.memory.memsw.limit_in_bytes = 1G

## Filesystem
lxc.mount.entry		= proc $R/proc proc nodev,noexec,nosuid 0 0
lxc.mount.entry		= sysfs $R/sys sysfs defaults,ro 0 0

_KOKO

# fix interfaces
T=$R/etc/network/interfaces
mv $T $T.orig
(
	cat $T.orig \
		| sed &quot;s/^iface eth0.*$//&quot;
	echo &quot;
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
	address			$IPADDR2
	netmask			255.255.255.0
	gateway			$GW
	dns-nameservers		$DNSSERVER
	&quot;
) &gt; $T
rm $T.orig

# fix resolv.conf
T=$R/etc/resolv.conf
cat &lt;&lt; _KOKO &gt; $T
domain $DOMAIN
search $DOMAIN
nameserver $GW
_KOKO

# add info to hosts
T=$R/etc/hosts
echo &quot;$IPADDR2 $NAME $NAME.$DOMAIN&quot; &gt;&gt; $T
echo &quot;$GW gw gw.$DOMAIN $PARENTNAME.$DOMAIN $PARENTNAME&quot; &gt;&gt; $T

# set debian_chroot (for help)
echo &quot;lxc-$NAME&quot; &gt;&gt; $R/etc/debian_chroot

# create ttys
for i in $(seq 0 6) ; do
	mknod $R/dev/tty$i c 4 $i
done

run()
{
	echo chroot $R &quot;$@&quot;
	LC_ALL=C chroot $R &quot;$@&quot;
}

run2()
{
	ssh -o StrictHostKeyChecking=no $IPADDR2 &quot;$@&quot;
}

runmaster()
{
	ssh -o StrictHostKeyChecking=no $PUPPETMASTER &quot;$@&quot;
}

# Install locales
run apt-get -y install locales

# disable init scripts
DISABLED=&quot;bootlogd bootlogs checkfs.sh checkroot.sh halt hostname.sh \
	hwclockfirst.sh hwclock.sh module-init-tools mountall.sh \
	mountdevsubfs.sh mountkernfs.sh mountnfs.sh mountoverflowtmp procps \
	reboot stop-bootlogd stop-bootlogd-single udev umountfs umountnfs.sh \
	umountroot&quot;
for dis in $DISABLED ; do
	run update-rc.d $dis disable
done

# disable rsyslog's kernel logging
run sed -i 's/^\(.*imklog.*\)$/#\1/' /etc/rsyslog.conf

# add user
run adduser --gecos $VIRTUSER --disabled-password $VIRTUSER
run adduser $VIRTUSER root

# fix sources.list
T=$R/etc/apt/sources.list
cat &lt;&lt; _KOKO &gt; $T
deb $MIRROR $SUITE main
_KOKO

# Install ssh
run apt-get update
run apt-get -y install openssh-server
run /etc/init.d/ssh stop

# Fix root and su
run passwd -l root
T=$R/etc/pam.d/su
mv $T $T.old
cat $T.old \
	| sed 's/^# \(.*pam_wheel.so trust\)/\1/' \
	&gt; $T
rm $T.old

# Add ssh keys
T=$R/home/$VIRTUSER/.ssh/authorized_keys
T2=$R/root/.ssh/authorized_keys
mkdir $R/home/$VIRTUSER/.ssh $R/root/.ssh
for u in $LOCALUSERS ; do
	H=$(getent passwd $u | cut -f 6 -d : )
	cat $H/.ssh/id_rsa.pub &gt;&gt; $T
	cat $H/.ssh/id_rsa.pub &gt;&gt; $T2
done
chown $VIRTUSER.$VIRTUSER $R/home/$VIRTUSER/.ssh $T
chown root.root $R/home/$VIRTUSER/.ssh $T2

# Start it
# Use sudo to bypass file descriptor problems
sudo lxc-start -n $NAME -d
sleep 1

if ! [ -z &quot;$PUPPETMASTER&quot; ] ; then
	# Install packages
	run2 apt-get -y install puppet

	# Clear any existing certificate
	runmaster puppet cert clean $NAME.$DOMAIN

	# Fix puppet config
	T=$R/etc/default/puppet
	mv $T $T.old
	cat $T.old \
		| sed 's/START=no/START=yes/' \
		| sed &quot;s/DAEMON_OPTS=\&quot;\&quot;/DAEMON_OPTS=\&quot;--server=$PUPPETMASTER --verbose\&quot;/&quot; \
		&gt; $T
	rm -rf $T.old

	run2 puppet agent --server=$PUPPETMASTER --no-daemonize --onetime

	# sign the certificate
	runmaster puppet cert --sign $NAME.$DOMAIN

	run2 /etc/init.d/puppet start
fi

cat &lt;&lt; _KOKO

LXC virtual box is ready!

Config file is at: $R0/config
Root fs is at: $R

Get a console with:
  lxc-console -n $NAME

Stop it with:
  lxc-stop -n $NAME

Start it with:
  lxc-start -n $NAME -d

_KOKO
</pre>
</pre>
<p>Update: You can use the above code under the GPLv3 license.</p>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 1582px; width: 1px; height: 1px; overflow: hidden;">#!/bin/bash</p>
<p>if [ -z "$1" ] ; then<br />
echo "Pass the name of the machine as the first parameter"<br />
exit 1<br />
fi</p>
<p># The name of the container to create. Also used as the hostname<br />
NAME="$1"</p>
<p># The name of the parent (local) machine without the domain<br />
PARENTNAME="deb0"</p>
<p># Distribution<br />
SUITE="squeeze"</p>
<p># The domain to be used by the virtual machines.<br />
DOMAIN="virt.hell.gr"</p>
<p># The network prefix (first 3 octets - it is assumed to be a /24 network)<br />
NETPREFIX="10.3.1"</p>
<p># Since we use approx, this is the approx server. If not, add a mirror.<br />
MIRROR="http://ftp.debian.org/debian/"</p>
<p># The gateway address for the virtual machine. This is most probably the<br />
# address of the bridge interface.<br />
GW="$NETPREFIX.1"</p>
<p># The bridge interface to use for networking<br />
BRIDGEIF="brvirt"</p>
<p># The username of the user to create inside the container<br />
VIRTUSER="v13"</p>
<p># A list of local users that will have ssh access to the container<br />
# They need to have a public key in the local machine<br />
LOCALUSERS="v13 root"</p>
<p># The puppet master. This must be the hostname of the master (not an IP addr).<br />
# No puppet if this is empty.<br />
PUPPETMASTER=""</p>
<p>IPADDR2=$(getent hosts $NAME.$DOMAIN | awk '{print $1}')</p>
<p>if [ "x$IPADDR2" = "x169.254.1.1" ] ; then<br />
IPADDR2=""<br />
fi</p>
<p>if [ -z "$IPADDR2" ] ; then<br />
echo "Could not resolve $NAME.$DOMAIN"<br />
exit 1<br />
fi</p>
<p>IPADDR="$IPADDR2/24"</p>
<p>MAC=$(date "+4a:%y:%m:%d:%H:%M")</p>
<p>lxc-stop -n $NAME<br />
lxc-destroy -n $NAME</p>
<p>export SUITE<br />
export MIRROR</p>
<p>R0=/var/lib/lxc/$NAME<br />
R=$R0/rootfs</p>
<p>mkdir $R0 $R</p>
<p># Install base system<br />
echo cdebootstrap -f standard $SUITE $R $MIRROR<br />
cdebootstrap -f standard $SUITE $R $MIRROR</p>
<p>CFG=$R0/config</p>
<p># Create config file<br />
cat &lt;&lt; _KOKO &gt; $CFG<br />
# Auto-generated by: $*<br />
# at $(date)</p>
<p>## Container<br />
lxc.utsname        = $NAME<br />
lxc.rootfs        = $R<br />
lxc.tty            = 6<br />
lxc.pts            = 1024</p>
<p>## Network<br />
lxc.network.type    = veth<br />
lxc.network.hwaddr    = $MAC<br />
lxc.network.link    = $BRIDGEIF<br />
lxc.network.veth.pair    = veth-$NAME</p>
<p>## Capabilities<br />
lxc.cap.drop        = mac_admin<br />
lxc.cap.drop        = mac_override<br />
lxc.cap.drop        = sys_admin<br />
lxc.cap.drop        = sys_module</p>
<p>## Devices<br />
# Allow all device<br />
lxc.cgroup.devices.allow    = a<br />
# Deny all device<br />
lxc.cgroup.devices.deny        = a<br />
# Allow to mknod all devices (but not using them)<br />
lxc.cgroup.devices.allow    = c *:* m<br />
lxc.cgroup.devices.allow    = b *:* m</p>
<p># /dev/console<br />
lxc.cgroup.devices.allow    = c 5:1 rwm<br />
# /dev/fuse<br />
lxc.cgroup.devices.allow    = c 10:229 rwm<br />
# /dev/null<br />
lxc.cgroup.devices.allow    = c 1:3 rwm<br />
# /dev/ptmx<br />
lxc.cgroup.devices.allow    = c 5:2 rwm<br />
# /dev/pts/*<br />
lxc.cgroup.devices.allow    = c 136:* rwm<br />
# /dev/random<br />
lxc.cgroup.devices.allow    = c 1:8 rwm<br />
# /dev/rtc<br />
lxc.cgroup.devices.allow    = c 254:0 rwm<br />
# /dev/tty<br />
lxc.cgroup.devices.allow    = c 5:0 rwm<br />
# /dev/urandom<br />
lxc.cgroup.devices.allow    = c 1:9 rwm<br />
# /dev/zero<br />
lxc.cgroup.devices.allow    = c 1:5 rwm<br />
# /dev/net/tun<br />
lxc.cgroup.devices.allow        = c 10:200 rwm</p>
<p>## Limits<br />
#lxc.cgroup.cpu.shares                  = 1024<br />
#lxc.cgroup.cpuset.cpus                 = 0<br />
#lxc.cgroup.memory.limit_in_bytes       = 256M<br />
#lxc.cgroup.memory.memsw.limit_in_bytes = 1G</p>
<p>## Filesystem<br />
lxc.mount.entry        = proc $R/proc proc nodev,noexec,nosuid 0 0<br />
lxc.mount.entry        = sysfs $R/sys sysfs defaults,ro 0 0</p>
<p>_KOKO</p>
<p># fix interfaces<br />
T=$R/etc/network/interfaces<br />
mv $T $T.orig<br />
(<br />
cat $T.orig \<br />
| sed "s/^iface eth0.*$//"<br />
echo "<br />
auto lo<br />
iface lo inet loopback</p>
<p>auto eth0<br />
iface eth0 inet static<br />
address            $IPADDR2<br />
netmask            255.255.255.0<br />
gateway            $GW<br />
dns-nameservers        $GW<br />
"<br />
) &gt; $T<br />
rm $T.orig</p>
<p># fix resolv.conf<br />
T=$R/etc/resolv.conf<br />
cat &lt;&lt; _KOKO &gt; $T<br />
domain $DOMAIN<br />
search $DOMAIN<br />
nameserver $GW<br />
_KOKO</p>
<p># add info to hosts<br />
T=$R/etc/hosts<br />
echo "$IPADDR2 $NAME $NAME.$DOMAIN" &gt;&gt; $T<br />
echo "$GW gw gw.$DOMAIN $PARENTNAME.$DOMAIN $PARENTNAME" &gt;&gt; $T</p>
<p># set debian_chroot (for help)<br />
echo "lxc-$NAME" &gt;&gt; $R/etc/debian_chroot</p>
<p># create ttys<br />
for i in $(seq 0 6) ; do<br />
mknod $R/dev/tty$i c 4 $i<br />
done</p>
<p>run()<br />
{<br />
echo chroot $R "$@"<br />
LC_ALL=C chroot $R "$@"<br />
}</p>
<p>run2()<br />
{<br />
ssh -o StrictHostKeyChecking=no $IPADDR2 "$@"<br />
}</p>
<p>runmaster()<br />
{<br />
ssh -o StrictHostKeyChecking=no $PUPPETMASTER "$@"<br />
}</p>
<p># Install locales<br />
run apt-get -y install locales</p>
<p># disable init scripts<br />
DISABLED="bootlogd bootlogs checkfs.sh checkroot.sh halt hostname.sh \<br />
hwclockfirst.sh hwclock.sh module-init-tools mountall.sh \<br />
mountdevsubfs.sh mountkernfs.sh mountnfs.sh mountoverflowtmp procps \<br />
reboot stop-bootlogd stop-bootlogd-single udev umountfs umountnfs.sh \<br />
umountroot"<br />
for dis in $DISABLED ; do<br />
run update-rc.d $dis disable<br />
done</p>
<p># disable rsyslog's kernel logging<br />
run sed -i 's/^\(.*imklog.*\)$/#\1/' /etc/rsyslog.conf</p>
<p># add user<br />
run adduser --gecos $VIRTUSER --disabled-password $VIRTUSER<br />
run adduser $VIRTUSER root</p>
<p># fix sources.list<br />
T=$R/etc/apt/sources.list<br />
cat &lt;&lt; _KOKO &gt; $T<br />
deb $MIRROR $SUITE main<br />
_KOKO</p>
<p># Install ssh<br />
run apt-get update<br />
run apt-get -y install openssh-server<br />
run /etc/init.d/ssh stop</p>
<p># Fix root and su<br />
run passwd -l root<br />
T=$R/etc/pam.d/su<br />
mv $T $T.old<br />
cat $T.old \<br />
| sed 's/^# \(.*pam_wheel.so trust\)/\1/' \<br />
&gt; $T<br />
rm $T.old</p>
<p># Add ssh keys<br />
T=$R/home/$VIRTUSER/.ssh/authorized_keys<br />
T2=$R/root/.ssh/authorized_keys<br />
mkdir $R/home/$VIRTUSER/.ssh $R/root/.ssh<br />
for u in $LOCALUSERS ; do<br />
H=$(getent passwd $u | cut -f 6 -d <img src='http://www.v13.gr/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
cat $H/.ssh/id_rsa.pub &gt;&gt; $T<br />
cat $H/.ssh/id_rsa.pub &gt;&gt; $T2<br />
done<br />
chown $VIRTUSER.$VIRTUSER $R/home/$VIRTUSER/.ssh $T<br />
chown root.root $R/home/$VIRTUSER/.ssh $T2</p>
<p># Start it<br />
# Use sudo to bypass file descriptor problems<br />
sudo lxc-start -n $NAME -d<br />
sleep 1</p>
<p>if ! [ -z "$PUPPETMASTER" ] ; then<br />
# Install packages<br />
run2 apt-get -y install puppet</p>
<p># Clear any existing certificate<br />
runmaster puppet cert clean $NAME.$DOMAIN</p>
<p># Fix puppet config<br />
T=$R/etc/default/puppet<br />
mv $T $T.old<br />
cat $T.old \<br />
| sed 's/START=no/START=yes/' \<br />
| sed "s/DAEMON_OPTS=\"\"/DAEMON_OPTS=\"--server=$PUPPETMASTER --verbose\"/" \<br />
&gt; $T<br />
rm -rf $T.old</p>
<p>run2 puppet agent --server=$PUPPETMASTER --no-daemonize --onetime</p>
<p># sign the certificate<br />
runmaster puppet cert --sign $NAME.$DOMAIN</p>
<p>run2 /etc/init.d/puppet start<br />
fi</p>
<p>cat &lt;&lt; _KOKO</p>
<p>LXC virtual box is ready!</p>
<p>Config file is at: $R0/config<br />
Root fs is at: $R</p>
<p>Get a console with:<br />
lxc-console -n $NAME</p>
<p>Stop it with:<br />
lxc-stop -n $NAME</p>
<p>Start it with:<br />
lxc-start -n $NAME -d</p>
<p>_KOKO</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.v13.gr/blog/?feed=rss2&#038;p=192</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>TalkTalk traffic interception</title>
		<link>http://www.v13.gr/blog/?p=161</link>
		<comments>http://www.v13.gr/blog/?p=161#comments</comments>
		<pubDate>Mon, 12 Mar 2012 23:51:51 +0000</pubDate>
		<dc:creator>v13</dc:creator>
				<category><![CDATA[Networks]]></category>
		<category><![CDATA[internet]]></category>

		<guid isPermaLink="false">http://www.v13.gr/blog/?p=161</guid>
		<description><![CDATA[Recently I was really annoyed by my ISP (TalkTalk @ UK). In short: They are intercepting traffic and doing deep packet inspection without any warning or approval. But wait, there&#8217;s more: In general they monitor web traffic (read: the data) and after intercepting an HTTP request the replay that (yes.. they replay the request). Here&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I was really annoyed by my ISP (TalkTalk @ UK).</p>
<p>In short: They are intercepting traffic and doing deep packet inspection without any warning or approval.</p>
<p>But wait, there&#8217;s more: In general they monitor web traffic (read: the data) and after intercepting an HTTP request the replay that (yes.. <span style="text-decoration: underline;">they replay the request</span>).</p>
<p>Here&#8217;s an example:</p>
<p>78.149.130.80 &#8211; - [12/Mar/2012:22:47:23 +0100]<br />
  &quot;GET /korokokokokoLALALALA HTTP/1.1&quot; 404 536 &quot;-&quot;<br />
  &quot;Wget/1.13.4 (linux-gnu)&quot;</p>
<p>62.24.252.133 &#8211; - [12/Mar/2012:22:47:55 +0100]<br />
  &quot;GET /korokokokokoLALALALA HTTP/1.0&quot; 404 498<br />
  &quot;http://&lt;removed&gt;/korokokokokoLALALALA&quot;<br />
  &quot;Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0;<br />
  .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022;<br />
  .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; InfoPath.2)&quot;</p>
<p>The first request was performed by me and it was followed by a second one 32 seconds later (for the unbeliever: this is 100% reproducible). The IP address of the offender is always the same (62.24.252.133).</p>
<p>Digging a bit on this I found these:</p>
<ul>
<li><a href="http://talktalkmembers.net/forums/showthread.php?t=54112">http://talktalkmembers.net/forums/showthread.php?t=54112</a></li>
<li><a href="http://talktalkmembers.net/forums/showthread.php?t=54112">http://www.whatdotheyknow.com/request/the_last_3_months_of_tt_ico</a></li>
</ul>
<p>I don&#8217;t think there are enough things I can say about this. However, here are a couple of them:</p>
<ul>
<li>They shouldn&#8217;t do that</li>
<li>They are a bunch of $#&amp;@%)&amp;#$%</li>
<li>This actually doubles the web traffic that originates from the talktalk network</li>
<li>It can be really harmful as it is possible to trigger a delete action (i.e. when GET is used instead of POST)</li>
<li>It is completely unethical</li>
<li>It is performed even when you have all the security features disabled</li>
<li>Did I say that they are a bunch of @$#)*&amp;%*#$ ?</li>
</ul>
<p>In any case, I started exploiting this a bit:</p>
<p>Fortunately I&#8217;ve a domain under my control and a couple of servers. As such I used one of them that is already running apache and added this rule:</p>
<pre class="brush: bash; title: ;">
iptables -I OUTPUT -d 62.24.252.133 -p tcp --sport 80 \
  -m tcp --tcp-flags SYN '' -j REJECT --reject-with tcp-reset
</pre>
<p>After that I ran this from a PC at home:</p>
<pre class="brush: bash; title: ;">
for b in $(seq 0 9) ; do
 ( (
    for i in $(seq 22${b}00 22${b}99) ; do
      wget http://xxx.xxx.xxx/bad-talktalk-bad-bad-$i ;
    done
  ) &amp; ) ;
done
</pre>
<p>The idea is to create an iptables rule at the server that matches outgoing TCP segments without the SYN flag (iow: segments after the initial 2 SYNs of the handshake) and reset that connection.  The result is that when that host (62.24.252.133) tries to re-fetch the page (i.e. replay the request):</p>
<ul>
<li> It initiates the TCP connection sending a SYN to the server which is accepted</li>
<li>The server replies with SYN+ACK which is normally sent</li>
<li>The offender receives the SYN+ACK so it goes to the ESTABLISHED state, sending an ACK plus some data</li>
<li>The server receives the data and responds with an ACK</li>
<li>The iptables rule takes effect, dropping the packet and responding to the server (itself) with a reset</li>
</ul>
<p>After the above steps, the server closes the connection abnormally and the offender stays with a fully open connection and keeps trying to send the data.</p>
<p>The rational behind that was to exhaust the offender&#8217;s TCP ports by creating &gt;60000 connections.</p>
<p>The good news is that the theory behind that  works. The bad news is that the offender is very slow (most probably on purpose). The good news after that is that it keeps a backlog of the connections and tries to perform them all (or a big part of them).</p>
<p>My tests showed the offender trying to perform connections up to an hour after that.</p>
<p>Here are the results of itpables&#8217; accounting:</p>
<p>Chain OUTPUT (policy ACCEPT 75792 packets, 16M bytes)<br />
pkts bytes target     prot opt in     out     source               destination<br />
14600  584K REJECT     tcp  &#8211;  *      *       0.0.0.0/0            62.24.252.133</p>
<p>Chain INPUT (policy ACCEPT 0 packets, 0 bytes)<br />
pkts bytes target     prot opt in     out     source               destination<br />
28462 6088K ACCEPT     tcp  &#8211;  *      *       62.24.252.133        0.0.0.0/0</p>
<p>The first one is the output rule. The second one is a rule I added for accounting purposes.</p>
<p>So we ended up having 14600 resets sent and 28400 packets from the offender. (note: I only created about 3000 connections)</p>
<p>The day is over but I have other plans as well:</p>
<ul>
<li>Create a bunch (i.e. 100) alternate DNS names for the server and perform the requests against them, pushing the offender to perform more requests in parallel</li>
<li>Write a python program that operates at client side and server side constructing fake TCP packets with predefined sequence numbers and fake IP addresses so that the offender will believe that it will have to follow more than one users.</li>
<li>Study whether the offender it intelligent. It is possible that it only inspects packet payloads for HTTP requests instead of fully reconstructing the whole TCP stream. In that case I&#8217;ll only have to send a large number of data packets with HTTP requests</li>
</ul>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 204px; width: 1px; height: 1px; overflow: hidden;">78.149.130.80 &#8211; - [12/Mar/2012:22:47:23 +0100] &#8220;GET /korokokokokoLALALALA HTTP/1.1&#8243; 404 536 &#8220;-&#8221; &#8220;Wget/1.13.4 (linux-gnu)&#8221;<br />
62.24.252.133 &#8211; - [12/Mar/2012:22:47:55 +0100] &#8220;GET /korokokokokoLALALALA HTTP/1.0&#8243; 404 498 &#8220;http://srv3.v13.gr/korokokokokoLALALALA&#8221; &#8220;Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; InfoPath.2)&#8221;</div>
]]></content:encoded>
			<wfw:commentRss>http://www.v13.gr/blog/?feed=rss2&#038;p=161</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quick fix for X.org screensaver bypass</title>
		<link>http://www.v13.gr/blog/?p=149</link>
		<comments>http://www.v13.gr/blog/?p=149#comments</comments>
		<pubDate>Fri, 27 Jan 2012 15:28:07 +0000</pubDate>
		<dc:creator>v13</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[Xorg]]></category>

		<guid isPermaLink="false">http://www.v13.gr/blog/?p=149</guid>
		<description><![CDATA[This vulnerability is quite annoying if you&#8217;re locking your desktop in work or anywhere else. In short, one is able to kill xorg&#8217;s xscreensaver&#8217;s lock by just pressing alt-ctrl-* or alt-ctrl-/ (both * and / need to be from the keypad). A workaround that was posted suggests to modify files in the system. If you [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://lwn.net/Articles/476134/" target="_blank">This</a> vulnerability is quite annoying if you&#8217;re locking your desktop in work or anywhere else.</p>
<p>In short, one is able to kill xorg&#8217;s xscreensaver&#8217;s lock by just pressing alt-ctrl-* or alt-ctrl-/ (both * and / need to be from the keypad).</p>
<p>A <a href="http://openwall.com/lists/oss-security/2012/01/19/7" target="_blank">workaround that was posted</a> suggests to modify files in the system. If you don&#8217;t want to (like me &#8211; for various reasons) then you can do this on-the-fly.</p>
<p>Put the following script in a file  and make it run whenever you log in to your X session (e.g. by putting it in ~/.kde/Autostart/ if you&#8217;re using KDE):</p>
<pre class="brush: bash; title: ;">
#!/bin/bash

xkbcomp :0 - &gt; /tmp/xkbcomp
cat /tmp/xkbcomp \
 | sed -n '/key &lt;KPMU&gt; {/,/^ *}/ !p' \
 | sed -n '/key &lt;KPDV&gt; {/,/^ *}/ !p' \
 &gt; /tmp/xkbcomp.new
xkbcomp /tmp/xkbcomp.new :0
</pre>
<p>On each login, this will get rid of the offending xkb entries.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.v13.gr/blog/?feed=rss2&#038;p=149</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>fix for radeon + opensource driver + kde effects = crash</title>
		<link>http://www.v13.gr/blog/?p=142</link>
		<comments>http://www.v13.gr/blog/?p=142#comments</comments>
		<pubDate>Fri, 06 Jan 2012 13:50:58 +0000</pubDate>
		<dc:creator>v13</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[kde]]></category>

		<guid isPermaLink="false">http://www.v13.gr/blog/?p=142</guid>
		<description><![CDATA[The problem Kwin crashes when enabling opengl effects. It doesn&#8217;t crash immediately but it crashes after specific actions so it is 100% reproducible. For example when exiting from desktop-grid effect. The situation I&#8217;m using: Radeon 4870 graphics card (RV770) Kernel 3.1.5 (but seems irrelevant) Open source ATI driver with KMS using Gallium Xorg 1.11.2.902 (but [...]]]></description>
			<content:encoded><![CDATA[<h4>The problem</h4>
<p>Kwin crashes when enabling opengl effects. It doesn&#8217;t crash immediately but it crashes after specific actions so it is 100% reproducible. For example when exiting from desktop-grid effect.</p>
<h4>The situation</h4>
<p>I&#8217;m using:</p>
<ul>
<li>Radeon 4870 graphics card (RV770)</li>
<li>Kernel 3.1.5 (but seems irrelevant)</li>
<li>Open source ATI driver with KMS using Gallium</li>
<li>Xorg 1.11.2.902 (but happened with previous versions)</li>
<li>MESA 7.11.2</li>
<li>KDE 4.7.4 from debian</li>
<li>DRM 2.4.29</li>
<li>xserver radeon driver 6.14.3</li>
</ul>
<p>I&#8217;m not using the blur effect</p>
<h4>The solution</h4>
<p>cd to ~/.kde/env/ (create it if it doesn&#8217;t exist)</p>
<p>create a file named gl.sh (or any other name) with execute permissions (should not be needed) and with the following contents:</p>
<pre class="brush: plain; title: ;">
#!/bin/bash

export LIBGL_ALWAYS_INDIRECT=1
</pre>
<p>The first line should not be needed as this file most probably gets source&#8217;d, but it will not hurt.</p>
<h4>The drawback</h4>
<p>Every GL app you&#8217;ll be using will inherit the LIBGL_ALWAYS_INDIRECT from environment, which may cause problems. If you want to play (for example) a game then open a terminal and run:</p>
<pre class="brush: plain; title: ;">
unset LIBGL_ALWAYS_INDIRECT
nexuiz  # or whichever opengl app you want to launch
</pre>
</pre>
<p>Note: Fireofx is one of the applications that may use GL.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.v13.gr/blog/?feed=rss2&#038;p=142</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Big nfs_inode_cache</title>
		<link>http://www.v13.gr/blog/?p=125</link>
		<comments>http://www.v13.gr/blog/?p=125#comments</comments>
		<pubDate>Mon, 02 Jan 2012 10:05:31 +0000</pubDate>
		<dc:creator>v13</dc:creator>
				<category><![CDATA[Administration]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[NFS]]></category>

		<guid isPermaLink="false">http://www.v13.gr/blog/?p=125</guid>
		<description><![CDATA[The story Boxes with various kernel versions have weird free memory problems. After examining the memory usage it seems that processes don&#8217;t add up to the actual memory that is being used. Taking a look at /proc/meminfo we see something like this: MemTotal:      8161544 kB MemFree:        115676 kB Buffers:          3900 kB Cached:         200520 kB SwapCached:      [...]]]></description>
			<content:encoded><![CDATA[<h3>The story</h3>
<p>Boxes with various kernel versions have weird free memory problems. After examining the memory usage it seems that processes don&#8217;t add up to the actual memory that is being used.</p>
<p>Taking a look at /proc/meminfo we see something like this:</p>
<pre class="brush: plain; title: ;">
MemTotal:      8161544 kB
MemFree:        115676 kB
Buffers:          3900 kB
Cached:         200520 kB
SwapCached:      42336 kB
Active:         546824 kB
Inactive:       138336 kB
HighTotal:           0 kB
HighFree:            0 kB
LowTotal:      8161544 kB
LowFree:        115676 kB
SwapTotal:     2096472 kB
SwapFree:       547480 kB
Dirty:            1020 kB
Writeback:           0 kB
AnonPages:      453480 kB
Mapped:          66928 kB
Slab:          7250176 kB
PageTables:      75408 kB
...
</pre>
<p>Notice that Slab is about 7.5GB, almost the whole memory (8GB) (!).</p>
<p>Slab is the kernel memory and we can see where it is allocated by examining /proc/slabinfo. Here&#8217;s an excerpt:</p>
<pre class="brush: plain; title: ;">
# name            &lt;active_objs&gt; &lt;num_objs&gt; &lt;objsize&gt; &lt;objperslab&gt; &lt;pagesperslab&gt; : tunables &lt;limit&gt; &lt;batchcount&gt; &lt;sharedfactor&gt; : slabdata &lt;active_slabs&gt; &lt;num_slabs&gt; &lt;sharedavail&gt;
nfs_direct_cache       0      0    136   28    1 : tunables  120   60    8 : slabdata      0      0      0
nfs_write_data        62     63    832    9    2 : tunables   54   27    8 : slabdata      7      7      0
nfs_read_data        215    297    832    9    2 : tunables   54   27    8 : slabdata     33     33     54
nfs_inode_cache   5384386 5399040   1032    3    1 : tunables   24   12    8 : slabdata 1799680 1799680     40
nfs_page             534    750    128   30    1 : tunables  120   60    8 : slabdata     25     25    264
rpc_buffers            8      8   2048    2    1 : tunables   24   12    8 : slabdata      4      4      0
...
</pre>
<p>Notice the nfs_inode_cache which is 5.3M objects of 1032 bytes each, adding up to about 5.4GB.</p>
<h3>The workaround</h3>
<p>Looking a bit about this on the internet we see that this is most probably a bug. Fortunately there are two workaround: A slow and a fast one:</p>
<p>Slow workaround: Login to that box and run &#8220;sync&#8221;. Then leave it alone for a couple of minutes while the nfs_inode_cache memory goes down and down. It make take a couple of minutes before starting going down and there may be pauses in the process. It can take more than an hour to free the memory.</p>
<p>Fast workaround: Login to that box and run:</p>
<pre class="brush: plain; title: ;">
# sync
# echo 2 &gt; /proc/sys/vm/drop_caches
</pre>
<p>I&#8217;m not sure why the first one works, but it looks like it is triggering a chain reaction that frees the memory.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.v13.gr/blog/?feed=rss2&#038;p=125</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Easy one-time git subtree merge</title>
		<link>http://www.v13.gr/blog/?p=109</link>
		<comments>http://www.v13.gr/blog/?p=109#comments</comments>
		<pubDate>Sun, 20 Nov 2011 13:27:30 +0000</pubDate>
		<dc:creator>v13</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[git]]></category>

		<guid isPermaLink="false">http://www.v13.gr/blog/?p=109</guid>
		<description><![CDATA[The situation: Have a git project (A) Have a second git project (B) that I want to merge to A under a directory This needs to be done once. After that, project B will not be re-sync to A&#8217;s subdirectory Need to preserve history The actual situation: I have a git project that is named [...]]]></description>
			<content:encoded><![CDATA[<p>The situation:</p>
<ul>
<li>Have a git project (A)</li>
<li>Have a second git project (B) that I want to merge to A under a directory</li>
<li>This needs to be done once. After that, project B will not be re-sync to A&#8217;s subdirectory</li>
<li>Need to preserve history</li>
</ul>
<p>The actual situation: I have a git project that is named &#8220;drlaunch&#8221; and another git project that is named &#8220;debian&#8221;. &#8220;debian&#8221; is the packaging directory for drlaunch. The problem occurred because I used to have two svn trees, one for the project and one for the debian/ directory for making this a package for maemo.</p>
<p>I found a number of related things but all of them were complicated because they were doing more than I wanted. Finally, I came to this simple solution:</p>
<p>Under project drlaunch, there is a subdir drlaunch. I want to include the project debian under a directory named debian in the drlaunch project. The tree looks like this:</p>
<pre>drlaunch (project)
\-- drlaunch (dir)

debian (project)</pre>
<p>And at the end I want it to look like this:</p>
<pre>drlaunch (project)
|-- drlaunch (dir)
\-- debian (dir)</pre>
<p>The solution is as simple as this:</p>
<ol>
<li>Go to the debian&#8217;s project dir and export all changes with format-patch:
<pre class="brush: bash; title: ;">
cd debian/
mkdir ../1
git format-patch --root -o ../1/
rm ../1/0000-*
</pre>
<p>(Note: The removal of the first file is required. The file should be empty and for me it triggers a git bug causing it to use 100% cpu indefinitely. Feel free to check it yourself)</li>
<li>Go to the drlaunch&#8217;s project dir and import all changes to a directory:
<pre class="brush: bash; title: ;">
cd drlaunch/
git am --directory=debian/ ../1/*
</pre>
</li>
<li>Ta-da! Ready! Now compare the tree to be sure that nothing bad happend:
<pre class="brush: bash; title: ;">
diff -uR debian ../debian/
</pre>
</li>
</ol>
<p>Don&#8217;t forget to commit your changes.</p>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 1281px; width: 1px; height: 1px; overflow: hidden;">
<pre>$</pre>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.v13.gr/blog/?feed=rss2&#038;p=109</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Multiple Monitors with Opensource Radeon Driver and Xorg</title>
		<link>http://www.v13.gr/blog/?p=94</link>
		<comments>http://www.v13.gr/blog/?p=94#comments</comments>
		<pubDate>Fri, 06 May 2011 11:18:07 +0000</pubDate>
		<dc:creator>v13</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Radeon]]></category>
		<category><![CDATA[Xorg]]></category>

		<guid isPermaLink="false">http://www.v13.gr/blog/?p=94</guid>
		<description><![CDATA[Setting up multiple monitors is currently a nice experience. Doing this from krandrtray, which is a very very nice front-end, is easy. But doing it via xorg.conf can be &#8230; well &#8230; interesting. That&#8217;s mostly because each driver has its own method of properly setting up multiple monitors. Here&#8217;s how to setup multiple monitors with [...]]]></description>
			<content:encoded><![CDATA[<p>Setting up multiple monitors is currently a nice experience. Doing this from krandrtray, which is a very very nice front-end, is easy. But doing it via xorg.conf can be &#8230; well &#8230; interesting. That&#8217;s mostly because each driver has its own method of properly setting up multiple monitors.</p>
<p>Here&#8217;s how to setup multiple monitors with xorg.conf when using the opensource radeon driver (tested with 6.14.1). The tricky part (and the one that took me aprox. 1 hour to figure) is to name the Monitors with the exact same name as the card&#8217;s outputs.</p>
<p>First, you need to launch X at least once with both monitors connected just to find out the output names. Look at /var/log/Xorg.0.log:</p>
<pre class="brush: bash; title: ;">
$ grep 'Output.*connected' /var/log/Xorg.0.log
(II) RADEON(0): Output HDMI-0 connected
(II) RADEON(0): Output DIN disconnected
(II) RADEON(0): Output VGA-0 disconnected
(II) RADEON(0): Output DVI-0 connected
</pre>
<p>From the above search you can see that the connected outputs are named HDMI-0 and DVI-0. You may be able to determine which monitor is connected to which output either by looking up its resolution:</p>
<pre class="brush: plain; title: ;">
(II) RADEON(0): Output HDMI-0 using initial mode 1920x1200
</pre>
<p>or other information in Xorg.0.log</p>
<p>Next you need to create or update /etc/X11/xorg.conf. The required relevant sections are as follows:</p>
<pre class="brush: plain; title: ;">
Section &quot;Monitor&quot;
        Identifier   &quot;HDMI-0&quot;
        Option          &quot;Primary&quot;       &quot;On&quot;
EndSection

Section &quot;Monitor&quot;
        Identifier   &quot;DVI-0&quot;
        Option          &quot;LeftOf&quot;        &quot;HDMI-0&quot;
EndSection

Section &quot;Device&quot;
        Identifier      &quot;Card0&quot;
        Driver          &quot;radeon&quot;
        BusID           &quot;PCI:1:0:0&quot;
        Screen          1
EndSection

Section &quot;Device&quot;
        Identifier      &quot;Card1&quot;
        Driver          &quot;radeon&quot;
        BusID           &quot;PCI:1:0:1&quot;
        Screen          1
EndSection

Section &quot;Screen&quot;
        Identifier &quot;Screen0&quot;
        Device     &quot;Card0&quot;
        Monitor    &quot;HDMI-0&quot;
        DefaultDepth    24
        SubSection &quot;Display&quot;
                Depth     24
                Modes   &quot;1920x1200&quot;
        EndSubSection
EndSection

Section &quot;Screen&quot;
        Identifier &quot;Screen1&quot;
        Device  &quot;Card1&quot;
        Monitor &quot;DVI-0&quot;
        DefaultDepth    24
        SubSection &quot;Display&quot;
                Depth 24
                Modes &quot;1440x900&quot;
        EndSubSection
EndSection

Section &quot;ServerLayout&quot;
        Identifier     &quot;Layout0&quot;
        Screen          &quot;Screen0&quot; 1440 0
        Screen          &quot;Screen1&quot; LeftOf &quot;Screen0&quot;
EndSection
</pre>
<p>Now I&#8217;m not sure about the second &#8220;LeftOf&#8221; because I stopped restarting X and KDM after it worked, but IIRC, it is not required.<br />
As it was mentioned earlier, the tricky part is to named the Monitors as the outputs of the card (HDMI-0 and DVI-0 in my case).<br />
Also, I remember that using the above naming for PciIDs is also required (observer that they are different) and I believe tht the &#8220;Monitor&#8221; statement inside the &#8220;Screen&#8221; section doesn&#8217;t affect anything.</p>
<p>If everything is setup correctly you should see this in Xorg.0.log:</p>
<pre class="brush: plain; title: ;">
(II) RADEON(0): Output HDMI-0 using monitor section HDMI-0
(II) RADEON(0): Output DVI-0 using monitor section DVI-0
</pre>
<p>which indicates that monitor sections where properly matched with outputs.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.v13.gr/blog/?feed=rss2&#038;p=94</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>pyzor problem after debian squeeze upgrade</title>
		<link>http://www.v13.gr/blog/?p=85</link>
		<comments>http://www.v13.gr/blog/?p=85#comments</comments>
		<pubDate>Fri, 18 Feb 2011 11:05:41 +0000</pubDate>
		<dc:creator>v13</dc:creator>
				<category><![CDATA[Administration]]></category>
		<category><![CDATA[Problems/Bugs]]></category>

		<guid isPermaLink="false">http://www.v13.gr/blog/?p=85</guid>
		<description><![CDATA[After upgrading some servers to Debian squeeze, the following log was filling the logs: Feb 18 12:49:38 aetos check[982]: pyzor: [19952] error: TERMINATED, signal 15 (000f) The problem was caused by wrong pyzor servers. Unfortunately, pyzor keeps a servers list in each home directory in file ~/.pyzor/servers. This is what this file used to have: [...]]]></description>
			<content:encoded><![CDATA[<p>After upgrading some servers to Debian squeeze, the following log was filling the logs:</p>
<pre class="brush: plain; title: ;">
Feb 18 12:49:38 aetos check[982]: pyzor: [19952] error: TERMINATED, signal 15 (000f)
</pre>
<p>The problem was caused by wrong pyzor servers. Unfortunately, pyzor keeps a servers list in each home directory in file ~/.pyzor/servers. This is what this file used to have:</p>
<pre class="brush: plain; title: ;">
82.94.255.100:24441
</pre>
<p>This file is created automatically (with a proper value) so it is safe to remove it. That&#8217;s what it should have (for now):</p>
<pre class="brush: plain; title: ;">
public.pyzor.org:24441
</pre>
<p>In order to get rid of the error message all users&#8217; files should be deleted:</p>
<pre class="brush: plain; title: ;">
find /home -name servers | grep pyzor/servers &gt; /tmp/lst
# examine /tmp/lst by hand to verify that nothing bad is there
cd /home
cat /tmp/lst | xargs rm
</pre>
<p>That&#8217;s it. There should be no more &#8220;TERMINATED&#8221; messages.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.v13.gr/blog/?feed=rss2&#038;p=85</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A fast interpreted language</title>
		<link>http://www.v13.gr/blog/?p=70</link>
		<comments>http://www.v13.gr/blog/?p=70#comments</comments>
		<pubDate>Sun, 28 Nov 2010 10:30:04 +0000</pubDate>
		<dc:creator>v13</dc:creator>
				<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.v13.gr/blog/?p=70</guid>
		<description><![CDATA[How can one claim that an interpreted language is fast? Easily. If you implement the language using itself and the resulting interpreter is faster than the original then this means that the interpreted language manages to imprint the prorgammer&#8217;s intentions to the C language (or assembly) better than the programmer herself. For example, I may [...]]]></description>
			<content:encoded><![CDATA[<p>How can one claim that an interpreted language is fast?</p>
<p>Easily. If you implement the language using itself and the resulting interpreter is faster than the original then this means that the interpreted language manages to imprint the prorgammer&#8217;s intentions to the C language (or assembly) better than the programmer herself.</p>
<p>For example, I may create an interpreted language named V using C and try to make the implementation as fast as I can. Of course this means that I have to implement a number of data structures and handle them. Also I have to optimize code path etc etc.</p>
<p>Then I re-implement the V language using the V language itself. If the re-implementation if faster than the original implementation then this means that the interpreter&#8217;s logic produces faster code than me.</p>
<p>Well&#8230; <a href="http://morepypy.blogspot.com/2010/11/pypy-14-ouroboros-in-practice.html">here it is</a>. The Python implementation in Python is faster than the Python implementation using C!</p>
<p>Read: It is very probable to end up with a faster program if you write it using python instead of C because the language will do better than you will in optimizing your data structures and your code. Just like it is better to write C than assembly and let your compiler to produce the optimized assembly code.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.v13.gr/blog/?feed=rss2&#038;p=70</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>World&#8217;s smallest IPv6 compatible web browser program</title>
		<link>http://www.v13.gr/blog/?p=59</link>
		<comments>http://www.v13.gr/blog/?p=59#comments</comments>
		<pubDate>Thu, 25 Nov 2010 21:38:08 +0000</pubDate>
		<dc:creator>v13</dc:creator>
				<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.v13.gr/blog/?p=59</guid>
		<description><![CDATA[For a long time now I&#8217;ve become a fan of the python+Qt combination. It is great to have an easy to learn, easy to use language with great portability and minimalistic syntax. The following program has become my favorite showcase for python. To my knowledge, it is the smallest, easier to understand, portable, IPv6 compatible [...]]]></description>
			<content:encoded><![CDATA[<p>For a long time now I&#8217;ve become a fan of the python+Qt combination. It is great to have an easy to learn, easy to use language with great portability and minimalistic syntax.</p>
<p>The following program has become my favorite showcase for python. To my knowledge, it is the smallest, easier to understand, portable, IPv6 compatible web browser in the world.</p>
<p>If you have IPv6 connectivity just <span style="text-decoration: line-through;">lunch python and copy-paste it</span> save it to a file and run it (it may crash python otherwise):</p>
<pre class="brush: python; title: ;">
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.QtWebKit import *

app=QApplication([])
win=QMainWindow()
w=QWebView(win)
win.setCentralWidget(w)
w.setUrl(QUrl(&quot;http://ipv6.google.com/&quot;))
win.show()
app.exec_()
</pre>
<p>If you don&#8217;t then you can try the IPv4 version:</p>
<pre class="brush: python; title: ;">
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.QtWebKit import *

app=QApplication([])
win=QMainWindow()
w=QWebView(win)
win.setCentralWidget(w)
w.setUrl(QUrl(&quot;http://www.google.com/&quot;))
win.show()
app.exec_()
</pre>
<p>In order to be able to run it you&#8217;ll need the Qt4 library and the python Qt bindings. If you&#8217;re under debian just run:</p>
<pre class="brush: bash; light: true; title: ;">
# apt-get install python-qt4
</pre>
<p>This should work at least under Linux, Windows, Maemo and perhaps Symbian.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.v13.gr/blog/?feed=rss2&#038;p=59</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

