<?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>Brandon&#039;s Blog &#187; vps</title>
	<atom:link href="http://www.brandonturner.net/blog/tag/vps/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.brandonturner.net/blog</link>
	<description>Random thoughts on web applications, software development and Linux</description>
	<lastBuildDate>Thu, 08 Apr 2010 01:47:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Installing Gentoo 2008.0 amd64 on a Linode VPS</title>
		<link>http://www.brandonturner.net/blog/2009/02/install-gentoo-amd64-linode/</link>
		<comments>http://www.brandonturner.net/blog/2009/02/install-gentoo-amd64-linode/#comments</comments>
		<pubDate>Tue, 10 Feb 2009 05:21:17 +0000</pubDate>
		<dc:creator>Brandon</dc:creator>
				<category><![CDATA[Gentoo]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[Linode]]></category>
		<category><![CDATA[vps]]></category>

		<guid isPermaLink="false">http://www.brandonturner.net/blog/?p=14</guid>
		<description><![CDATA[Linode VPS doesn't provide a Gentoo 2008.0 amd64 image out of the box.  Here I describe the steps needed to install a fresh Gentoo 2008.0 image on Linode.]]></description>
			<content:encoded><![CDATA[<p>Today I signed up for a <a title="Linode.com" href="http://www.linode.com">Linode VPS</a>.  Linode appeared to have great reviews and very reasonable prices.  I had originally looked at <a href="http://www.vr.org">Host Virtual</a>, primarily because they are planning to offer native ipv6 (something I&#8217;ve been wanting to play with) later this month.  I ended up with Linode because they have a Dallas datacenter which makes my connections from Austin pretty fast.</p>
<p>One advantage that Host Virtual provided was a more recent Gentoo image.  Linode only offers a Gentoo 2007.0 install, which it doesn&#8217;t even list as a <em>current distribution</em>.  No worries, in this post I describe the steps I took to install a fresh <strong>Gentoo 2008.0 amd64</strong> image on my new Linode!</p>
<div class="note">
<strong>Update:</strong>  On April 4 2009, Linode released a <a href="http://blog.linode.com/2009/04/04/gentoo-20080-x86_64-and-slackware-122/">Gentoo 2008.0 x86_64</a> image, which somewhat obsoletes this post.  I haven&#8217;t tried it, but if your looking to try 64-bit Gentoo on a Linode, try that image instead of these instructions.
</div>
<p>Before we get started, some of the things I wanted on my system:</p>
<ul>
<li>x86_64 kernel running natively compiled 64-bit applications</li>
<li>ReiserFS filesystem instead of ext3</li>
<li>Basic LAMP server and no more</li>
</ul>
<div class="note">
<strong>Note:</strong> Currently, Linode does not provide a 64-bit recovery option, so we&#8217;ll have to install a small 64-bit environment to use when setting up our new Gentoo environment.  This can be done with only 300MB of disk space so it is best to leave it installed in case your Gentoo environment gets screwed up.
</div>
<h4>1. Create recovery configuration profile</h4>
<ol>
<li>From the Linode Manager Dashboard, click <em>Deploy a Linux Distribution</em></li>
<li>Select an Unbuntu 8.10 64-bit (or similar 64-bit OS) with a 300MB disk drive.  If you want swap space, you should configure that here.</li>
<li>Click <em>Create Profile</em></li>
<li>Change the name of the profile to &#8220;Recovery Ubuntu 64bit&#8221;</li>
</ol>
<h4>2. Create the Gentoo disk image</h4>
<ol>
<li>From the Linode Manager Dashboard, click <em>Create a new Disk Image</em></li>
<li>Give your disk a label (you can change this later) and size (most likely all the remaining disk space on your Linode)</li>
<li>Pick <em>Unformatted / raw</em> for the filesystem, we&#8217;ll format using ReiserFS later</li>
<li>Click <em>Create Disk</em></li>
<li>Edit your Recovery Unbuntu 64bit profile: set /dev/xvdc to the disk image you just created.</li>
<li>Click <em>Save Profile</em></li>
</ol>
<h4>3. Boot the recovery profile</h4>
<ol>
<li>From the Linode Manager Dashboard, boot your recovery profile</li>
<li>Log in with your favorite ssh client: root@<em>&lt;linode vps IP&gt;</em> and the root password you set up in section 1</li>
<li>Install some tools required in later steps:
<div class="prompt">
root@li # <span class="cmd">apt-get update</span><br />
root@li # <span class="cmd">apt-get install reiserfsprogs wget</span>
</div>
</li>
</ol>
<h4>4. Set up Gentoo</h4>
<p style="margin-top: 0;">This section roughly follows the <a href="http://www.gentoo.org/doc/en/gentoo-x86-quickinstall.xml">Gentoo Quick Install Guide</a>.</p>
<ol>
<li>Create the ReiserFS filesystem:
<div class="prompt">
root@li # <span class="cmd">mkreiserfs /dev/xvdc</span>
</div>
<li>Mount the filesystem:
<div class="prompt">
root@li # <span class="cmd">mkdir -p /mnt/gentoo</span><br />
root@li # <span class="cmd">mount /dev/xvdc /mnt/gentoo</span><br />
root@li # <span class="cmd">cd /mnt/gentoo</span>
</div>
</li>
<li>Set up the stage:
<div class="prompt">
root@li # <span class="cmd">wget http://gentoo.osuosl.org/releases/amd64/2008.0/stages/stage3-amd64-2008.0.tar.bz2</span><br />
root@li # <span class="cmd">tar xjpf stage3*</span><br />
root@li # <span class="cmd">rm stage3*</span>
</div>
</li>
<li>Install latest portage snapshot:
<div class="prompt">
root@li # <span class="cmd">cd /mnt/gentoo/usr</span><br />
root@li # <span class="cmd">wget http://gentoo.osuosl.org/snapshots/portage-latest.tar.bz2</span><br />
root@li # <span class="cmd">tar xjf portage-lat*</span><br />
root@li # <span class="cmd">rm portage-lat*</span>
</div>
</li>
<li>Chroot into the new Gentoo environment:
<div class="prompt">
root@li # <span class="cmd">cd /</span><br />
root@li # <span class="cmd">mount -t proc proc /mnt/gentoo/proc</span><br />
root@li # <span class="cmd">mount -o bind /dev /mnt/gentoo/dev</span><br />
root@li # <span class="cmd">cp -L /etc/resolv.conf /mnt/gentoo/etc/</span><br />
root@li # <span class="cmd">chroot /mnt/gentoo /bin/bash</span><br />
li50-172 / # <span class="cmd">env-update &#038;&#038; source /etc/profile</span>
</div>
</li>
<li>Set your timezone:
<div class="prompt">
li50-172 / # <span class="cmd">ls /usr/share/zoneinfo</span><br />
<span style="color: red">(Using US/Central as an example)</span><br />
li50-172 / # <span class="cmd">cp /usr/share/zoneinfo/US/Central /etc/localtime</span><br />
li50-172 / # <span class="cmd">nano -w /etc/conf.d/clock</span><br />
<span style="color: red">(Change value of TIMEZONE variable, e.g. TIMEZONE=&#8221;US/Central&#8221;)</span><br />
li50-172 / # <span class="cmd">date</span><br />
Mon Feb 9 14:41:50 CST 2009
</div>
</li>
<li>Set host and domain name
<div class="prompt">
li50-172 / # <span class="cmd">cd /etc</span><br />
li50-172 etc # <span class="cmd">echo &#8220;127.0.0.1 mybox.at.myplace mybox localhost&#8221; &gt; hosts</span><br />
li50-172 etc # <span class="cmd">sed -i -e &#8216;s/HOSTNAME.*/HOSTNAME=&#8221;mybox&#8221;/&#8217; conf.d/hostname</span><br />
li50-172 etc # <span class="cmd">hostname mybox</span><br />
li50-172 etc # <span class="cmd">hostname -f</span><br />
mybox.at.myplace
</div>
</li>
<li>Configure fstab mount points
<div class="prompt">
li50-172 etc # <span class="cmd">nano -w fstab</span>
</div>
<p style="margin-bottom:0">Edit the fstab file similar to:</p>
<div class="file">
<pre>
/dev/xvda     /       reiserfs     noatime,notail  0 1
/dev/xvdb     none    swap         sw              0 0
</pre>
</div>
</li>
<li>Edit <code>/etc/inittab</code>.<br />
To ensure the lish console works if you ever need it, edit the <code>terminals</code> section of <code>/etc/inittab</code> to look like:</p>
<div class="file">
<pre>
# TERMINALS
c1:12345:respawn:/sbin/agetty 38400 <b>hvc0</b> linux
#c2:2345:respawn:/sbin/agetty 38400 tty2 linux
#c3:2345:respawn:/sbin/agetty 38400 tty3 linux
#c4:2345:respawn:/sbin/agetty 38400 tty4 linux
#c5:2345:respawn:/sbin/agetty 38400 tty5 linux
#c6:2345:respawn:/sbin/agetty 38400 tty6 linux
</pre>
</div>
</li>
<li>Configure networking and SSH:
<div class="prompt">
li50-172 etc # <span class="cmd">rc-update add net.eth0 default</span><br />
 <span style="color: green">*</span> net.eth0 added to runlevel default<br />
li50-172 etc # <span class="cmd">rc-update add sshd default</span><br />
 <span style="color: green">*</span> sshd added to runlevel default<br />
li50-172 etc # <span class="cmd">passwd</span><br />
New UNIX password: <span style="color: red">type_the_password</span><br />
Retype new UNIX password: <span style="color: red">type_the_password_again</span><br />
passwd: password updated successfully
</div>
</li>
<li>Install system tools:
<div class="prompt">
li50-172 etc # <span class="cmd">emerge logrotate syslog-ng vixie-cron reiserfsprogs dhcpcd</span><br />
li50-172 etc # <span class="cmd">rc-update add syslog-ng default</span><br />
 <span style="color: green">*</span> syslog-ng added to runlevel default<br />
li50-172 etc # <span class="cmd">rc-update add vixie-cron default</span><br />
 <span style="color: green">*</span> vixie-cron added to runlevel default
</div>
</li>
<li>Prepare to reboot:
<div class="prompt">
li50-172 etc # <span class="cmd">exit</span><br />
root@li # <span class="cmd">umount /mnt/gentoo/proc /mnt/gentoo/dev/ /mnt/gentoo</span><br />
root@li # <span class="cmd">exit</span>
</div>
</li>
</ol>
<h4>5. Set up Gentoo profile</h4>
<ol>
<li>From the Linode Manager, shutdown the recovery Linode.</li>
<li>Create a new profile by clicking <em>Create a new Configuration Profile</em></li>
<li>Set the following options:
<ul>
<li>Label: Gentoo 2008.0 amd64</li>
<li>Kernel: a 64-bit kernel, e.g. 2.6.27.4-x86_64-linode3</li>
<li>Drive: /dev/xvda:  <em>The disk image you set up in section 2 (<strong>not</strong> the small Ubuntu recovery disk)</em></li>
<li>Drive: /dev/xvdb: Swap Image</li>
</ul>
</li>
</ol>
<h4>6. Boot Gentoo and finish installation</h4>
<ol>
<li>From the Linode Manager, click the <em>Boot</em> button for your new Gentoo profile</li>
<li>Log in via ssh: root@<em>&lt;Linode VPS IP&gt;</em><br />
(You may have to delete the old ssh key out of your known_hosts file on your local machine)</li>
<li>Add a non-root user, install sudo and disable root logins via SSH:
<div class="prompt">
mybox ~ # <span class="cmd">useradd -m -G wheel <em>username</em></span><br />
mybox ~ # <span class="cmd">passwd <em>username</em></span><br />
New UNIX password: <span style="color: red">type_the_password</span><br />
Retype new UNIX password: <span style="color: red">type_the_password_again</span><br />
passwd: password updated successfully<br />
mybox ~ # <span class="cmd">nano -w /etc/ssh/sshd_config</span><br />
<span style="color: red;">(Add a line: <code>PermitRootLogin: no</code>)</span><br />
mybox ~ # <span class="cmd">emerge sudo</span><br />
mybox ~ # <span class="cmd">visudo</span><br />
<span style="color: red;">(Uncomment the line: &#8220;<code>%wheel   ALL=(ALL) ALL</code>&#8220;, around line 24)</span><br />
mybox ~ # <span class="cmd">/etc/init.d/sshd restart</span>
</div>
</li>
<li>Install a simple conservative firewall:
<div class="prompt">
mybox ~ # <span class="cmd">emerge iptables</span><br />
mybox ~ # <span class="cmd">iptables -A INPUT -p tcp -m tcp &#8211;dport 22 -j ACCEPT</span><br />
mybox ~ # <span class="cmd">iptables -A INPUT -p icmp -m icmp &#8211;icmp-type 8 -j ACCEPT</span><br />
mybox ~ # <span class="cmd">iptables -A INPUT -i lo -j ACCEPT</span><br />
mybox ~ # <span class="cmd">iptables -A INPUT -m state &#8211;state RELATED,ESTABLISHED -j ACCEPT</span><br />
mybox ~ # <span class="cmd">iptables -P FORWARD DROP</span><br />
mybox ~ # <span class="cmd">iptables -P INPUT DROP</span><br />
mybox ~ # <span class="cmd">/etc/init.d/iptables save</span><br />
mybox ~ # <span class="cmd">/etc/init.d/iptables start</span><br />
mybox ~ # <span class="cmd">rc-update add iptables default</span><br />
 <span style="color: green">*</span> iptables added to runlevel default
</div>
</li>
<li>Select a Gentoo mirror and update make.conf:
<div class="prompt">
mybox ~ # <span class="cmd">emerge mirrorselect</span><br />
mybox ~ # <span class="cmd">mirrorselect -i -o >> /etc/make.conf</span><br />
mybox ~ # <span class="cmd">mirrorselect -i -r -o >> /etc/make.conf</span><br />
mybox ~ # <span class="cmd">nano -w /etc/make.conf</span>
</div>
<p style="margin-bottom: 0;">Edit the file to include the parts in bold:</p>
<div class="file">
<pre>
# Typical Linode has 4 processors, make use of them when compiling
<strong>MAKEOPTS="-j5"</strong>

<strong>CHOST="x86_64-pc-linux-gnu"</strong>
<strong>CFLAGS="-march=nocona -O2 -pipe"</strong>
<strong>CXXFLAGS="${CFLAGS}"</strong>
</pre>
</div>
<p style="margin-bottom: 0;">At this point you should also run <code>emerge -vpe world</code> and decide what USE variables you want to include in your make.conf file.</p>
</li>
<li>Define locales:
<div class="prompt">
mybox ~ # <span class="cmd">nano -w /etc/locale.gen</span><br />
<span style="color: red;">(Uncomment the first two en_US lines)</span><br />
mybox ~ # <span class="cmd">locale-gen</span>
</div>
</li>
<li>Update portage and installed packages:
<div class="prompt">
mybox ~ # <span class="cmd">emerge portage</span><br />
mybox ~ # <span class="cmd">emerge -vpuD &#8211;newuse world</span><br />
mybox ~ # <span class="cmd">emerge -vUD &#8211;newuse world</span><br />
<span style="color: red;">(Go grab some lunch, this is going to take a while.)</span><br />
mybox ~ # <span class="cmd">emerge &#8211;oneshot libtool</span><br />
mybox ~ # <span class="cmd">emerge gentoolkit</span><br />
mybox ~ # <span class="cmd">revdep-rebuild</span>
</div>
</li>
</ol>
<h4>7. Reboot and enjoy</h4>
<p>At this point I like to reboot the server to ensure that everything comes back up the way I expect it.  This isn&#8217;t necessary however.</p>
<p>After reboot my server was using just under a GB of data (990264 bytes) and about 60MB of RAM.  The server is now ready to install apache, mysql, etc.  I&#8217;ll be looking at optimizing my memory usage in a later post.</p>
<p class="note green" style="font-size: 90%;"><strong>Note:</strong> If you found this helpful and are interesting in signing up for Linode, feel free to use my referral code below.  I&#8217;m only putting this out there if you&#8217;d like to use it &#8211; you can easily sign up for a Linode VPS without it!<br />
<a href="http://www.linode.com/?r=edff465df97bb1e29468836d3700c79a2d24a17e">http://www.linode.com/?r=edff465df97bb1e29468836d3700c79a2d24a17e</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.brandonturner.net/blog/2009/02/install-gentoo-amd64-linode/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>
