<?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>muhuk.com &#187; vm</title>
	<atom:link href="http://www.muhuk.com/tag/vm/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.muhuk.com</link>
	<description>know thyself</description>
	<lastBuildDate>Thu, 29 Dec 2011 05:05:14 +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>How To Create A Debian VM With Qemu</title>
		<link>http://www.muhuk.com/2010/07/how-to-create-a-debian-vm-with-qemu/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-create-a-debian-vm-with-qemu</link>
		<comments>http://www.muhuk.com/2010/07/how-to-create-a-debian-vm-with-qemu/#comments</comments>
		<pubDate>Wed, 07 Jul 2010 10:26:39 +0000</pubDate>
		<dc:creator>Atamert Ölçgen</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[qemu]]></category>
		<category><![CDATA[share]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[vm]]></category>

		<guid isPermaLink="false">http://www.muhuk.com/?p=375</guid>
		<description><![CDATA[I would like to post my notes as a little tutorial here. I am usually using these virtual machines as cheap staging servers. The first part of this tutorial, you hopefully need to do only once: creating a fresh Debian system. In the second part we will build on this image to create many different [...]<div><a class="addthis_button" href="//addthis.com/bookmark.php?v=250" addthis:url='http://www.muhuk.com/2010/07/how-to-create-a-debian-vm-with-qemu/' addthis:title='How To Create A Debian VM With Qemu '><img src="//cache.addthis.com/cachefly/static/btn/v2/lg-share-en.gif" width="125" height="16" alt="Bookmark and Share" style="border:0"/></a></div>]]></description>
			<content:encoded><![CDATA[<p>I would like to post my notes as a little tutorial here. I am usually using these virtual machines as cheap staging servers. The first part of this tutorial, you hopefully need to do only once: creating a fresh Debian system. In the second part we will build on this image to create many different servers.</p>

<h2>Creating A Base Debian System</h2>

<p>We will create a Qemu machine and install Debian Lenny on it first:</p>

<pre><code># Download Debian image
wget http://debian.osuosl.org/debian-cdimage/current/i386/iso-cd/debian-504-i386-businesscard.iso

# Create base VM image
qemu-img create -f qcow2 debian.qcow2 2G
</code></pre>

<p>Our disk image will have a 2 Gigabyte size limit. You can pick a different size if you need.</p>

<p>Now we need to power on our VM and install Debian:</p>

<pre><code># Install Debian
qemu -enable-kvm -k tr -cdrom debian-504-i386-businesscard.iso -hda debian.qcow2 -boot d
</code></pre>

<p>You don&#8217;t need to allocate a large swap disk, 128MB should do just fine for a file/web server. Also I wouldn&#8217;t bother creating a seperate partition for <code>/home/</code>.</p>

<p>Next let&#8217;s log in as the user (<code>www</code> here) we have created to make final changes:</p>

<pre><code># logged in as user
dpkg-reconfigure console-data
aptitude install ssh sudo
echo "www ALL=(ALL) ALL" &gt;&gt; /etc/sudoers
</code></pre>

<p>At this point you might want to take a backup of <code>debian.qcow2</code>. (Even though we will open it only read-only from now on)</p>

<h2>Creating The Actual VM</h2>

<p>To save time and space we will use copy-on-write disks and re-use <code>debian.qcow2</code>.</p>

<pre><code># Create the actual VM's disk
qemu-img create -f qcow2 -o backing_file=debian.qcow2 actual.qcow2
</code></pre>

<p>Actually we are done. You can log in to your VM using the following command and start installing/configuring/running:</p>

<pre><code>qemu -enable-kvm -k tr -hda actual.qcow2 -net user -net nic \
                                         -redir tcp:5022::22 \
                                         -redir tcp:9080::80
</code></pre>

<p>A few things to note about the command above:</p>

<ul>
<li><code>-enable-kvm</code> is meaningful only if you have <code>kvm</code> kernel module installed. It improves performance a great deal, so it&#8217;s highly recommended.</li>
<li>You probably need to change <code>-k tr</code> according to your keyboard&#8217;s layout.</li>
<li>We are setting up two TCP redirections. 22 is for SSH and 80 is for HTTP. You can add more ports if you need.</li>
</ul>

<p>Finally, I suggest you to prefer SSHing your VM instead of logging in directly:</p>

<pre><code># SSH into the VM
ssh -p 5022 www@localhost
</code></pre>

<p>I hope some of you find this useful.</p>
<div><a class="addthis_button" href="http://www.muhuk.com//addthis.com/bookmark.php?v=250" addthis:url='http://www.muhuk.com/2010/07/how-to-create-a-debian-vm-with-qemu/' addthis:title='How To Create A Debian VM With Qemu '><img src="//cache.addthis.com/cachefly/static/btn/v2/lg-share-en.gif" width="125" height="16" alt="Bookmark and Share" style="border:0"/></a></div><p>No related posts.</p> <p><a href="http://www.muhuk.com/?flattrss_redirect&amp;id=375&amp;md5=d713dc941f47b9510d1c7d27eb397b5c" title="Flattr" target="_blank"><img src="http://www.muhuk.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.muhuk.com/2010/07/how-to-create-a-debian-vm-with-qemu/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<atom:link rel="payment" href="http://www.muhuk.com/?flattrss_redirect&amp;id=375&amp;md5=d713dc941f47b9510d1c7d27eb397b5c" type="text/html" />
	</item>
	</channel>
</rss>

