<?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>Scienco.org &#187; network bridge</title>
	<atom:link href="http://www.scienco.org/tag/network-bridge/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.scienco.org</link>
	<description>Life&#039;s too short to be unenthusiastic</description>
	<lastBuildDate>Wed, 14 Jul 2010 19:06:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
	<atom:link rel="next" href="http://www.scienco.org/tag/network-bridge/feed/?page=2" />

		<item>
		<title>Ubuntu Server 8.04 as domU</title>
		<link>http://www.scienco.org/2008/ubuntu-server-804-as-domu/</link>
		<comments>http://www.scienco.org/2008/ubuntu-server-804-as-domu/#comments</comments>
		<pubDate>Mon, 04 Aug 2008 10:23:32 +0000</pubDate>
		<dc:creator>Mikkel Meyer Andersen</dc:creator>
				<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Xen]]></category>
		<category><![CDATA[Hetzner]]></category>
		<category><![CDATA[network bridge]]></category>

		<guid isPermaLink="false">http://www.scienco.org/?p=161</guid>
		<description><![CDATA[If you have followed the guide in &#8220;Xen on Ubuntu Server 8.04 (Hardy Heron) with complex disk setup&#8221; or have an environment similar to that, please read on &#8211; if not please read on, too . Since my server is hosted at Hetzner, this guide will be based on that. I want to use network [...]]]></description>
			<content:encoded><![CDATA[<p>If you have followed the guide in <a href="http://www.scienco.org/2008/xen-on-ubuntu-server-804-hardy-heron-with-complex-disk-setup/">&#8220;Xen on Ubuntu Server 8.04 (Hardy Heron) with complex disk setup&#8221;</a> or have an environment similar to that, please read on &#8211; if not please read on, too <img src='http://www.scienco.org/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> . Since my server is hosted at Hetzner, this guide will be based on that. I want to use network bridging.<span id="more-161"></span> To do that you need additional IP-addresses. My host has <code>213.x.x.6</code> and besides that I&#8217;ve got <code>78.x.x.1</code>, <code>78.x.x.2</code>, &#8230;, <code>78.x.x.6</code> (plus a broadcasting address).On my host I&#8217;ve got this:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">root<span style="color: #000000; font-weight: bold;">@</span>host:~<span style="color: #666666; font-style: italic;"># cat /etc/network/interfaces </span>
<span style="color: #666666; font-style: italic;">### Hetzner Online AG - installimage</span>
<span style="color: #666666; font-style: italic;"># Loopback device:</span>
auto lo
iface lo inet loopback
&nbsp;
<span style="color: #666666; font-style: italic;"># device: eth0</span>
auto eth0
iface eth0 inet static
  address 213.x.x.6
  broadcast 213.x.x.31
  netmask 255.255.255.224
  gateway 213.x.x.1
&nbsp;
<span style="color: #666666; font-style: italic;"># default route to access subnet</span>
up route add <span style="color: #660033;">-net</span> 213.x.x.0 netmask 255.255.255.224 gw 213.x.x.1 eth0
&nbsp;
auto eth0:<span style="color: #000000;">1</span>
iface eth0:<span style="color: #000000;">1</span> inet static
  address 78.x.x.1
  broadcast 78.x.x.7
  netmask 255.255.255.248</pre></div></div>

<p>The plan is that the guests will get <code>78.x.x.2</code>, <code>78.x.x.3</code>, etc. and will use <code>78.x.x.1</code> as gateway (you&#8217;ll see this later) &#8211; that&#8217;s why I&#8217;ve assigned it to the host.</p>
<p>Well, after you have found out that Xen kernel is loaded with</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">uname</span> <span style="color: #660033;">-r</span>
xm list</pre></div></div>

<p>you&#8217;ll be ready to proceed.</p>
<p>Now we want to make a domU with Ubuntu Server 8.04 with the program <code>debootstrap</code>. First identify the partitions you want to use. For the root filesystem I&#8217;ll use <code>/dev/lvmstore/lv1</code> and for swap I&#8217;ll use <code>/dev/sda6</code>. To prepare the partitions, please</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">mkfs.xfs <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>lvmstore<span style="color: #000000; font-weight: bold;">/</span>lv1
mkswap <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>sda6</pre></div></div>

<p>Now it&#8217;s time to install the guest system. First mount the root file system like this:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mount</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>lvmstore<span style="color: #000000; font-weight: bold;">/</span>lv1 <span style="color: #000000; font-weight: bold;">/</span>mnt</pre></div></div>

<p>Now just install it with this simple command (depending on your environment you might have to change the <code>--arch</code>-parameter):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">debootstrap <span style="color: #660033;">--arch</span> amd64 hardy <span style="color: #000000; font-weight: bold;">/</span>mnt http:<span style="color: #000000; font-weight: bold;">//</span>archive.ubuntu.com<span style="color: #000000; font-weight: bold;">/</span>ubuntu</pre></div></div>

<p>Now you should copy a couple of files:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>resolv.conf <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>resolv.conf
<span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>apt<span style="color: #000000; font-weight: bold;">/</span>sources.list <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>apt<span style="color: #000000; font-weight: bold;">/</span>sources.list
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>modules<span style="color: #000000; font-weight: bold;">/`</span><span style="color: #c20cb9; font-weight: bold;">uname</span> -r<span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #660033;">-R</span> <span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>modules<span style="color: #000000; font-weight: bold;">/`</span><span style="color: #c20cb9; font-weight: bold;">uname</span> -r<span style="color: #000000; font-weight: bold;">`/*</span> <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>modules<span style="color: #000000; font-weight: bold;">/`</span><span style="color: #c20cb9; font-weight: bold;">uname</span> -r<span style="color: #000000; font-weight: bold;">`/</span></pre></div></div>

<p>Now you should change a couple of files. Now</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">vi</span> <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>network<span style="color: #000000; font-weight: bold;">/</span>interfaces</pre></div></div>

<p>should have the content</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">root<span style="color: #000000; font-weight: bold;">@</span>host:~<span style="color: #666666; font-style: italic;"># cat /mnt/etc/network/interfaces </span>
auto lo
iface lo inet loopback
&nbsp;
auto eth0
iface eth0 inet static
  address 78.x.x.2
  broadcast 78.x.x.7
  netmask 255.255.255.248
  gateway 78.x.x.1</pre></div></div>

<p>Here you see that I&#8217;m using the host as gateway.</p>
<p>And</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">vi</span> <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">hostname</span></pre></div></div>

<p>to change the hostname of the guest.</p>
<p>We also need to change the <code>fstab</code> &#8211; mine looks like this (remember to change <code>xfs</code> to <code>ext3</code> or similar if you&#8217;re not using xfs):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">root<span style="color: #000000; font-weight: bold;">@</span>host:~<span style="color: #666666; font-style: italic;"># cat /mnt/etc/fstab </span>
<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>sda1 <span style="color: #000000; font-weight: bold;">/</span>    xfs  defaults <span style="color: #000000;">1</span> <span style="color: #000000;">2</span>
<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>sda2 none swap sw       <span style="color: #000000;">0</span> <span style="color: #000000;">0</span></pre></div></div>

<p>The names <code>/dev/sda1</code> and <code>/dev/sda2</code> is assigned on a Xen configuration file  we&#8217;ll get to that i a minute.</p>
<p>Now we prepare the network bridge at the host by:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">vi</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>sysctl.conf</pre></div></div>

<p>and change</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#net.ipv4.ip_forward=1</span></pre></div></div>

<p>to</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">net.ipv4.ip_forward=<span style="color: #000000;">1</span></pre></div></div>

<p>We also start the network bridge:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>xen<span style="color: #000000; font-weight: bold;">/</span>scripts<span style="color: #000000; font-weight: bold;">/</span>network-bridge start</pre></div></div>

<p>Now reboot the host to enable the changes in <code>/etc/sysctl.conf</code>. After reboot please check that the bridge is okay:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">brctl show</pre></div></div>

<p>Now we create the file <code>/etc/xen/domU1.conf</code> with this content:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">root<span style="color: #000000; font-weight: bold;">@</span>host:~<span style="color: #666666; font-style: italic;"># cat /etc/xen/domu1.cfg </span>
kernel      = <span style="color: #ff0000;">'/boot/vmlinuz-2.6.24-19-xen'</span>
ramdisk     = <span style="color: #ff0000;">'/boot/initrd.img-2.6.24-19-xen'</span>
memory      = <span style="color: #ff0000;">'512'</span>
maxmem      = <span style="color: #ff0000;">'1536'</span>
&nbsp;
root        = <span style="color: #ff0000;">'/dev/sda1 ro'</span>
disk        = <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">'phy:/dev/lvmstore/lv1,sda1,w'</span>,<span style="color: #ff0000;">'phy:/dev/sda6,sda2,w'</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>
&nbsp;
name        = <span style="color: #ff0000;">'domU1'</span>
&nbsp;
vif	     = <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">'bridge=eth0'</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>
&nbsp;
on_poweroff = <span style="color: #ff0000;">'destroy'</span>
on_reboot   = <span style="color: #ff0000;">'restart'</span>
on_crash    = <span style="color: #ff0000;">'restart'</span>
&nbsp;
vcpus	     = <span style="color: #ff0000;">'2'</span>
extra       = <span style="color: #ff0000;">'xencons=tty1'</span></pre></div></div>

<p>This is the specs of the guest. This is a configuration making you able to ballon the amount of memory to 1,5 GB instead of the initial 512 MB. Please view <code>man xmdomain.cfg</code> for further details.</p>
<p>Now start the guest (the <code>-c</code> means that the console is attached to the guest immediately):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">xm create <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>xen<span style="color: #000000; font-weight: bold;">/</span>domu1.cfg <span style="color: #660033;">-c</span></pre></div></div>

<p>When the environment is started, login with the same password as on your host. Now check the network is okay, change the password, and update the system, respectively:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ping</span> 78.x.x.1
<span style="color: #c20cb9; font-weight: bold;">passwd</span>
<span style="color: #c20cb9; font-weight: bold;">apt-get</span> update
<span style="color: #c20cb9; font-weight: bold;">apt-get</span> upgrade
<span style="color: #c20cb9; font-weight: bold;">apt-get</span> dist-upgrade</pre></div></div>

<p>You&#8217;ll probably see some locales errors. For my case (da_DK) it&#8217;s fixed by this:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">locale-gen da_DK.UTF8
tzselect
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;export LANG=C&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> ~<span style="color: #000000; font-weight: bold;">/</span>.bashrc</pre></div></div>

<p>Please refer to <a href="https://wiki.ubuntu.com/DebootstrapChroot">https://wiki.ubuntu.com/DebootstrapChroot</a> for details regarding this and debootstrap in general.</p>
<p>To shut it down, use</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">init <span style="color: #000000;">0</span></pre></div></div>

<p>You can start the guest without the <code>-c</code>-parameter to start it without the console. Then you can use</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">xm list</pre></div></div>

<p>to check that it&#8217;s running.</p>
<p>At this point I&#8217;d strongly recommend to shut the guest down, reboot the host (dom0) and start everything again. This is to verify that everything is also working after a reboot (before using it in production).</p>
<p>I followed <a href="http://www.howtoforge.com/high-performance-xen-on-ubuntu-8.04-amd64">http://www.howtoforge.com/high-performance-xen-on-ubuntu-8.04-amd64</a> when I installed the guest, but I&#8217;ve done it slightly different and avoided some of the errors.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.scienco.org/2008/ubuntu-server-804-as-domu/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
