<?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>IONCANNON &#187; linux</title>
	<atom:link href="http://www.ioncannon.net/tag/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ioncannon.net</link>
	<description>Thoughts on Software Development and Engineering</description>
	<lastBuildDate>Tue, 03 Jan 2012 13:59:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
	<atom:link rel='hub' href='http://www.ioncannon.net/?pushpress=hub'/>
		<item>
		<title>Minimal EC2 Linux Install Using TTYLinux</title>
		<link>http://www.ioncannon.net/system-administration/1310/minimal_ec2_linux_install_using_ttylinux/</link>
		<comments>http://www.ioncannon.net/system-administration/1310/minimal_ec2_linux_install_using_ttylinux/#comments</comments>
		<pubDate>Tue, 14 Sep 2010 17:22:10 +0000</pubDate>
		<dc:creator>carson</dc:creator>
				<category><![CDATA[system administration]]></category>
		<category><![CDATA[ec2]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[ttylinux]]></category>

		<guid isPermaLink="false">http://www.ioncannon.net/?p=1310</guid>
		<description><![CDATA[If you have ever wondered how to get a Linux EC2 node down to the bare minimum this post is for you. I have been wanting to do this for a long time but it wasn&#039;t possible until pv-grub support that was added recently. To make this even more exciting Amazon now offers EC2 micro [...]]]></description>
			<content:encoded><![CDATA[<p>If you have ever wondered how to get a Linux EC2 node down to the bare minimum this post is for you. I have been wanting to do this for a long time but it wasn&#039;t possible until pv-grub support that was added recently. To make this even more exciting Amazon now offers <a href="http://aws.typepad.com/aws/2010/09/new-amazon-ec2-micro-instances.html">EC2 micro instances</a> that will go well with this type of bare bones system.</p>
<p>You may wonder why you would want to do this. I&#039;ll give you at least two reasons. First there is speed. The configuration I ended up with will boot in about 14 seconds. Almost all of that time is spent waiting on the AWS DHCP server for an IP address. The second reason is security. There is little on this system that you don&#039;t need. The majority of what you need is provided by a single application that you can easily monitor for patches. That leaves you to worry about only the tools you must have to get your job done. I&#039;ll also include a couple downsides. First this isn&#039;t going to be easy for everyone and it can be fairly complicated. The second issue you will run into is that there is nothing in this distribution. If you need something like PHP you might spend a long time building all the support you need. There isn&#039;t much to be done about the complexity if you want to do this all yourself. Selection of tools can help you lessen the impact of the bare nature of the system, more on that in a future post.</p>
<p><span id="more-1310"></span></p>
<p>I picked <a href="http://minimalinux.org/ttylinux/">TTYLinux</a> because that is what I&#039;m most familiar with. I have used it a number of times and I believe it may be the most basic of all the small Linux distros. It really is bare and the large majority of the features are provided by <a href="http://www.busybox.net/">BusyBox</a>. Before attempting to build your own instance it may help to read some of the TTYLinux documentation. Although I haven&#039;t tried I assume that other small distros like DSL would probably work with the same general instructions.</p>
<p>A couple important prerequisites are needed before starting this. First look at the How_To_Build_ttylinux.txt file that comes with the TTYLinux source. It contains a lot of information about how you go about building the system. Next look at my post on <a href="http://www.ioncannon.net/system-administration/1290/how-to-build-compile-a-custom-linux-kernel-for-ec2/">compiling the Linux kernel for EC2</a> because you will need to do that for this TTYLinux instance. Finally you need to have to have gcc, g++ and yacc available on the machine you are going to use to build on.</p>
<p>I have also created a public AMI that anyone can use with the name TTYLinuxBase and AMI ID of ami-0cfe0b65. Be sure to boot it with the correct hd0 kernel for your region. The password for root on this AMI is just password so be sure to change it when you fire it up. I have created the AMI so that the EBS volume gets deleted when it is terminated.</p>
<ol>
<li>Grab the source from <a href="http://minimalinux.org/ttylinux/source.html">the TTYLinux source page</a>:
<pre class="brush: plain; title: ; notranslate">
wget http://minimalinux.org/ttylinux/Download/ttylinux-src-mp3.tar.bz2
tar xvjf ttylinux-src-mp3.tar.bz2
</pre>
</li>
<li>The kernel that comes with the current version of TTYLinux isn&#039;t new enough to work on EC2 so the configuration and build scripts need to be changed to get a more recent version that will. The first step is to create a kernel configuration and put it in the correct location:
<pre class="brush: plain; title: ; notranslate">
ttylinux-src-mp3/config/platform_pc/kernel-2.6.35.4-i686.cfg
</pre>
<p>You can create this configuration by doing a make menuconfig on the kernel you want to use and then saving the kernel configuration to a file. You may also download the <a href="http://www.ioncannon.net/examples/ec2ttylinux/kernel-2.6.35.4-i686.cfg">kernel config</a> I used:</p>
<pre class="brush: plain; title: ; notranslate">
wget http://www.ioncannon.net/examples/ec2ttylinux/kernel-2.6.35.4-i686.cfg
cp kernel-2.6.35.4-i686.cfg ttylinux-src-mp3/config/platform_pc/kernel-2.6.35.4-i686.cfg
</pre>
<p>There is a lot of the kernel that can be pruned from the kernel configuration so if you do this by hand take time to turn things off that you won&#039;t need. Doing so will speed up the kernel compile and make the system boot faster. The above kernel configuration is pruned down quite a bit.
</li>
<li>Copy the packages configuration to one that matches the kernel version:
<pre class="brush: plain; title: ; notranslate">
cp ttylinux-src-mp3/config/platform_pc/packages-2.11-2.6.30.5.txt ttylinux-src-mp3/config/platform_pc/packages-2.11-2.6.35.4.txt
</pre>
</li>
<li>Modify the kernel build script to apply the XSAVE patch. Start by adding the following line to line 132 of the ttylinux-src-mp3/scripts/build-kernel.sh build script:
<pre class="brush: plain; title: ; notranslate">
patch -p1 &lt; /tmp/kernel.patch
</pre>
<p>You should end up with the following around it:</p>
<pre class="brush: plain; title: ; notranslate">
echo -n &quot;b.&quot; &gt;&amp;${CONSOLE_FD}
cp &quot;${kcfg}&quot; &quot;linux-${kver}/.config&quot;
cd &quot;linux-${kver}&quot;
patch -p1 &lt; /tmp/kernel.patch
sed --in-place scripts/mod/sumversion.c \
        --expression=&quot;s|&lt;string.h&gt;| &lt;limits.h&gt;\n#include &lt;string.h&gt;|&quot;
source &quot;${TTYLINUX_XTOOL_DIR}/_xbt_env_set&quot;
</pre>
<p>Create the patch file /tmp/kernel.patch with the following in it:</p>
<pre class="brush: plain; title: ; notranslate">
--- a/arch/x86/xen/enlighten.c  2010-08-05 20:35:13.000000000 -0400
+++ b/arch/x86/xen/enlighten.c  2010-08-05 20:35:22.000000000 -0400
@@ -776,6 +776,7 @@
 {
 	cr4 &amp;= ~X86_CR4_PGE;
 	cr4 &amp;= ~X86_CR4_PSE;
+	cr4 &amp;= ~X86_CR4_OSXSAVE;

 	native_write_cr4(cr4);
 }
</pre>
<p>Note that the above patch file has tabs in it. Make sure there is a tab before each cr4 line and the native_write_cr4 line or download the <a href="http://www.ioncannon.net/examples/ec2ttylinux/kernel.patch">kernel patch</a> file I created.
</li>
<li>Select the correct build target in the ttylinux-src-mp3/ttylinux.dist-config.sh file. Find the TTYLINUX_TARGET lines, comment them all out and then add the following line:
<pre class="brush: plain; title: ; notranslate">
TTYLINUX_TARGET=&quot;i686:pc:2.11-2.6.35.4&quot;
</pre>
</li>
<li>Set up the cross compile tools build directory:
<pre class="brush: plain; title: ; notranslate">
cp -Rp ttylinux-src-mp3/cross-tools-2.11-2.6.30.5/ ttylinux-src-mp3/cross-tools-2.11-2.6.35.4/
</pre>
<p>Find XBT_KERNEL in the script ttylinux-src-mp3/cross-tools-2.11-2.6.35.4/_scripts/xbt-versions.sh and change it to:</p>
<pre class="brush: plain; title: ; notranslate">
XBT_KERNEL=&quot;linux-2.6.35.4&quot;
</pre>
</li>
<li>Build the cross compile tools:
<pre class="brush: plain; title: ; notranslate">
cd ttylinux-src-mp3/cross-tools-2.11-2.6.35.4
make setup
make dload
make i686
cd ..
</pre>
</li>
<li>Build the entire TTYLinux distro:
<pre class="brush: plain; title: ; notranslate">
make dist
</pre>
<p>From this point the instructions are just like the last few posts I have made. The distribution created in here needs to be transferred to an EBS volume and made into an AMI.
</li>
<li>Using a temporary EC2 instance create a volume that will be used to boot the install and give it a file system:
<pre class="brush: plain; title: ; notranslate">
ec2-create-volume -z us-east-1a -s 1
ec2-attach-volume volume-id -i instance-id -d /dev/sdh
mkfs.ext3 /dev/sdh
</pre>
</li>
<li>Transfer the TTYLinux distribution image that was created to the temporary EC2 instance. Then copy the image to the boot volume:
<pre class="brush: plain; title: ; notranslate">
mkdir /mnt/dest
mkdir /mnt/src
mount /dev/sdh /mnt/dest
mount -o loop img/file_sys-i686-11.2.img /mnt/src
cd /mnt/src
find . | cpio -pvd /mnt/dest
cd -
cp config/boot/* /mnt/dest/boot/
umount /mnt/src
</pre>
<p>In the above the boot volume is mounted, the TTYLinux distribution image is mounted via a loop device and then all the files are copied from the image to the boot volume. I do a copy here because the default boot image that the TTYLinux build creates is only 8M and the smallest EBS volume you can create is 1G so it is better to use what you have to have.
</li>
<li>While the boot volume is mounted there are a number of things that need to be configured that are different than some of the previous examples of booting custom systems in EC2. First set the password for root by using chroot:
<pre class="brush: plain; title: ; notranslate">
chroot /mnt/dest/ passwd
</pre>
<p>Next change the root device in fstab:</p>
<pre class="brush: plain; title: ; notranslate">
cat &lt;&lt;EOF &gt; /mnt/dest/etc/fstab
/dev/xvda1    /            ext3       defaults                      0 0
tmpfs         /dev         tmpfs      noauto                        0 0
devpts        /dev/pts     devpts     gid=5,mode=0620               0 0
tmpfs         /dev/shm     tmpfs      rw,noexec,nosuid,size=24k     0 0
proc          /proc        proc       noauto                        0 0
sysfs         /sys         sysfs      noauto                        0 0
EOF
</pre>
<p>Then modify the inittab to only create one terminal:</p>
<pre class="brush: plain; title: ; notranslate">
cat &lt;&lt;EOF &gt; /mnt/dest/etc/inittab
::sysinit:/etc/rc.d/rc.sysinit

tty1::respawn:/sbin/getty 38400 tty1

::ctrlaltdel:/sbin/reboot
::shutdown:/etc/rc.d/rc.sysdone
EOF
</pre>
<p>Then configure the network to start on boot:</p>
<pre class="brush: plain; title: ; notranslate">
cat &lt;&lt;EOF &gt; /mnt/dest/etc/sysconfig/network-scripts/ifcfg-eth0
ENABLE=yes
NAME=Ethernet
IPADDRESS=192.168.1.20
CIDRLEN=24
NETWORK=192.168.1.0
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
BROADCAST=192.168.1.255
DHCP=yes
EOF
</pre>
<p>Finally, If you want to get rid of the warnings about setting the hardware clock you can edit /mnt/dest/etc/rc.d/rc.sysdone and comment out the part that tries to set it:</p>
<pre class="brush: plain; title: ; notranslate">
# Disabled for XenU use
#if [[ &quot;$(uname -m)&quot; != armv5tej* ]]; then
#     action $&quot;syncing hardware clock to system time&quot; hwclock ${HWCLOCKARGS}
#fi
</pre>
<p>and you will also want to do the same to /mnt/dest/etc/rc.d/rc.sysinit:</p>
<pre class="brush: plain; title: ; notranslate">
# Disabled for XenU
#if [[ &quot;$(uname -m)&quot; != armv5tej* ]]; then hwclock ${HWCLOCKARGS}; fi
</pre>
</li>
<li>To tell pv-grub what to boot you will need a /boot/grub/menu.lst file with the following in it:
<pre class="brush: plain; title: ; notranslate">
mkdir /mnt/dest/boot/grub

cat &lt;&lt;EOF &gt; /mnt/dest/boot/grub/menu.lst
default 0
timeout 0
title TTYOS
        root (hd0)
        kernel /boot/vmlinuz root=/dev/xvda1
EOF
</pre>
<p>Unmount the boot image:</p>
<pre class="brush: plain; title: ; notranslate">
umount /mnt/dest/
</pre>
</li>
<li>Snapshot the volume and register it as an AMI:
<pre class="brush: plain; title: ; notranslate">
ec2-create-snapshot -d &quot;Volume Description&quot; volume-id
ec2-register -n &quot;AMIName&quot; -d &quot;AMI Description&quot; --root-device-name /dev/sda1 -b /dev/sda1=snap-id:1:true
</pre>
</li>
<li>Boot it using the hd0 kernel for your region (in my case that is aki-407d9529):
<pre class="brush: plain; title: ; notranslate">
ec2-run-instances -z us-east-1a -g your-group -k your-keypair -n 1 --kernel pv-grub-kernel-id ami-from-step-13
</pre>
</li>
</ol>
<p>There are a few final notes that might be interesting. The smallest you can create is 1G and that is about 950M too large. This is probably not a real issue since you will most likely want space to put your application but it is interesting to note. The instructions assume you are building a i386 instance but they are almost the same for a 64 bit instance.</p>
<p>With the kernel config I provide you will see boot times from start to init in about 0.3 seconds. That is pretty fast. From init to login is fast as well but depends completely on how long it takes to get an IP from the DHCP server. This type of system could potentially boot in just a second or two if it didn&#039;t have to wait for any AWS parts.</p>
<p>A few people have created <a href="http://minimalinux.org/ttylinux/addons.html">TTY addons</a> to make compiling code for TTYLinux easier. You may want to check those out. Baring that you will find instructions on building anything with the cross compiling system in the TTYLinux howto documentation. Of course you may be able to bypass any pain there by compiling static binaries or even using something like Java.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ioncannon.net/system-administration/1310/minimal_ec2_linux_install_using_ttylinux/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>How to Build and Compile a Custom Linux Kernel for EC2</title>
		<link>http://www.ioncannon.net/system-administration/1290/how-to-build-compile-a-custom-linux-kernel-for-ec2/</link>
		<comments>http://www.ioncannon.net/system-administration/1290/how-to-build-compile-a-custom-linux-kernel-for-ec2/#comments</comments>
		<pubDate>Thu, 09 Sep 2010 14:55:58 +0000</pubDate>
		<dc:creator>carson</dc:creator>
				<category><![CDATA[system administration]]></category>
		<category><![CDATA[AWS]]></category>
		<category><![CDATA[ec2]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://www.ioncannon.net/?p=1290</guid>
		<description><![CDATA[I have a long running goal that I&#039;m trying to reach with all these pv-grub for EC2 posts. That goal is to find the smallest/tightest usable node that can be created for EC2. The next step in that path requires a custom Linux kernel. What follows is how to build the latest Linux kernel so [...]]]></description>
			<content:encoded><![CDATA[<p>I have a long running goal that I&#039;m trying to reach with all these <a href="http://aws.typepad.com/aws/2010/07/use-your-own-kernel-with-amazon-ec2.html">pv-grub for EC2</a> posts. That goal is to find the smallest/tightest usable node that can be created for EC2. The next step in that path requires a custom Linux kernel. What follows is how to build the latest Linux kernel so that it works on EC2 using pv-grub.</p>
<p>It is important to have a recent kernel since most of what is needed to get a kernel to work on EC2 is now incorporated into the source. These instructions assume the latest kernel is 2.6.35.4 and I&#039;ve used them with 2.6.35 as well but keep that in mind since the one patch that is required could eventually be merged in. Before getting started it may help to read over how to <a href="http://www.faqs.org/docs/Linux-HOWTO/Kernel-HOWTO.html">compile the Linux kernel</a> normally and then my post on <a href="http://www.ioncannon.net/system-administration/1205/installing-cent-os-5-5-on-ec2-with-the-cent-os-5-5-kernel/">running CentOS 5.5 on EC2 using pv-grub</a>.</p>
<p><span id="more-1290"></span></p>
<p>Before you begin you will need a place to build the kernel. For these instructions I used an EC2 instance to build the kernel but you don&#039;t have to. I also installed the kernel on the same EC2 instance when I was done. The AMI I used was Amazon&#039;s EBS boot starter ( ami-b232d0db : amazon/getting-started-with-ebs-boot ).</p>
<p>The following steps go over building and installing the kernel in detail:</p>
<ol>
<li>Download the latest <a href="http://www.kernel.org/">Linux kernel</a> or the version I&#039;m using:
<pre class="brush: plain; title: ; notranslate">
wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.35.4.tar.bz2
</pre>
</li>
<li>Configure the source to run on EC2:
<pre class="brush: plain; title: ; notranslate">
make menuconfig
</pre>
<p>You will need to make sure the following options are set in the configuration:</p>
<ul>
<li>&#034;Processor type and features&#034; -> &#034;High Memory Support&#034; -> Make sure it is set to 64GB</li>
<li>&#034;Processor type and features&#034; -> &#034;PAE (Physical Address Extension) Support&#034; -> enable</li>
<li>&#034;Processor type and features&#034; -> &#034;Paravirtualized guest support&#034; -> enable</li>
<li>&#034;Processor type and features&#034; -> &#034;Paravirtualized guest support&#034; -> &#034;Xen guest support&#034; -> enable</li>
<li>&#034;Device Drivers&#034; -> &#034;Block devices&#034; -> &#034;Xen virtual block device support&#034; -> enable either as a module or built in</li>
<li>&#034;Device Drivers&#034; -> &#034;Network device support&#034; -> &#034;Xen network device frontend driver&#034; -> enable either as a module or built in</li>
</ul>
<p> <br/></p>
<p>If you want you can make the device drivers modules but you have to have them so it is probably best to just compile them into the kernel itself. If you want to compare your config file with the one I used you can download mine here: <a href="http://www.ioncannon.net/examples/ec2kernel/kernel-2.6.35.4-i686.config">kernel-2.6.35.4-i686.config</a>.</p>
<p>The starter AMI I used needed ncurses development libraries and gcc installed for menuconfig to work:</p>
<pre class="brush: plain; title: ; notranslate">
yum install ncurses-devel gcc
</pre>
<p>If you want to know a little more about what is being enabled in this step see the &#034;Building with domU support&#034; section of <a href="http://wiki.xensource.com/xenwiki/XenParavirtOps">XenParavirtOps</a>.
</li>
<li>Apply the following patch to disable XSAVE:
<pre class="brush: plain; title: ; notranslate">
--- a/arch/x86/xen/enlighten.c	2010-08-05 20:35:13.000000000 -0400
+++ b/arch/x86/xen/enlighten.c	2010-08-05 20:35:22.000000000 -0400
@@ -776,6 +776,7 @@
 {
 	cr4 &amp;= ~X86_CR4_PGE;
 	cr4 &amp;= ~X86_CR4_PSE;
+	cr4 &amp;= ~X86_CR4_OSXSAVE;

 	native_write_cr4(cr4);
 }

cd /path/to/root/of/kernel/source

patch -p1 &lt; /tmp/kernel.patch
</pre>
<p>Note that the above patch file has tabs in it. Make sure there is a tab before each cr4 line and the native_write_cr4 line. If you want to you can download a copy of the <a href="http://www.ioncannon.net/examples/ec2kernel/kernel.patch">patch with the tabs in it</a> to be sure.
</li>
<li>Build the kernel and install it if you are on the same machine you want to install it on. If you need help compiling the kernel refer to the kernel compile howto. <br/><br/>
<p>After this step you have a kernel, modules and initrd that you can use. The remaining steps go over using it.
</li>
<li>Configure the /boot/grub/menu.lst file on the target AMI to use the new kernel, the following is an example of the contents of the file:
<pre class="brush: plain; title: ; notranslate">
default 0
timeout 1
title Test
     root (hd0)
     kernel /boot/vmlinuz-2.6.35.4 root=/dev/xvda1
     initrd /boot/initrd-2.6.35.4.img
</pre>
<p>Note that the root device here is /dev/xvda1 instead of /dev/sda1. This is caused by the XSAVE patch.
</li>
<li>Verify that your /etc/fstab file is correct. If your previous root device was /dev/sda1 it is going to be /dev/xvda1 now. The contents of the fstab file I used follow:
<pre class="brush: plain; title: ; notranslate">
/dev/xvda1                              /                       ext3    defaults 1 1
/dev/mapper/swapVG-swapFS               swap                    swap    defaults 0 0
/dev/mapper/storageVG-storageFS         /mnt                    ext3    defaults 0 0
none                                    /dev/pts                devpts  gid=5,mode=620 0 0
none                                    /dev/shm                tmpfs   defaults 0 0
none                                    /proc                   proc    defaults 0 0
none                                    /sys                    sysfs   defaults 0 0
</pre>
</li>
<li>Make a snapshot of the volume and register it as an AMI:
<pre class="brush: plain; title: ; notranslate">
ec2-create-snapshot -d &quot;Snapshot Description&quot; volume-id
ec2-register -n &quot;CustomKernel&quot; -d &quot;Custom kernel AMI&quot; --root-device-name /dev/sda1 -b /dev/sda1=snap-id:15:true
</pre>
<p>Note that the devices here are /dev/sda1 and not /dev/xvda1. That is a little confusing but the AWS system doesn&#039;t see the devices in the same way your AMI will once it is booted.
</li>
<li>Start the instance. In my case using the hd0 pv-grub kernel:
<pre class="brush: plain; title: ; notranslate">
ec2-run-instances -z us-east-1a -g your-group -k your-keypair -n 1 --kernel aki ami-from-step-7
</pre>
</li>
</ol>
<p>If all goes well you should be able to run dmesg and see a boot message something like the following at the top:</p>
<pre class="brush: plain; title: ; notranslate">
Reserving virtual address space above 0xf5800000
Linux version 2.6.35.4 (root@domU) (gcc version 4.1.2 20070925 (Red Hat 4.1.2-33)) #2 SMP Mon Aug 23 20:00:01 EDT 2010
BIOS-provided physical RAM map:
 Xen: 0000000000000000 - 00000000000a0000 (usable)
 Xen: 00000000000a0000 - 0000000000100000 (reserved)
 Xen: 0000000000100000 - 000000006a400000 (usable)
NX (Execute Disable) protection: active
...
</pre>
<p>With the ability to create a custom kernel for EC2 the next step is to prune the OS itself down to the bare minimum.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ioncannon.net/system-administration/1290/how-to-build-compile-a-custom-linux-kernel-for-ec2/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Installing Cent OS 5.5 on EC2 with the Cent OS 5.5 Kernel</title>
		<link>http://www.ioncannon.net/system-administration/1205/installing-cent-os-5-5-on-ec2-with-the-cent-os-5-5-kernel/</link>
		<comments>http://www.ioncannon.net/system-administration/1205/installing-cent-os-5-5-on-ec2-with-the-cent-os-5-5-kernel/#comments</comments>
		<pubDate>Tue, 10 Aug 2010 10:51:37 +0000</pubDate>
		<dc:creator>carson</dc:creator>
				<category><![CDATA[system administration]]></category>
		<category><![CDATA[AWS]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[ec2]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://www.ioncannon.net/?p=1205</guid>
		<description><![CDATA[Amazon recently introduced the ability to boot a custom kernel using pv-grub on EC2. This opens the door for all kinds of interesting ideas that I&#039;ve been thinking about for a while, like seeing if I can boot right into a web server and skip all that extra junk that comes with Linux distributions, but [...]]]></description>
			<content:encoded><![CDATA[<p>Amazon recently introduced the ability to <a href="http://aws.typepad.com/aws/2010/07/use-your-own-kernel-with-amazon-ec2.html">boot a custom kernel</a> using pv-grub on EC2. This opens the door for all kinds of interesting ideas that I&#039;ve been thinking about for a while, like seeing if I can boot right into a web server and skip all that extra junk that comes with Linux distributions, but that is just me. The main door it is going to open for most people interested in EC2 will be the ability to upgrade the kernel that comes with their distribution. That brings us to how to install Cent OS 5.5 on EC2 and use the kernel that is part of the distribution.</p>
<p>For those who might just be interested in booting a custom kernel using EC2 pv-grub I will try to produce a few more posts with more details on that but for now here are the main things to know:</p>
<ul>
<li>The pv-grup kernels named with hd00 will look on the first partition of the registered device in the /boot/boot/grub directory for a menu.lst file. Use this type of kernel if you create want to use a partitioned disk.</li>
<li>The pv-grup kernels named with hd0 will look on the registered device in the /boot/grub directory for a menu.lst file. Use this type of kernel if you don&#039;t have a partition on your disk.</li>
<li>You won&#039;t get anything meaningful back from the boot attempt if your grub menu.lst file is in the wrong place or is not valid. See the end of the post for what a pv-grub error message looks like and some tips on what to do if you see it.</li>
<li>The kernel you use does matter but the current mainline Linux kernel (2.6.35) contains everything you need except for a small change to turn off XSAVE. The main thing to know is that not every distribution may have made the change needed to work on EC2.</li>
<li>I have tried non-Linux kernels to no avail. See the end of the post for a little more information.</li>
</ul>
<p><span id="more-1205"></span></p>
<p>A lot of what follows is similar, both steps and concepts, to the &#034;from scratch&#034; section of my post on <a href="http://www.ioncannon.net/system-administration/894/fedora-12-bootable-root-ebs-on-ec2/">Fedora 12 on EC2 using a root EBS</a>. I&#039;ve also bundled all the instance building commands up into one <a href="http://www.ioncannon.net/examples/centos5.5.sh">script (centos5.5.sh)</a>. If you want to use that script then do 1 and 2 of what follows, make sure to change the password used for root in the script and then pick back up at 18. The following steps should not be taken as the only way to do this but more of a recipe:</p>
<ol>
<li>
Start an EC2 instance that has yum on it to be used as a setup box. A RedHat based box, Fedora or CentOS will work best unless you want to install yum. For the following steps I used a Fedora 8 based EC2 node.</p>
<pre class="brush: plain; title: ; notranslate">
ec2-run-instances -z us-east-1a -g your-group -k your-keypair -n 1 ami-84db39ed
</pre>
</li>
<li>
Create a new EBS volume to install to and map it to the running instance from step 1. Your volume should be greater than 2G for a base install. I mapped this new volume to the /dev/sdh device on the setup machine so you will notice that in the following steps (if you are using the script you will want to make sure you map to /dev/sdh as well):</p>
<pre class="brush: plain; title: ; notranslate">
ec2-create-volume -z us-east-1a -s 2
ec2-attach-volume volume-id -i instance-id -d /dev/sdh
</pre>
</li>
<li>
<p>Create a <a href="http://tldp.org/HOWTO/Partition/fdisk_partitioning.html">partion table using fdisk</a> on the volume you are going to install to.</p>
<p>I created both a /boot and / partion on /dev/sdh1 and /dev/sdh2 respecivly. I also made the /dev/sdh1 partition active so it is exactly as it would be if it had been installed on a real machine.</p>
<p>Note that this step is optional but I am going to include it because I think it makes for a more natural setup and is more in line with what you would get if you did a VirtualBox install and then transfered the image.
</li>
<li>
Format your partition(s) and mount them into /mnt. For me that was done with the following:</p>
<pre class="brush: plain; title: ; notranslate">
echo &quot;y&quot; | mkfs.ext3 /dev/sdh1
echo &quot;y&quot; | mkfs.ext3 /dev/sdh2
mount /dev/sdh2 /mnt
mkdir /mnt/boot
mkdir /mnt/dev
mkdir /mnt/proc
mkdir /mnt/etc
mount /dev/sdh1 /mnt/boot
mount -t proc none /mnt/proc
</pre>
</li>
<li>
Create a base device setup for the new instance:</p>
<pre class="brush: plain; title: ; notranslate">
for i in console null zero ; do /sbin/MAKEDEV -d /mnt/dev -x $i ; done
</pre>
</li>
<li>
Create a base fstab file in /mnt/etc/fstab. The following is the one I used:</p>
<pre class="brush: plain; title: ; notranslate">
/dev/sda1               /boot                   ext3    defaults 1 1
/dev/sda2               /                       ext3    defaults 1 2
none                    /dev/pts                devpts  gid=5,mode=620 0 0
none                    /dev/shm                tmpfs   defaults 0 0
none                    /proc                   proc    defaults 0 0
none                    /sys                    sysfs   defaults 0 0
/dev/sdc1               /mnt                    ext3    defaults 0 0
/dev/sdc2               swap                    swap    defaults 0 0
</pre>
</li>
<li>
Create the yum repo configuration, prepare for the yum install and then install the base OS onto the new volume.<br/><br/></p>
<p>The following is the yum configuration file I used:</p>
<pre class="brush: plain; title: ; notranslate">
[main]
cachedir=/var/cache/yum
debuglevel=2
logfile=/var/log/yum.log
exclude=*-debuginfo
gpgcheck=0
obsoletes=1
reposdir=/dev/null

[os]
name=CentOS 5.5 - i386 - OS
mirrorlist=http://mirrorlist.centos.org/?release=5&amp;arch=i386&amp;repo=os
enabled=1

[updates]
name=CentOS 5.5 - i386 - Updates
mirrorlist=http://mirrorlist.centos.org/?release=5&amp;arch=i386&amp;repo=updates
enabled=1
</pre>
<p>The following command will install the base of Cent OS 5.5 into /mnt (note that I created the above config file as /tmp/yumec2.conf):</p>
<pre class="brush: plain; title: ; notranslate">
yum -c /tmp/yumec2.conf --installroot=/mnt -y groupinstall Base
</pre>
</li>
<li>
Install sshd, grub, the Cent OS Xen kernel and then clean the repo to free up disk space:</p>
<pre class="brush: plain; title: ; notranslate">
yum -c /tmp/yumec2.conf --installroot=/mnt -y install openssh-server
yum -c /tmp/yumec2.conf --installroot=/mnt -y install grub
yum -c /tmp/yumec2.conf --installroot=/mnt -y install kernel-xen.i686

yum -c /tmp/yumec2.conf --installroot=/mnt -y clean packages
</pre>
</li>
<li>
Disable DNS checks and allow root to log in via SSH:</p>
<pre class="brush: plain; title: ; notranslate">
echo &quot;UseDNS no&quot; &gt;&gt; /mnt/etc/ssh/sshd_config
echo &quot;PermitRootLogin yes&quot; &gt;&gt; /mnt/etc/ssh/sshd_config
</pre>
</li>
<li>
Set up networking by creating the /mnt/etc/sysconfig/network file. The contents for this example are:</p>
<pre class="brush: plain; title: ; notranslate">
NETWORKING=yes
</pre>
<p>As well as the /mnt/etc/sysconfig/network-scripts/ifcfg-eth0 file. The contents for this example are:</p>
<pre class="brush: plain; title: ; notranslate">
DEVICE=eth0
BOOTPROTO=dhcp
ONBOOT=yes
TYPE=Ethernet
USERCTL=yes
PEERDNS=yes
IPV6INIT=no
</pre>
</li>
<li>
I&#039;m not sure if this is needed still but in the past there have been some /dev file missing on boot so I always add the following to the startup script to make sure they are available. The first two are the random devices and the last three are where the ephimeral drive is usually mapped:</p>
<pre class="brush: plain; title: ; notranslate">
echo &quot;/sbin/MAKEDEV /dev/urandom&quot; &gt;&gt; /mnt/etc/rc.sysinit
echo &quot;/sbin/MAKEDEV /dev/random&quot; &gt;&gt; /mnt/etc/rc.sysinit
echo &quot;/sbin/MAKEDEV /dev/sdc&quot; &gt;&gt; /mnt/etc/rc.sysinit
echo &quot;/sbin/MAKEDEV /dev/sdc1&quot; &gt;&gt; /mnt/etc/rc.sysinit
echo &quot;/sbin/MAKEDEV /dev/sdc2&quot; &gt;&gt; /mnt/etc/rc.sysinit
</pre>
</li>
<li>
Change the root password for the new instance. This is optional as you could create scripts to download your SSH key from EC2 but for these instructions setting the root password is the easiest:</p>
<pre class="brush: plain; title: ; notranslate">
chroot /mnt
pwconv
passwd
exit
</pre>
</li>
<li>
Change the network settings so that the NetworkManager is off and network is on</p>
<pre class="brush: plain; title: ; notranslate">
chroot /mnt chkconfig --level 2345 NetworkManager off
chroot /mnt chkconfig --level 2345 network on
</pre>
</li>
<li>
Disable a few things that are enabled by default but won&#039;t do any good for an EC2 instance:</p>
<pre class="brush: plain; title: ; notranslate">
chroot /mnt chkconfig --level 2345 avahi-daemon off
chroot /mnt chkconfig --level 2345 firstboot off
</pre>
</li>
<li>
The stock CentOS Xen initrd doesn&#039;t load the Xen block or net drivers and those are required to boot. I unpacked the installed initrd and created a modified version by hand using the following commands (note that as soon as the CentOS Xen kernel version changes this will stop functioning):</p>
<pre class="brush: plain; title: ; notranslate">
cp /mnt/boot/initrd-2.6.18-194.8.1.el5xen.img /mnt/boot/initrd-2.6.18-194.8.1.el5xen.img.orig
mkdir /tmp/initrdextract
cd /tmp/initrdextract
gzip -dc /mnt/boot/initrd-2.6.18-194.8.1.el5xen.img | cpio -id
cp /mnt/lib/modules/2.6.18-194.8.1.el5xen/kernel/drivers/xen/blkfront/xenblk.ko lib
cp /mnt/lib/modules/2.6.18-194.8.1.el5xen/kernel/drivers/xen/netfront/xennet.ko lib
chmod -x lib/xenblk.ko
chmod -x lib/xennet.ko
cat &lt;&lt;EOL &gt; init
#!/bin/nash

mount -t proc /proc /proc
setquiet
echo Mounting proc filesystem
echo Mounting sysfs filesystem
mount -t sysfs /sys /sys
echo Creating /dev
mount -o mode=0755 -t tmpfs /dev /dev
mkdir /dev/pts
mount -t devpts -o gid=5,mode=620 /dev/pts /dev/pts
mkdir /dev/shm
mkdir /dev/mapper
echo Creating initial device nodes
mknod /dev/null c 1 3
mknod /dev/zero c 1 5
mknod /dev/urandom c 1 9
mknod /dev/systty c 4 0
mknod /dev/tty c 5 0
mknod /dev/console c 5 1
mknod /dev/ptmx c 5 2
mknod /dev/rtc c 10 135
mknod /dev/tty0 c 4 0
mknod /dev/tty1 c 4 1
mknod /dev/tty2 c 4 2
mknod /dev/tty3 c 4 3
mknod /dev/tty4 c 4 4
mknod /dev/tty5 c 4 5
mknod /dev/tty6 c 4 6
mknod /dev/tty7 c 4 7
mknod /dev/tty8 c 4 8
mknod /dev/tty9 c 4 9
mknod /dev/tty10 c 4 10
mknod /dev/tty11 c 4 11
mknod /dev/tty12 c 4 12
mknod /dev/ttyS0 c 4 64
mknod /dev/ttyS1 c 4 65
mknod /dev/ttyS2 c 4 66
mknod /dev/ttyS3 c 4 67
echo Setting up hotplug.
hotplug
echo Creating block device nodes.
mkblkdevs
echo &quot;Loading jbd.ko module&quot;
insmod /lib/jbd.ko
echo &quot;Loading ext3.ko module&quot;
insmod /lib/ext3.ko
echo &quot;Loading xenblk.ko module&quot;
insmod /lib/xenblk.ko
echo &quot;Loading xennet.ko module&quot;
insmod /lib/xennet.ko
mkblkdevs
echo Scanning and configuring dmraid supported devices
resume /dev/sdc2
echo Creating root device.
mkrootdev -t ext3 -o defaults,ro /dev/sda1
echo Mounting root filesystem.
mount /sysroot
echo Setting up other filesystems.
setuproot
echo Switching to new root and running init.
switchroot
EOL
find ./ | cpio -H newc -o | gzip &gt; /mnt/boot/initrd-2.6.18-194.8.1.el5xen.img
cd -
</pre>
</li>
<li>
Install grub on the new instance, move the boot directory into a subdirectory and create a grub menu.lst file that points to the CentOS kernel and initrd file:</p>
<pre class="brush: plain; title: ; notranslate">
chroot /mnt grub-install /dev/sdh

mkdir /mnt/boot/boot/
mv /mnt/boot/* /mnt/boot/boot/ 2&gt; /dev/null &gt; /dev/null
</pre>
<p>Put the following in /mnt/boot/boot/grub/menu.lst  (note that as soon as the CentOS Xen kernel version changes this will be incorrect):</p>
<pre class="brush: plain; title: ; notranslate">
default 0
timeout 1
title CentOS5.5
     root (hd0,0)
     kernel /boot/vmlinuz-2.6.18-194.8.1.el5xen root=/dev/sda2
     initrd /boot/initrd-2.6.18-194.8.1.el5xen.img
</pre>
<p>Note that this goes in /mnt/boot/boot/grub and that isn&#039;t the normal spot you would expect it in. This is where the AWS EC2 pv-grub expects to find the file on the first partition and moving the boot directory around just keeps everything in line with those expectations.
</li>
<li>
Make sure everything is written to disk and unmount the volume. At this point you have a CentOS 5.5 install that is almost ready to boot.</p>
<pre class="brush: plain; title: ; notranslate">
sync
umount /mnt/proc
umount /mnt/boot
umount /mnt
</pre>
</li>
<li>
Make a snapshot of the volume you just installed to, you will need to volume ID that came from step 2:</p>
<pre class="brush: plain; title: ; notranslate">
ec2-create-snapshot -d &quot;Volume Description&quot; volume-id
</pre>
</li>
<li>
Use the snapshot from step 18 along with the ec2-register command to register your instance:</p>
<pre class="brush: plain; title: ; notranslate">
ec2-register -n &quot;AMIName&quot; -d &quot;AMI Description&quot; --root-device-name /dev/sda2 -b /dev/sda=snap-id:2:true
</pre>
<p>There are a number of things to take note of with the above command:</p>
<ol>
<li>Running this command will result in output something like: IMAGE   ami-a5ae9bb</li>
<li>The -b option can now assign a snapshot to a block device, the options in this example tell EC2 to generate 2G of space for the snapshot and to delete the volume it creates from the snapshot if the instance terminates. If you plan to use an instance long term you should replace that true at the end with a false to keep EC2 from deleting the volume when the instance terminates.</li>
<li>Notice that the -b option is assigning the snapshot to the device and not to a partition of the device, that is /dev/sda instead of /dev/sda1. You can still assign a snapshot directly to a partition but now you can also assign a block device to a raw partitioned disk. Because I created the partition table earlier the snapshot is the raw disk device here.</li>
<li>Also note that we are missing the kernel configuration option. As of this post using it with a pv-grub kernel causes the register command to fail. It isn&#039;t a big issue but just keep that in mind when you fire the AMI up otherwise it won&#039;t boot with the correct pv-grub kernel.</li>
</ol>
<p><br/>
</li>
<li>
Start an instance of the fresh CentOS 5.5 install. One key thing here is picking the correct pv-grub kernel to boot from. There are currently 4 different kernels at each location, see the <a href="http://developer.amazonwebservices.com/connect/entry.jspa?categoryID=174&#038;externalID=3967">Enabling User Provided Kernels in Amazon EC2</a> document for a full list of kernels in each availability zone. In this case because the root disk was created with a partition table I used the &#034;ec2-public-images/pv-grub-hd00-V1.01-i386.gz.manifest.xml&#034; kernel to boot with (on US-East-1 that is kernel id aki-4c7d9525). For example:</p>
<pre class="brush: plain; title: ; notranslate">
ec2-run-instances -z us-east-1a -g your-group -k your-keypair -n 1 --kernel pv-grub-kernel-id ami-from-step-19
</pre>
</li>
</ol>
<p><b>Tips on debugging the boot process</b></p>
<p>If your instance won&#039;t boot you can use the ec2-get-console-output command to get the console output created from the pv-grub boot process. If your console output ends up like the following there are a number of things you may have done wrong.</p>
<ul>
<li>You may have selected the wrong kernel and it is trying to boot from a non-existant partition. Make sure you are using the correct pv-grub kernel hd0 vs hd00.</li>
<li>You forgot to install grub or installed grub in the wrong place. Make sure you have either /boot/grub/menu.lst or /boot/boot/grub/menu.lst</li>
<li>You have a bad menu.lst file. One mistake I made was giving a boot item a title with a space in it. Make the menu.lst as simple as you can until you get it to boot.</li>
</ul>
<pre class="brush: plain; title: ; notranslate">
    Xen Minimal OS!
  start_info: 0xb10000(VA)
    nr_pages: 0x6a400
  shared_inf: 0x002f9000(MA)
     pt_base: 0xb13000(VA)
nr_pt_frames: 0x9
    mfn_list: 0x967000(VA)
   mod_start: 0x0(VA)
     mod_len: 0
       flags: 0x0
    cmd_line:  root=/dev/sda1 ro 4
  stack:      0x946780-0x966780
MM: Init
      _text: 0x0(VA)
     _etext: 0x621f5(VA)
   _erodata: 0x76000(VA)
     _edata: 0x7b6d4(VA)
stack start: 0x946780(VA)
       _end: 0x966d34(VA)
  start_pfn: b1f
    max_pfn: 6a400
Mapping memory range 0xc00000 - 0x6a400000
setting 0x0-0x76000 readonly
skipped 0x1000
MM: Initialise page allocator for e6c000(e6c000)-0(6a400000)
MM: done
Demand map pfns at 6a401000-7a401000.
Heap resides at 7a402000-ba402000.
Initialising timer interface
Initialising console ... done.
gnttab_table mapped at 0x6a401000.
Initialising scheduler
Thread &quot;Idle&quot;: pointer: 0x7a402008, stack: 0x6a030000
Initialising xenbus
Thread &quot;xenstore&quot;: pointer: 0x7a402478, stack: 0x6a040000
Dummy main: start_info=0x966880
Thread &quot;main&quot;: pointer: 0x7a4028e8, stack: 0x6a050000
&quot;main&quot; &quot;root=/dev/sda1&quot; &quot;ro&quot; &quot;4&quot;
vbd 2048 is hd0
******************* BLKFRONT for device/vbd/2048 **********

backend at /local/domain/0/backend/vbd/2111/2048
Failed to read /local/domain/0/backend/vbd/2111/2048/feature-barrier.
Failed to read /local/domain/0/backend/vbd/2111/2048/feature-flush-cache.
12582912 sectors of 0 bytes
**************************
vbd 2051 is hd1
******************* BLKFRONT for device/vbd/2051 **********

backend at /local/domain/0/backend/vbd/2111/2051
Failed to read /local/domain/0/backend/vbd/2111/2051/feature-barrier.
Failed to read /local/domain/0/backend/vbd/2111/2051/feature-flush-cache.
1835008 sectors of 0 bytes
**************************

    [H
    [J

    GNU GRUB  version 0.97  (1740800K lower / 0K upper memory)

       [ Minimal BASH-like line editing is supported.   For

         the   first   word,  TAB  lists  possible  command

         completions.  Anywhere else TAB lists the possible

         completions of a device/filename. ]

grubdom&gt;
    [9;10H
</pre>
<p><br/><br/></p>
<p><b>Booting non-Linux OSes with EC2</b></p>
<p>I have attempted both FreeBSD and NetBSD in particular with no luck. </p>
<p>FreeBSD is tricky because it really wants to use its loader and while you can do that with the grub chainloader command it results in a grub error from EC2 about needing to load the kernel before booting:</p>
<pre class="brush: plain; title: ; notranslate">
root (hd0,1)

 Filesystem type unknown, partition type 0xa5

chainloader +1

Error 8: Kernel must be loaded before booting

Press any key to continue...
</pre>
<p>I was also able to try a modified version of FreeBSD that should boot without the loader but with that I get an error claiming the kernel isn&#039;t bziped:</p>
<pre class="brush: plain; title: ; notranslate">
root (hd0,1,a)

 Filesystem type is ufs2, partition type 0xa5

kernel /boot/loader

xc_dom_probe_bzimage_kernel: kernel is not a bzImage
ERROR Invalid kernel: xc_dom_find_loader: no loader found

xc_dom_core.c:523: panic: xc_dom_find_loader: no loader found
xc_dom_parse_image returned -1

Error 9: Unknown boot failure

Press any key to continue...
</pre>
<p>For NetBSD the result is actually a completely blank console log so I assume it causes some catastrophic failure that keeps the EC2 system from even being able to pull back a log.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ioncannon.net/system-administration/1205/installing-cent-os-5-5-on-ec2-with-the-cent-os-5-5-kernel/feed/</wfw:commentRss>
		<slash:comments>24</slash:comments>
		</item>
		<item>
		<title>Developing Adobe Air Apps with Linux</title>
		<link>http://www.ioncannon.net/programming/875/developing-adobe-air-apps-with-linux/</link>
		<comments>http://www.ioncannon.net/programming/875/developing-adobe-air-apps-with-linux/#comments</comments>
		<pubDate>Tue, 12 Jan 2010 12:21:24 +0000</pubDate>
		<dc:creator>carson</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[air]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://www.ioncannon.net/?p=875</guid>
		<description><![CDATA[I finally found a little project I wanted to do using Adobe Air and after some searching I found out you can use Linux to develop Air applications. At first I thought I would have to use Flex Builder which is still in alpha for Linux but it turns out there is a better option [...]]]></description>
			<content:encoded><![CDATA[<p>I finally found a little project I wanted to do using <a href="http://www.adobe.com/products/air/">Adobe Air</a> and after some searching I found out you can use Linux to develop Air applications. At first I thought I would have to use Flex Builder which is still in <a href="http://labs.adobe.com/technologies/flex/flexbuilder_linux/">alpha for Linux</a> but it turns out there is a better option from <a href="http://www.aptana.org/">Aptana</a>. </p>
<p>The <a href="http://www.aptana.org/air/">Aptana Air</a> plugin supports developing Adobe Air applications using HTML and Javascript. It even support the 2.0 release of Air that is currently in beta. Aptana uses the Eclipse framework as an editor so if you are familure with Eclipse it will be even easier to use.</p>
<p>I started by downloading and installing the latest version of the <a href="http://get.adobe.com/air/">Air runtime</a>. Next I grabbed the <a href="http://www.adobe.com/products/air/tools/sdk/">Air SDK</a>, the SDK doesn&#039;t come with the plugin so it is something you have to get directly from the Air developers site. After getting the SDK unpacked I installed the latest Aptana core release. Once the core is installed there is a big plugin button on the startup screen that currently has Air listed.</p>
<p>The install went smoothly except for a few issues. The first one I ran into was very noticeable since it kept any dialog buttons from working when they were clicked although they did work when I clicked them and then hit enter or navigated to them with the keyboard. Luckily someone has already figured out that there is an issue with <a href="http://mou.me.uk/2009/10/31/fixing-eclipse-in-ubuntu-9-10-karmic-koala/">Eclipse and GTK+</a> that is the cause (even though the post is for Ubuntu the same problem and solution worked for me on Fedora). The fix is to set the GDK_NATIVE_WINDOWS variable before running the Aptana binary:</p>
<div class="codesnip-container" >GDK_NATIVE_WINDOWS=true; AptanaStudio</div>
<p>The next thing I noticed was the application.xml descriptor that Aptana created didn&#039;t generate correctly. It needs to start with the correct xmlns or the following error will be thrown on run: &#034;invalid application descriptor: descriptor version does not match runtime version&#034;. To fix this check the version of the Air SDK by running the following command:</p>
<div class="codesnip-container" >./adt -version<br />
adt version &quot;1.5.3.9120&quot;</div>
<p>For the version of the Air SDK I downloaded the correct xmlns was http://ns.adobe.com/air/application/1.5 so I needed the following application tag:</p>
<div class="codesnip-container" >&lt;application xmlns=&quot;http://ns.adobe.com/air/application/1.5&quot;&gt;</div>
<p>Once I had that working I was able to compile and execute a demo application. I was also able to create an Air application package from within Aptana using File > Export > Adobe AIR > Adobe AIR Package. Before creating the Air package I had to create a signing certificate. Creating the certificate can be done within Aptana too but because I had not yet fixed the above button issue I created a cert on the command line with the Air SDK and then imported it. To create the Air signing certificate from the command line I used the adt command from the SDK:</p>
<div class="codesnip-container" >adt -certificate -cn SelfSigned 1024-RSA sampleCert.pfx samplePassword</div>
<p>Remember the password that gets used to generate the certificate because it will have to be used before a package is signed.</p>
<p>Finally Adobe has a lot of information on developing Air applications on their <a href="http://www.adobe.com/devnet/air/">Air devnet site</a>. The <a href="http://www.adobe.com/devnet/air/ajax/">Air ajax section</a> is especially important.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ioncannon.net/programming/875/developing-adobe-air-apps-with-linux/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Upgrade to Fedora 12 from Fedora 11</title>
		<link>http://www.ioncannon.net/system-administration/719/upgrade-to-fedora-12-from-fedora-11/</link>
		<comments>http://www.ioncannon.net/system-administration/719/upgrade-to-fedora-12-from-fedora-11/#comments</comments>
		<pubDate>Wed, 18 Nov 2009 11:56:18 +0000</pubDate>
		<dc:creator>carson</dc:creator>
				<category><![CDATA[system administration]]></category>
		<category><![CDATA[Fedora]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://www.ioncannon.net/?p=719</guid>
		<description><![CDATA[Fedora 12 was just released and it is time to upgrade again of course. I almost thought this was going to be a version to yawn at but then I saw that there was going to be a new version of Fedora based on Moblin and it seemed exciting again. Of course that isn&#039;t the [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://docs.fedoraproject.org/release-notes/f12/en-US/html/">Fedora 12</a> was just released and it is time to upgrade again of course. I almost thought this was going to be a version to yawn at but then I saw that there was going to be a new version of Fedora based on <a href="http://moblin.org/">Moblin</a> and it seemed exciting again. Of course that isn&#039;t the only thing being upgraded in the latest version of Fedora. Some of the more notable changes in this version:</p>
<ul>
<li>Updated window managers <a href="http://www.fedoraproject.org/wiki/Features/Gnome2.28">Gnome 2.28</a>, <a href="http://www.fedoraproject.org/wiki/Features/KDE43">KDE 4.3</a> and <a href="http://www.fedoraproject.org/wiki/Features/FedoraMoblin">Fedora Moblin</a></li>
<li><a href="http://fedoraproject.org/wiki/Features/Presto">Delta RPM support</a></li>
<li><a href="http://www.fedoraproject.org/wiki/Features/F12X86Support">i686 as the base architecture</a></li>
<li>Lots of virtualization changes: <a href="http://www.fedoraproject.org/wiki/Features/KSM">KSM</a>, <a href="http://www.fedoraproject.org/wiki/Features/KVM_Huge_Page_Backed_Memory">KVM huge page support</a>, <a href="http://www.fedoraproject.org/wiki/Features/KVM_NIC_Hotplug>KVM NIC hotplug</a>, <a href="http://www.fedoraproject.org/wiki/Features/KVM_qcow2_Performance">KVM QCow2 performance improvements</a>, <a href="http://www.fedoraproject.org/wiki/Features/KVM_Stable_Guest_ABI">KVM Stable Guest ABI</a>, <a href="http://www.fedoraproject.org/wiki/Features/libguestfs">libguestfs</a>, <a href="http://www.fedoraproject.org/wiki/Features/Network_Interface_Management">Virtual network management</a> and <a href="http://www.fedoraproject.org/wiki/Features/VirtPrivileges">improved virtual privileges</a> to name a few</li>
<li>An easier to use bug reporting interface <a href="http://www.fedoraproject.org/wiki/Features/ABRTF12">Abrt 1.0</a></li>
<li><a href="http://www.fedoraproject.org/wiki/Features/BetterWebcamSupportF12">Better Webcam Support</a></li>
</ul>
<p>You can find the complete list of <a href="http://www.fedoraproject.org/wiki/Releases/12/FeatureList">Fedora 12 enhancements</a> as well if you want more details.</p>
<p><span id="more-719"></span></p>
<p>I&#039;m again starting with <a href="http://fedoraproject.org/wiki/Features/PreUpgrade">PreUpdate</a> since it worked well last time. The steps are pretty much the same as last time but I did have more problems after the upgrade:</p>
<ol>
<li>You have to be at Fedora11 before you try this. If you aren&#039;t there follow the <a href="http://www.ioncannon.net/system-administration/358/upgrading-to-fedora-11-from-fedora-10/">steps to get to Fedora11</a>.</li>
<li>yum clean all</li>
<li>yum udpate</li>
<li>Make sure to back up your xorg.conf since it can disappear with the upgrade.</li>
<li>preupgrade-cli &#034;Fedora 12 (Constantine)&#034; The total download for the upgrade from Fedora 11 to Fedora 12 was 1.1GB for me</li>
<li>After I rebooted the first time I got an error that the /boot directory didn&#039;t have enough space. It turns out I needed about 27M of free space so I ended up having to delete old kernels until I had 28M of free space.</li>
<li>reboot and wait</li>
</ol>
<p>I lucked out again and didn&#039;t have to remove anything to fix dependency issues. I recompiled my existing NVIDIA driver but I ran into an issue with the nouveau NVIDIA driver that comes with Fedora 12. I needed to remove the nouveau package, rebuild initrd and reboot before I could build the NVIDIA driver:</p>
<div class="codesnip-container" >
<div class="text codesnip" style="font-family:monospace;">yum remove xorg-x11-drv-nouveau.i686<br />
rm /boot/initramfs-2.6.31.5-127.fc12.i686.img<br />
mkinitrd /boot/initramfs-2.6.31.5-127.fc12.i686.img 2.6.31.5-127.fc12.i686</div>
</div>
<p>If that is too much work you can also get the NVIDIA driver from <a href="http://www.atrpms.net/">atrpms</a> but you will still need to remove the nouveau driver first. I also needed to pull down the Fedora 12 version of <a href="http://www.virtualbox.org/wiki/Linux_Downloads">Virtualbox</a> but so far that was all.</p>
<p>If you prefer the yum upgrade option here are the steps for that as well:</p>
<ol>
<li>yum clean all</li>
<li>yum update</li>
<li>rpm -Uvh http://mirrors.kernel.org/fedora/releases/12/Fedora/i386/os/Packages/fedora-release-notes-12.0.0-4.fc12.noarch.rpm http://mirrors.kernel.org/fedora/releases/12/Fedora/i386/os/Packages/fedora-release-12-1.noarch.rpm</li>
<li>yum clean all</li>
<li>yum -y update</li>
<li>You may need to resolve dependencies and then do another yum -y update</li>
<li>reboot</li>
</ol>
<p>I had to resolve dependencies to get this to work. I had to remove tigervnc-server-1.0.0-2.fc11.i586 and VirtualBox-3.0.10_54097_fedora11-1.i586. The resulting update was about 1.4G so it took a little while to apply.</p>
<p>I&#039;ve also put together a few <a href="http://www.ioncannon.net/projects/miscellaneous-projects/fedora-12-screenshots-and-videos/">videos and screenshots</a> if you want to get a quick preview of what the different versions available look like. You can also view the videos on Youtube: <a href="http://www.youtube.com/watch?v=W6rTVTyjQ1Q&#038;feature=player_embedded">Moblin</a>, <a href="http://www.youtube.com/watch?v=F0UlVnoUtbw&#038;feature=player_embedded">KDE</a> and <a href="http://www.youtube.com/watch?v=GZ8tSxMJTr8&#038;feature=player_embedded">Gnome</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ioncannon.net/system-administration/719/upgrade-to-fedora-12-from-fedora-11/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Upgrading to Fedora 11 from Fedora 10</title>
		<link>http://www.ioncannon.net/system-administration/358/upgrading-to-fedora-11-from-fedora-10/</link>
		<comments>http://www.ioncannon.net/system-administration/358/upgrading-to-fedora-11-from-fedora-10/#comments</comments>
		<pubDate>Fri, 12 Jun 2009 10:40:54 +0000</pubDate>
		<dc:creator>carson</dc:creator>
				<category><![CDATA[system administration]]></category>
		<category><![CDATA[Fedora]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://www.ioncannon.net/?p=358</guid>
		<description><![CDATA[It is time again to upgrade if you are using Fedora. Fedora 11 was released a few days ago and contains some nice enhancements. For people who can a complete re-install is probably best. One reason for that is the inclusion of ext4 in Fedora11. You won&#039;t get the benefit of ext4 unless you do [...]]]></description>
			<content:encoded><![CDATA[<p>It is time again to upgrade if you are using Fedora. <a href="http://docs.fedoraproject.org/release-notes/f11/">Fedora 11</a> was <a href="http://press.redhat.com/2009/06/09/fedora-11-rapid-innovation-available-today/">released</a> a few days ago and contains some nice <a href="http://fedoraproject.org/wiki/Fedora_11_tour">enhancements</a>.</p>
<p>For people who can a complete re-install is probably best. One reason for that is the inclusion of ext4 in Fedora11. You won&#039;t get the benefit of ext4 unless you do a fresh install or <a href="http://www.cyberciti.biz/tips/linux-convert-ext3-to-ext4-file-system.html">upgrade from ext3 to ext4</a>. If you read the <a href="http://docs.fedoraproject.org/install-guide/f11/en-US/html/ch-upgrade-x86.html">upgrade guide</a> that Fedora produces it recommends not doing an upgrade.</p>
<p><span id="more-358"></span></p>
<p>This time around I decided to go with <a href="http://fedoraproject.org/wiki/Features/PreUpgrade">PreUpdate</a> right off the bat and it worked great. Here are the condensed steps. I think this will be the last time I do an upgrade post since they have it down to almost nothing now.</p>
<ol>
<li>You have to be at Fedora10 before you try this. If you aren&#039;t there follow the <a href="http://www.ioncannon.net/system-administration/142/upgrading-from-fedora-9-to-fedora-10-with-yum/">steps to get to Fedora10</a>.</li>
<li>yum clean all</li>
<li>yum udpate</li>
<li>preupgrade-cli &#034;Fedora 11 (Leonidas)&#034;</li>
<li>reboot and wait</li>
</ol>
<p>It seems like the days of conflicts before upgrades are gone now so that is a good thing. I didn&#039;t have to remove anything to make dependencies work out. The only fallout I had from this upgrade was my NVIDIA configuration for xorg got wiped and I had to pull it from backup. So take note to back up your xorg.conf if you have a custom one.</p>
<p>Tags: <a href="http://technorati.com/tag/linux" rel="tag">linux</a>, <a href="http://technorati.com/tag/fedora" rel="tag"> fedora</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ioncannon.net/system-administration/358/upgrading-to-fedora-11-from-fedora-10/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>FreeRADIUS with Oracle</title>
		<link>http://www.ioncannon.net/system-administration/136/freeradius-with-oracle/</link>
		<comments>http://www.ioncannon.net/system-administration/136/freeradius-with-oracle/#comments</comments>
		<pubDate>Mon, 07 Jul 2008 12:41:51 +0000</pubDate>
		<dc:creator>carson</dc:creator>
				<category><![CDATA[system administration]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[radius]]></category>

		<guid isPermaLink="false">http://www.ioncannon.net/?p=136</guid>
		<description><![CDATA[I recently needed to find a RADIUS server for use in a project where I could stick profile data into Oracle. I remembered seeing FreeRADIUS a while back so I checked to see if it was active and supported Oracle. Sure enough it did. It was a little tricky to set up because some of [...]]]></description>
			<content:encoded><![CDATA[<p>I recently needed to find a RADIUS server for use in a project where I could stick profile data into Oracle. I remembered seeing <a href="http://freeradius.org/">FreeRADIUS</a> a while back so I checked to see if it was active and supported Oracle. Sure enough it did. It was a little tricky to set up because some of the documentation is out of sync with the latest version so here is what you need to know to get it working.</p>
<p><span id="more-136"></span></p>
<p>I&#039;m using FreeRADIUS version 2.0.3 so some of these issues may be fixed down the road. The first thing you should do is compile FreeRADIUS and get it working using the normal users file. After you have done that and successfully tested queries to the server you can recompile to build Oracle in. </p>
<p>I used the <a href="http://www.oracle.com/technology/tech/oci/instantclient/instantclient.html">Oracle Instant client</a> again. I&#039;ve used the Oracle instant client a number of times now and I can&#039;t believe it took them so long to release their SDK in this type of paired down package.</p>
<p>This should be all you need to add to the configure command to enable the Oracle driver:</p>
<div class="codesnip-container" >
<div class="text codesnip" style="font-family:monospace;">./configure &#8211;with-oracle-home-dir=&lt;path to oracle instant client&gt;</div>
</div>
<p>However that didn&#039;t work for me. Instead I had to go into the RLM Oracle driver directory and run the configure command from there:</p>
<div class="codesnip-container" >
<div class="text codesnip" style="font-family:monospace;">cd freeradius-server-2.0.3/src/modules/rlm_sql/drivers/rlm_sql_oracle<br />
ORACLE_HOME=&lt;path to oracle instant client&gt; CFLAGS=-I&lt;path to oracle instant client&gt;/sdk/include/ LDFLAGS=-L&lt;path to oracle instant client&gt; ./configure</div>
</div>
<p>This created the Makefile but then that still wasn&#039;t correct. I had to modify the includes and libraries so they matched the correct location:</p>
<div class="codesnip-container" >
<div class="text codesnip" style="font-family:monospace;">RLM_SQL_CFLAGS = &nbsp; &nbsp;$(INCLTDL) -I&lt;path to oracle instant client&gt;/sdk/include/<br />
RLM_SQL_LIBS &nbsp; = &nbsp;-L&lt;path to oracle instant client&gt; -lclntsh -lm</div>
</div>
<p>After making these changes I could then do a make and make install. You can verify that the module is installed by looking for the module file named rlm_sql_oracle.a in your lib directory (in my case /usr/local/lib/). After you have verified that the module is compiled and in place you are ready to move on to the configuration.</p>
<p>The first thing to do is load the provided Oracle schema. That schema can be found in: freeradius-server-2.0.3/raddb/sql/oracle</p>
<p>Next read over the <a href="http://wiki.freeradius.org/Rlm_sql">RLM SQL configuration</a> information to get a general idea of what is going on in the configuration files and how FreeRADIUS uses the queries to find the correct information for a given request. </p>
<p>The following steps are needed to configure the Oracle access and have FreeRADIUS use that configuration for data (I assume that you have installed with a base of /usr/local):</p>
<ol>
<li>Edit /usr/local/etc/raddb/sql.conf set database = &#034;oracle&#034;, set the server, login, password, and radius_db values. The following is an example of the connection information needed:
<div class="codesnip-container" >
<div class="text codesnip" style="font-family:monospace;"># Connection info:<br />
server = &quot;127.0.0.1&quot;<br />
login = &quot;username&quot;<br />
password = &quot;password&quot;</p>
<p># Database table configuration for everything except Oracle<br />
#radius_db = &quot;radius&quot;<br />
# If you are using Oracle then use this instead<br />
radius_db = &quot;(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1521))(CONNECT_DATA=(SID=MYDB01)))&quot;</div>
</div>
</li>
<li>Search for the following and uncomment the SQL load line in the file /usr/local/etc/raddb/sites-enabled/default as follows:
<div class="codesnip-container" >
<div class="text codesnip" style="font-family:monospace;"># See &quot;Authorization Queries&quot; in sql.conf<br />
&nbsp; sql</div>
</div>
<p>Note: This is something that I didn&#039;t find in the documentation. I believe that is due to the documentation being for an older version and this being a new requirement.</p>
<li>Load sample data into the database:
<div class="codesnip-container" >
<div class="sql codesnip" style="font-family:monospace;"><span class="kw1">INSERT</span> <span class="kw1">INTO</span> radusergroup <span class="kw1">VALUES</span><span class="br0">&#40;</span>radusergroup_seq<span class="sy0">.</span><span class="kw1">NEXTVAL</span><span class="sy0">,</span> <span class="st0">&#039;dynamic&#039;</span><span class="sy0">,</span> <span class="st0">&#039;fredf&#039;</span><span class="br0">&#41;</span>;<br />
<span class="kw1">INSERT</span> <span class="kw1">INTO</span> radcheck <span class="kw1">VALUES</span><span class="br0">&#40;</span>radcheck_seq<span class="sy0">.</span><span class="kw1">NEXTVAL</span><span class="sy0">,</span> <span class="st0">&#039;fredf&#039;</span><span class="sy0">,</span> <span class="st0">&#039;Cleartext-Password&#039;</span><span class="sy0">,</span> <span class="st0">&#039;:=&#039;</span><span class="sy0">,</span> <span class="st0">&#039;wilma&#039;</span><span class="br0">&#41;</span>;<br />
<span class="kw1">INSERT</span> <span class="kw1">INTO</span> radreply <span class="kw1">VALUES</span><span class="br0">&#40;</span>radreply_seq<span class="sy0">.</span><span class="kw1">NEXTVAL</span><span class="sy0">,</span> <span class="st0">&#039;fredf&#039;</span><span class="sy0">,</span> <span class="st0">&#039;Framed-IP-Address&#039;</span><span class="sy0">,</span> <span class="st0">&#039;:=&#039;</span><span class="sy0">,</span> <span class="st0">&#039;1.2.3.4&#039;</span><span class="br0">&#41;</span>;<br />
<span class="kw1">INSERT</span> <span class="kw1">INTO</span> radgroupreply <span class="kw1">VALUES</span><span class="br0">&#40;</span>radgroupreply_seq<span class="sy0">.</span><span class="kw1">NEXTVAL</span><span class="sy0">,</span> <span class="st0">&#039;dynamic&#039;</span><span class="sy0">,</span> <span class="st0">&#039;Framed-Compression&#039;</span><span class="sy0">,</span> <span class="st0">&#039;:=&#039;</span><span class="sy0">,</span> <span class="st0">&#039;Van-Jacobsen-TCP-IP&#039;</span><span class="br0">&#41;</span>;</div>
</div>
</li>
<li>Start the daemon in debug mode:
<div class="codesnip-container" >
<div class="text codesnip" style="font-family:monospace;">radius -X</div>
</div>
<p>If you don&#039;t have the oracle libraries in your path you will need to start radius with the correct LD path entry like this:</p>
<div class="codesnip-container" >
<div class="text codesnip" style="font-family:monospace;">LD_LIBRARY_PATH=&lt;path to oracle instant client&gt; radiusd -X</div>
</div>
<li>Send a test query:
<div class="codesnip-container" >
<div class="text codesnip" style="font-family:monospace;">radtest fredf wilma localhost 0 radpassword</div>
</div>
<p>On the console for radius -X you will see debug and you should receive a valid response from the test that looks like this:</p>
<div class="codesnip-container" >
<div class="text codesnip" style="font-family:monospace;">User-Name = &quot;fredf&quot;<br />
User-Password = &quot;wilma&quot;<br />
NAS-IP-Address = 127.0.0.1<br />
NAS-Port = 0<br />
Framed-IP-Address = 1.2.3.4</div>
</div>
</li>
<p>At this point you are ready to load your data into FreeRADIUS via Oracle.</p>
<p>Other Notes:</p>
<p>Depending on how large your configuration values are the provided schema may not give you enough room to store everything. You may need to alter the tables to increase the space available for values like this:</p>
<div class="codesnip-container" >
<div class="sql codesnip" style="font-family:monospace;"><span class="kw1">ALTER</span> <span class="kw1">TABLE</span> radreply <span class="kw1">MODIFY</span> value varchar<span class="br0">&#40;</span>128<span class="br0">&#41;</span>;</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.ioncannon.net/system-administration/136/freeradius-with-oracle/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Examples of why netcat is still useful</title>
		<link>http://www.ioncannon.net/system-administration/134/netcat-examples/</link>
		<comments>http://www.ioncannon.net/system-administration/134/netcat-examples/#comments</comments>
		<pubDate>Thu, 24 Apr 2008 13:18:41 +0000</pubDate>
		<dc:creator>carson</dc:creator>
				<category><![CDATA[system administration]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://www.ioncannon.net/?p=134</guid>
		<description><![CDATA[I recently got a new work PC and was worried that stuck somewhere in the 40G hard drive of the old PC was something I would one day need. The new PC had 300G of space so I figured I would just copy the entire drive over and keep it forever. This isn&#039;t the most [...]]]></description>
			<content:encoded><![CDATA[<p>I recently got a new work PC and was worried that stuck somewhere in the 40G hard drive of the old PC was something I would one day need. The new PC had 300G of space so I figured I would just copy the entire drive over and keep it forever. This isn&#039;t the most difficult task in the world and I actually started out using ssh to transfer the image.</p>
<p><span id="more-134"></span></p>
<p>To transfer the drive using ssh I was using the following command from the new PC:</p>
<div class="codesnip-container" >
<div class="bash codesnip" style="font-family:monospace;"><span class="kw2">ssh</span> <span class="re5">-c</span> blowfish old-pc-ip <span class="st0">&quot;dd if=/dev/hda&quot;</span> <span class="sy0">&gt;</span> <span class="kw2">dd</span> <span class="re2">of</span>=old-pc.hda</div>
</div>
<p>This worked fine but the old PC seemed to be having a hard time keeping up. I did some adjusting to the block size of the transfers using dd but that didn&#039;t seem to help. That is when I decided to give netcat a try.</p>
<p>On the old PC side I ran:</p>
<div class="codesnip-container" >
<div class="bash codesnip" style="font-family:monospace;"><span class="kw2">dd</span> <span class="kw1">if</span>=<span class="sy0">/</span>dev<span class="sy0">/</span>hda <span class="sy0">|</span> nc <span class="re5">-l</span> <span class="nu0">10001</span></div>
</div>
<p>and on the new PC side I ran:</p>
<div class="codesnip-container" >
<div class="bash codesnip" style="font-family:monospace;">nc old-pc-ip 10001 <span class="sy0">|</span> <span class="kw2">dd</span> <span class="re2">of</span>=old-pc.hda</div>
</div>
<p>This worked like a charm and transfered the drive about twice as fast as ssh using blowfish encryption.</p>
<p>Just for reference I was using dd here to give myself more control over block sizes, skip any read errors, and at times I was actually trying to just transfer parts of the drive instead of the entire thing using the seek and count options. Another useful trick with dd is that you can find out the current amount transfered and rate by sending it a USR1 signal with kill. After poking around I actually found another nice utility that you can stick in the stream call <a href="http://www.ivarch.com/programs/pv.shtml">pipe viewer</a> that is able to give you a nice display of the count instead of having to send signals to dd.</p>
<p>Another great use for netcat that I ran into recently was setting up a ppp tunnel between two machines. Again at first I started by using ssh:</p>
<div class="codesnip-container" >
<div class="bash codesnip" style="font-family:monospace;">pppd updetach noauth passive pty <span class="st0">&quot;ssh remote-host-ip -lroot -o Batchmode=yes pppd nodetach notty noauth&quot;</span> ipparam vpn 192.168.77.1:192.168.77.2</div>
</div>
<p>This worked between two machines that were already connected by a network but my real goal was build the tunnel over a device that wouldn&#039;t work with ssh traffic. I turned to netcat again.</p>
<p>On the initiating side I ran this:</p>
<div class="codesnip-container" >
<div class="bash codesnip" style="font-family:monospace;"><span class="sy0">/</span>usr<span class="sy0">/</span>sbin<span class="sy0">/</span>pppd connect-delay <span class="nu0">30000</span> updetach noauth passive pty <span class="st0">&quot;echo connect-585 | nc device-ip 2000&quot;</span> ipparam root 192.168.77.1:192.168.77.2</div>
</div>
<p>Here I send the traffic to a device in between that forms a connection over a non-network link to the end point machine. I don&#039;t need netcat on the endpoint because the communication channel is not a network. On the end point I run this:</p>
<div class="codesnip-container" >
<div class="bash codesnip" style="font-family:monospace;"><span class="sy0">/</span>usr<span class="sy0">/</span>sbin<span class="sy0">/</span>pppd nodetach notty noauth</div>
</div>
<p>In this case netcat saved me from having to write some intermediate code that would communicate with the device and just pipe the bits through.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ioncannon.net/system-administration/134/netcat-examples/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to create a Fedora 7 Instance for EC2</title>
		<link>http://www.ioncannon.net/system-administration/128/how-to-create-a-fedora-7-instance-for-ec2/</link>
		<comments>http://www.ioncannon.net/system-administration/128/how-to-create-a-fedora-7-instance-for-ec2/#comments</comments>
		<pubDate>Sat, 02 Jun 2007 15:38:34 +0000</pubDate>
		<dc:creator>carson</dc:creator>
				<category><![CDATA[system administration]]></category>
		<category><![CDATA[ec2]]></category>
		<category><![CDATA[Fedora]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://www.ioncannon.net/uncategorized/128/how-to-create-a-fedora-7-instance-for-ec2/</guid>
		<description><![CDATA[Now that Fedora 7 is out I figured it was time to update the EC2 instance howto. It is almost exactly the same as creating a FC6 instance so if you want to know the details you can reference that article. Here is an updated script for creating the AMI the only change between this [...]]]></description>
			<content:encoded><![CDATA[<p>Now that Fedora 7 is out I figured it was time to update the EC2 instance howto. It is almost exactly the same as <a href="http://www.ioncannon.net/system-administration/115/creating-your-own-fc6-instance-for-ec2/">creating a FC6 instance</a> so if you want to know the details you can reference that article.</p>
<p><span id="more-128"></span></p>
<p>Here is an updated script for creating the AMI the only change between this and the one for FC6 is the yum repo and the image name:</p>
<div class="codesnip-container" >
<div class="bash codesnip" style="font-family:monospace;"><span class="co0">#!/bin/sh</span></p>
<p><span class="kw2">dd</span> <span class="kw1">if</span>=<span class="sy0">/</span>dev<span class="sy0">/</span>zero <span class="re2">of</span>=fedora7-i386.img <span class="re2">bs</span>=1M <span class="re2">count</span>=1 <span class="re2">seek</span>=1024<br />
<span class="sy0">/</span>sbin<span class="sy0">/</span>mke2fs <span class="re5">-F</span> <span class="re5">-j</span> fedora7-i386.img</p>
<p><span class="kw2">mount</span> <span class="re5">-o</span> loop fedora7-i386.img <span class="sy0">/</span>mnt</p>
<p><span class="kw2">mkdir</span> <span class="sy0">/</span>mnt<span class="sy0">/</span>dev<br />
<span class="kw2">mkdir</span> <span class="sy0">/</span>mnt<span class="sy0">/</span>proc<br />
<span class="kw2">mkdir</span> <span class="sy0">/</span>mnt<span class="sy0">/</span>etc<br />
<span class="kw1">for</span> i <span class="kw1">in</span> console null zero ; <span class="kw1">do</span> <span class="sy0">/</span>sbin<span class="sy0">/</span>MAKEDEV <span class="re5">-d</span> <span class="sy0">/</span>mnt<span class="sy0">/</span>dev <span class="re5">-x</span> <span class="re1">$i</span> ; <span class="kw1">done</span></p>
<p><span class="kw2">cat</span> <span class="sy0">&lt;&lt;</span>EOL <span class="sy0">&gt;</span> <span class="sy0">/</span>mnt<span class="sy0">/</span>etc<span class="sy0">/</span>fstab<br />
<span class="sy0">/</span>dev<span class="sy0">/</span>sda1 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="sy0">/</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ext3 &nbsp; &nbsp;defaults 1 1<br />
none &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="sy0">/</span>dev<span class="sy0">/</span>pts &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;devpts &nbsp;<span class="re2">gid</span>=5,<span class="re2">mode</span>=620 0 0<br />
none &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="sy0">/</span>dev<span class="sy0">/</span>shm &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;tmpfs &nbsp; defaults 0 0<br />
none &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="sy0">/</span>proc &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; proc &nbsp; &nbsp;defaults 0 0<br />
none &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="sy0">/</span>sys &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sysfs &nbsp; defaults 0 0<br />
<span class="sy0">/</span>dev<span class="sy0">/</span>sda2 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="sy0">/</span>mnt &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ext3 &nbsp; &nbsp;defaults 1 2<br />
<span class="sy0">/</span>dev<span class="sy0">/</span>sda3 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; swap &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;swap &nbsp; &nbsp;defaults 0 0<br />
EOL</p>
<p><span class="kw2">mount</span> <span class="re5">-t</span> proc none <span class="sy0">/</span>mnt<span class="sy0">/</span>proc</p>
<p><span class="kw2">cat</span> <span class="sy0">&lt;&lt;</span>EOL <span class="sy0">&gt;</span> <span class="sy0">/</span>tmp<span class="sy0">/</span>yumec2.conf<br />
<span class="br0">&#91;</span>main<span class="br0">&#93;</span><br />
<span class="re2">cachedir</span>=<span class="sy0">/</span>var<span class="sy0">/</span>cache<span class="sy0">/</span>yum<br />
<span class="re2">debuglevel</span>=2<br />
<span class="re2">logfile</span>=<span class="sy0">/</span>var<span class="sy0">/</span>log<span class="sy0">/</span>yum.log<br />
<span class="re2">exclude</span>=<span class="sy0">*</span>-debuginfo<br />
<span class="re2">gpgcheck</span>=0<br />
<span class="re2">obsoletes</span>=1<br />
<span class="re2">reposdir</span>=<span class="sy0">/</span>dev<span class="sy0">/</span>null</p>
<p><span class="br0">&#91;</span>base<span class="br0">&#93;</span><br />
<span class="re2">name</span>=Fedora Core 6 &#8211; i386 &#8211; Base<br />
<span class="re2">mirrorlist</span>=http:<span class="sy0">//</span>mirrors.fedoraproject.org<span class="sy0">/</span>mirrorlist?<span class="re2">repo</span>=fedora-7<span class="sy0">&amp;</span><span class="kw2">arch</span>=i386<br />
<span class="re2">enabled</span>=1</p>
<p><span class="br0">&#91;</span>updates-released<span class="br0">&#93;</span><br />
<span class="re2">name</span>=Fedora Core 6 &#8211; i386 &#8211; Released Updates<br />
<span class="re2">mirrorlist</span>=http:<span class="sy0">//</span>mirrors.fedoraproject.org<span class="sy0">/</span>mirrorlist?<span class="re2">repo</span>=updates-released-f7<span class="sy0">&amp;</span><span class="kw2">arch</span>=i386<br />
<span class="re2">enabled</span>=1<br />
EOL</p>
<p>yum <span class="re5">-c</span> <span class="sy0">/</span>tmp<span class="sy0">/</span>yumec2.conf <span class="re5">&#8211;installroot</span>=<span class="sy0">/</span>mnt <span class="re5">-y</span> groupinstall Base</p>
<p>yum <span class="re5">-c</span> <span class="sy0">/</span>tmp<span class="sy0">/</span>yumec2.conf <span class="re5">&#8211;installroot</span>=<span class="sy0">/</span>mnt <span class="re5">-y</span> clean packages</p>
<p><span class="kw2">mv</span> <span class="sy0">/</span>mnt<span class="sy0">/</span>lib<span class="sy0">/</span>tls <span class="sy0">/</span>mnt<span class="sy0">/</span>lib<span class="sy0">/</span>tls-disabled</p>
<p><span class="kw2">cat</span> <span class="sy0">&lt;&lt;</span>EOL <span class="sy0">&gt;&gt;</span> <span class="sy0">/</span>mnt<span class="sy0">/</span>etc<span class="sy0">/</span>rc.local<br />
<span class="kw1">if</span> <span class="br0">&#91;</span> <span class="sy0">!</span> <span class="re5">-d</span> <span class="sy0">/</span>root<span class="sy0">/</span>.ssh <span class="br0">&#93;</span> ; <span class="kw1">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">mkdir</span> <span class="re5">-p</span> <span class="sy0">/</span>root<span class="sy0">/</span>.ssh<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">chmod</span> 700 <span class="sy0">/</span>root<span class="sy0">/</span>.ssh<br />
<span class="kw1">fi</span><br />
<span class="co0"># Fetch public key using HTTP</span><br />
curl http:<span class="sy0">//</span>169.254.169.254<span class="sy0">/</span>1.0<span class="sy0">/</span>meta-data<span class="sy0">/</span>public-keys<span class="sy0">/</span>0<span class="sy0">/</span>openssl <span class="sy0">&gt;</span> <span class="sy0">/</span>tmp<span class="sy0">/</span>my-key<br />
<span class="kw1">if</span> <span class="br0">&#91;</span> <span class="re4">$?</span> <span class="re5">-eq</span> 0 <span class="br0">&#93;</span> ; <span class="kw1">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">cat</span> <span class="sy0">/</span>tmp<span class="sy0">/</span>my-key <span class="sy0">&gt;&gt;</span> <span class="sy0">/</span>root<span class="sy0">/</span>.ssh<span class="sy0">/</span>authorized_keys<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">chmod</span> 600 <span class="sy0">/</span>root<span class="sy0">/</span>.ssh<span class="sy0">/</span>authorized_keys<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">rm</span> <span class="sy0">/</span>tmp<span class="sy0">/</span>my-key<br />
<span class="kw1">fi</span><br />
<span class="co0"># or fetch public key using the file in the ephemeral store:</span><br />
<span class="kw1">if</span> <span class="br0">&#91;</span> <span class="re5">-e</span> <span class="sy0">/</span>mnt<span class="sy0">/</span>openssh_id.pub <span class="br0">&#93;</span> ; <span class="kw1">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">cat</span> <span class="sy0">/</span>mnt<span class="sy0">/</span>openssh_id.pub <span class="sy0">&gt;&gt;</span> <span class="sy0">/</span>root<span class="sy0">/</span>.ssh<span class="sy0">/</span>authorized_keys<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">chmod</span> 600 <span class="sy0">/</span>root<span class="sy0">/</span>.ssh<span class="sy0">/</span>authorized_keys<br />
<span class="kw1">fi</span><br />
EOL</p>
<p><span class="kw2">cat</span> <span class="sy0">&lt;&lt;</span>EOL <span class="sy0">&gt;&gt;</span> <span class="sy0">/</span>mnt<span class="sy0">/</span>etc<span class="sy0">/</span>ssh<span class="sy0">/</span>sshd_config<br />
UseDNS &nbsp;no<br />
PermitRootLogin without-password<br />
EOL</p>
<p><span class="kw2">cat</span> <span class="sy0">&lt;&lt;</span>EOL <span class="sy0">&gt;</span> <span class="sy0">/</span>mnt<span class="sy0">/</span>etc<span class="sy0">/</span>sysconfig<span class="sy0">/</span>network<br />
<span class="re2">NETWORKING</span>=<span class="kw2">yes</span><br />
<span class="re2">HOSTNAME</span>=localhost.localdomain<br />
EOL</p>
<p><span class="kw2">cat</span> <span class="sy0">&lt;&lt;</span>EOL <span class="sy0">&gt;</span> <span class="sy0">/</span>mnt<span class="sy0">/</span>etc<span class="sy0">/</span>sysconfig<span class="sy0">/</span>network-scripts<span class="sy0">/</span>ifcfg-eth0<br />
<span class="re2">ONBOOT</span>=<span class="kw2">yes</span><br />
<span class="re2">DEVICE</span>=eth0<br />
<span class="re2">BOOTPROTO</span>=dhcp<br />
EOL</p>
<p><span class="kw2">sync</span><br />
<span class="kw2">umount</span> <span class="sy0">/</span>mnt<span class="sy0">/</span>proc<br />
<span class="kw2">umount</span> <span class="sy0">/</span>mnt</div>
</div>
<p>Tags: <a href="http://technorati.com/tag/ec2" rel="tag">ec2</a>, <a href="http://technorati.com/tag/fedora+7" rel="tag"> fedora 7</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ioncannon.net/system-administration/128/how-to-create-a-fedora-7-instance-for-ec2/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>A lesson in on the limits of administrating your way out of problems: Shared MySQL</title>
		<link>http://www.ioncannon.net/system-administration/119/admin-shared-mysql/</link>
		<comments>http://www.ioncannon.net/system-administration/119/admin-shared-mysql/#comments</comments>
		<pubDate>Mon, 29 Jan 2007 11:09:19 +0000</pubDate>
		<dc:creator>carson</dc:creator>
				<category><![CDATA[system administration]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://www.ioncannon.net/system-administration/119/admin-shared-mysql/</guid>
		<description><![CDATA[I just finished reading a post to the Media Temple blog about their MySQL problems . I think it is an excellent example of what happens when you only have one side of the house trying to fix a problem. The post leaves out some details but they make it clear that they believe their [...]]]></description>
			<content:encoded><![CDATA[<p>I just finished reading a post to the Media Temple blog about their <a href="http://weblog.mediatemple.net/weblog/2007/01/19/anatomy-of-mysql-on-the-grid/">MySQL problems</a> . I think it is an excellent example of what happens when you only have one side of the house trying to fix a problem. The post leaves out some details but they make it clear that they believe their problems were caused by badly written apps hammering the database. It sounds like they tried very hard to fix the issues on the hardware and MySQL side but couldn&#039;t so have switched the way they are provisioning the database systems to more isolate the problem sites. The moral of that story is that even when you are smart you can&#039;t always fix software problems on the systems side. </p>
<p>The Media Temple guys don&#039;t go into any great detail on their current shared MySQL system but I would think that if nothing else they ran into the problems listed in this post: <a href="http://www.mysqlperformanceblog.com/2007/01/17/performance-impact-of-complex-queries/">performance of complex queries</a>. At some point you just have too many people trying to hit your database for any one person to achieve efficiency.</p>
<p>Tags: <a href="http://technorati.com/tag/mysql" rel="tag">mysql</a>, <a href="http://technorati.com/tag/administration" rel="tag"> administration</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ioncannon.net/system-administration/119/admin-shared-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

