From time to time I come across something truly amazing that I just must share no matter how tired I am. Even though they are typically very simple it helps me remember in the future and I hope it also helps others out wfhen they have the same problems that I do. I recently migrated a server from Slicehost to Linode and I wanted to find a quick and easy way to forward web traffic on various ports to the new server while DNS caught up. The answer was simple… iptables. I found this in an article here.
echo "1" > /proc/sys/net/ipv4/ip_forward iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to-destination 1.2.3.4:80 iptables -t nat -A PREROUTING -p tcp --dport 3306 -j DNAT --to-destination 1.2.3.4:3306 iptables -t nat -A POSTROUTING -j MASQUERADE
Now that I finally have a file server at home I got curious again with disk imaging solutions. After doing some research I found a pretty awesome tool called Clonezilla. After downloading the live CD and playing around for a while the first thing I wanted to do was test it out in a PXE boot fashion. Here was my quick and hackish approach. My test run was on a VirtualBox VM in Xubuntu 10.04 with a bridged adapter.
1. Install TFTP server
sudo apt-get install tftpd-hpa sudo start tftpd-hpa
Ensure /var/lib/tftpboot exists. If it does not:
mkdir -p /var/lib/tftpboot
Ensure that the values in /etc/defaults/tftpd-hpa match.
2. Install DHCP server
sudo apt-get install dhcp3-server sudo vim /etc/dhcp3/dhcpd.conf
Add something similar to the following…
default-lease-time 86400;
max-lease-time 604800;
authoritative;
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.10 192.168.1.15;
filename "pxelinux.0";
next-server 192.168.1.121;
option subnet-mask 255.255.255.0;
option broadcast-address 192.168.1.255;
option routers 192.168.1.1;
}
sudo service dhcp3-server start
The next-server option needs to be the IP of the TFTP server. Everything else should be self explanatory.
Before proceeding verify both services are listening.
sudo netstat -upan | awk '{print $6}'
2008/dhcpd3
582/dhclient
3627/in.tftpd
3. Install syslinux if it is not already (it should be). Copy over pxelinux.0 into the appropriate location.
sudo apt-get install syslinux sudo cp /usr/lib/syslinux/pxelinux.0 /var/lib/tftpboot
4. Download latest clonezilla zip from SourceForge.
sudo unzip clonezilla-live-*.zip sudo cp live/vmlinuz /var/lib/tftpboot/ sudo cp live/initrd.img /var/lib/tftpboot/ sudo cp live/filesystem.squashfs /var/lib/tftpboot/ cd /var/lib/tftpboot sudo touch boot.txt sudo mkdir pxelinux.cfg sudo touch pxelinux.cfg/default
Your tree should end up looking something like this in the end:
├── boot.txt ├── filesystem.squashfs ├── initrd.img ├── pxelinux.0 ├── pxelinux.cfg │ └── default └── vmlinuz
5. Create configs
sudo vim boot.txt
I made my menu look something like the following…
======================================================================== .d8888b. 888 d8b 888 888 d88P Y88b 888 Y8P 888 888 888 888 888 888 888 888 888 .d88b. 88888b. .d88b. 88888888 888 888 888 8888b. 888 888 d88""88b 888 "88b d8P Y8b d88P 888 888 888 "88b 888 888 888 888 888 888 888 88888888 d88P 888 888 888 .d888888 Y88b d88P 888 Y88..88P 888 888 Y8b. d88P 888 888 888 888 888 "Y8888P" 888 "Y88P" 888 888 "Y8888 88888888 888 888 888 "Y888888 ======== Boot Options: ================================================ >> clonezilla ......... Regular Boot >> clonezilla_safe .... Failsafe Mode =======================================================================
And finally the pxe config…
sudo vim pxelinux.cfg/default
Looked something like this:
DISPLAY boot.txt LABEL clonezilla kernel vmlinuz append initrd=initrd.img boot=live union=aufs noswap noprompt vga=788 fetch=tftp://192.168.1.121/filesystem.squashfs LABEL clonezilla_safe kernel vmlinuz append initrd=initrd.img boot=live union=aufs noswap noprompt vga=normal nomodeset nosplash fetch=tftp://192.168.1.121/filesystem.squashfs PROMPT 1 TIMEOUT 0
Please note that the IP address should be the IP of the TFTP server!
Now testing with a Dell Latitude E6410 I hit F12 on the BIOS screen, Select Network Adapter, and SUCCESS! You should see your boot.txt with a “boot:” prompt. Please share your experiences and alternative implementations on how you solved this issue. I would love to hear them!
My Test results:
250 GB (239.9 GB after formatting)
67.7 GB in use
175.2 GB free
Transfer Rate: Started at 900 MB/min at first, peaked at 1.91 GB/min, ended at 1.72GB/min, average 1.7 GB/min
Time elapsed: 37 minutes, 41 seconds
I have been giving it a lot of thought recently. I have been using Ubuntu for a couple years now and I think I am ready to move on. I haven’t tried Gentoo since college and I thought that tonight was a good night to check in on it. I was worried that it may be somewhat dead and that no one used it anymore so I decided to see if they had a chat room on irc.freenode.net – boy was I suprised! The channel was booming! I am currently installing a test drive VM right now. The installation process is so refreshing. Tonight made me realize that I have really let myself go since college. I am sick of Ubuntu and how it constantly wipes my ass for me, but fails sometimes anyway. I currently am running Ubuntu 9.10 with Gnome and the plan is to migrate to Gentoo and Xfce. The following information illustrates my reasons for wanting to switch. Ones that weigh more for me are in bold.
Ubuntu 9.10 Pros:
Just works
Apt package management is speedy
Well supported
Attractive
I know it
Ubuntu 9.10 Cons:
Does too much
Gnome is bloated
Deb package dependencies are crazy sometimes
Can be slow at times
Gentoo Pros:
Very trim and lightweight
Forces you to learn and maintain general linux knowledge
Very flexible
Gentoo Cons:
Takes FOREVER to compile packages and dependencies
Emerge can have issues
Not for lazy people (and im pretty lazy)
As I write this post I am on step 9/10 of the install. I will provide updates as time goes on.
Update 1:
I encountered three problems and got them all resolved. I am currently installing Xfce and xdm right now. The problems I faced:
1. Changed password for root user for install, not chrooted gentoo environment.
2. The install CD loads out of date drivers so hard drives show up as hda during install but sda during initial boot. This screwed up both GRUB and /etc/fstab.
3. I forgot to compile my network card drivers into the kernel so my eth0 device didn’t exist.
I also found this quite interesting and hilarious (click on it to read):

Update 2:
Gentoo compiles are taking WAY too long and the installation takes 4+ hours to complete. This is just not an option these days, especially for my work laptop. I decided to give Arch + Xfce a shot and it was a breeze. I still feel like I get way more control than I did in Ubuntu without all of the bloat. I am going to try this out for a while and see how I like it. If for whatever reason I dislike it, I will be switching to Xubuntu and call it a day.
Selling points on Arch:
The Arch Build System – Amazing!
The Arch User Repositories, for must haves like my beloved google-chrome!
Minimalistic approach
Kris I hope you are happy…
This is a quick and dirty walkthrough on how to integrate Rails with Apache2 in Ubuntu via Phusion Passenger. This guide provides setup instructions for a solution that includes:
Install All Required Packages from Apt
sudo apt-get install apache2 ruby irb ruby1.8-dev rdoc build-essential libopenssl-ruby apache2-prefork-dev libapr1-dev libaprutil1-dev mysql-server libmysql-ruby libmysqlclient-dev
Install RubyGems
wget http://production.cf.rubygems.org/rubygems/rubygems-1.3.6.tgz tar xvzf rubygems-1.3.6.tgz cd rubygems-1.3.6.tgz sudo ruby setup.rb sudo ln -s /usr/bin/gem1.8 /usr/bin/gem
Install Required Gems
sudo gem install rails passenger mysql
Compile Passenger Apache2 Module
sudo /usr/bin/passenger-install-apache2-module
Configure Apache2
sudo vim /etc/apache2/mods-enabled/phusion.load
Add the following:
LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.2.11/ext/apache2/mod_passenger.so PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.2.11 PassengerRuby /usr/bin/ruby1.8 RailsEnv development
Setup Test Virtual Host
sudo rm /etc/apache2/sites-enabled/000-default sudo vim /etc/apache2/sites-enabled/railstest
Add the following:
<VirtualHost *:80>
ServerName localhost
DocumentRoot /var/www/testapp/public
</VirtualHost>
Restart Apache2
sudo /etc/init.d/apache2 restart
Setup Default MySQL Database
mysqladmin create testapp_development -u root -p
Setup Test Rails Application
cd /var/www sudo rm index.html rails testapp -d mysql cd testapp sudo vim config/database.yml
Put in your root MySQL username and password.
Test!
If you see something like the following then you were successful!
Over the past couple of months I have started to really get into the habit of quickly dumping useful information or code snippets into Tomboy notes to save it for future use. I now use Tomboy for the majority of my note taking needs. I am very happy to get away from the notepad / gedit crutch. One issue that I faced is that I had some notes at home on my PC and other notes at work on my laptop. Thankfully, Tomboy notes has a nifty syncing feature that enables us to sync notes over SSH.
1. Create a directory on a server with SSH to host the notes
ssh tgeek@myserver.example
mkdir tomboy
2. Create an SSH key on each machine that you want to sync with and do necessary prep
ssh-keygen -t rsa
ssh-copy-id -i /path/to/keys/mynewkey tgeek@myserver.example
3. Download sshfs on each machine that you want to sync with
sudo apt-get install sshfs
4. Setup Tomboy to sync
4.1 In Tomboy, goto Preferences.
4.2 Click on the Add-ins tab and ensure that Synchronization -> SSH Sync Service Add-in is Enabled (if it is grayed out then it is disabled).
4.3 Click on the Syncronization tab.
4.4 For Service, choose SSH (sshfs FUSE)
4.5 Enter the credentials for your server that you setup in step 1.
ex. Server: myserver.example
Username: tgeek
Folder Path: /home/tgeek/tomboy
4.6 Click Save
I have this working in Ubuntu 9.10 and it is beautiful!