Xen on Ubuntu 8.04 (Hardy Heron)

I have been setting up Xen based virtualization and I just wanted to post the useful links I have found. Unfortunately (at the time of this writing) there are couple of bugs in the Ubuntu repositories for Xen that can make installing and configuring Xen a bit of a headache.

This article on HowtoForge pretty much gives you everything your need to get going (even how to get around the current bugs).

http://www.howtoforge.com/ubuntu-8.04-server-install-xen-from-ubuntu-repositories

This is the user manual for Xen. Unfortunately it is not very descriptive in places, but it is still a good resource.

http://tx.downloads.xensource.com/downloads/docs/user

This is the manual page for xen-create-image. It has some really great examples to base your DomU creation commands from.

http://man.cx/xen-create-image

Below is the Ubuntu community documentation for Xen. They still need some time to update to Hardy.

https://help.ubuntu.com/community/Xen

Static IP Address in Linux (Ubuntu)

Sometimes it can be useful to give a computer a static IP address. I was working on a Xen cluster and kept having to setup each machine with a static IP. I am posting this here to help me remember.

Edit this file.

sudo vim /etc/network/interfaces

Look for the lines that should say something like the following.

auto eth0
iface eth0 inet auto

This is presuming you only have one ethernet device in you computer. If you have more than one you may need to change eth1 or eth2 (or whatever), depending on which one you are using.

Take those lines and make it look something like this.

auto eth0
iface eth0 inet static
    address 192.168.0.150
    netmask 255.255.255.0
    network 192.168.0.0
    broadcast 192.168.0.255
    gateway 192.168.0.1

The ‘address’ is the static IP address that you choose. The rest of those could also be different depending on your network configuration and the IP address of your router (’gateway’ is usually the IP of your router).

After you get that setup like you want you can restart networking to test it out.

sudo /etc/init.d/networking restart

Then you can check that everything is correct by looking at the output of ifconfig.

ifconfig

It should show your device and the static IP address.

I was doing this on Ubuntu, but it should work for other distros as well.

Here is the reference link that helped me figure this out.

http://codesnippets.joyent.com/posts/show/319

Counting the Lines in a Set of Files

I find myself needing this command every once in a while and I can never remember exactly how it goes. It parses through a directory (and subs) to give you a report on how many lines are in each file. It is great for working with csv files.

wc -l `find ./ -name '*.csv'`

I got this from an old post on Dev Shed forums that I participated in. I posted it here so I don’t have to keep seeking out the post every time I am trying to remember this command.

http://forums.devshed.com/showthread.php?p=1857692#post1857692

Connecting to an MSSQL Server (and others) with OpenOffice.org

I have wanted to try out OpenOffice.org Base for some time now, but I have never taken the time to figure out how to make it connect to a relational database system. And as it turns out there doesn’t seem to be all that much documentation to help. Anyway I needed to figure out a way to look over the structure of a Microsoft SQL database and I didn’t have access to a Windows machine, let alone Enterprise Manager.

So OpenOffice.org uses JDBC to connect to various databases, but sadly it does not come bundled with any of the libraries required to connect and communicate. So after researching a little I came across jTDS. And with a little messing around I got it to work. Below is what I did.

  • First you have to download jTDS at http://sourceforge.net/project/showfiles.php?group_id=33291.
  • Second, uncompress the file and store it somewhere out of the way on your computer (such that you don’t accidentally move or delete it). You can store the whole folder or just the jtds-x.x.x.jar file.
  • Third, open up OpenOffice.org and go to Tools, Options…, OpenOffice.org (or NeoOffice), Java and then click on Class Path… and then Add Archive…. Choose the jtds-x.x.x.jar file and hit Open. Then keep hitting Ok until all preference windows are closed.
  • Fourth, you need to close and reopen OpenOffice.org for the change to take effect.

  • Fifth, open up Base and when the wizard comes up choose Connect to an existing database, choose JDBC from the dropdown and then hit Next.
  • Sixth, the Datasource URL is of the form below.

    jtds:sqlserver://[host]:[port]/[database]

    Replace [host] with the hostname of the server, replace [port] with the port that the database connects over (the default is usually 1433) and replace [database] with the name of the database.

  • Seventh, for the JDBC driver class put in the below.

    net.sourceforge.jtds.jdbc.Driver

    You can hit Test class if you want to. It should give you a promising message. After all of the fields are filled out hit Next.

  • Eight, on this screen you can fill out the authentication information. This should be pretty straight forward and you can test it to see that it is connecting properly. And then on the last screen you can set some final options and then save the local connected copy somewhere.

After that you should be able to see and browse the tables, build queries and have fun.

- - - - -

You can also use this jTDS driver to connect to Sybase. All you have to change the Datasource URL to this form.

jtds:sybase://[host]:[port]/[database]

- - - - -

For connecting to MySQL you can follow these same steps except you need to get the MySQL JDBC driver class from the MySQL website (http://www.mysql.com/products/connector/j).

The Datasource URL is:

mysql://[host]:[port]/[database]

And the JDBC driver class is:

com.mysql.jdbc.Driver

Command Line Reference

Came across this on digg today. It is another reference sheet for common Linux/Unix commands and programs. It has a lot of good common uses of good programs like scp, rsync, svn, psql and mysql.

http://cb.vu/unixtoolbox.xhtml

Using rsync to Backup a Home Folder

I have been trying to get more serious about my personal backups lately and I have finally started to figure out a scheme. I have a primary machine that is setup as a RAID 1 with two drives such that it keeps two copies of every file. And then every once in a while I copy the home directory with all of my files from that computer to an external drive.

It takes forever to transfer my home directory full of files over to the drive, so I decide to try and use rsync to synchronize the drives by only copying, moving and deleting the files that have changed.

For those of you who have never heard of rsync, it is an Open Source utility that can be used to copy files from one place to the other while minimizing the amount of transferring by detecting differences between the source and destination and only transferring the differences. So if you are trying to archive or backup a lot of files this can save a lot of time.

rsync is a pretty advanced tool and it took me a while to get the command correct, so I thought I would share it here in hopes that it might save someone else some time.

# rsync -rptDuv -e ssh user@127.0.0.1:/home/user/* /media/backup

Let me explain this in detail. First you have the command itself.

# rsync ...

Then you have the options.

# ... -rptDuv ...

The ‘r’ is for recursive, which means that it will go into folders and copy those files as well. The ‘p’ keeps the file permissions in tact. The ‘t’ is for time, which means that the copied files will keep the same created and modified times as the original. The ‘D’ is to account for special files, I am not sure that this was needed for my purposes. The ‘u’ is for update, which means it is not to copy files that already exist on the destination. The ‘v’ is for verbose, which just means that it will tell you what it is doing as it does it.

The next part is the source folder (i.e. the files you want to backup). Since my source folder was actually on another computer I had to specify some extra stuff to connect to it.

# ... -e ssh user@127.0.0.1:/home/user/* ...

If you were just backing up a folder on the same computer you could just do something like this instead.

# ... /home/user/* ...

One thing to note about the source is that I had to specify the ‘*’ at the end to prevent it from trying to backup hidden files as well. Since most of these files were just random configuration files for the user, I didn’t feel I needed to back them up.

Last is the destination (i.e. where you are keeping your backups). I am transferring mine to an external hard drive so I can take it to another location.

# ... /media/backup

The first time you run the command it will transfer the whole set of folders and files to the backup drive. But after that it will only update the backup drive with the changes you have made.

Thanks to Chad from the Linux Basement for helping me work through this command over IRC.

Relaying Mail to a SMTP Server That Requires Authentication (Ubuntu/Postfix)

I have been playing around with setting up a home server and one thing I learned is that my current ISP does not allow an SMTP server to send out mail. This meant that any of the random web applications or server software I installed was unable to to generate and send an email that would actually be received to an email account in the outside world.

I imagine that my ISP does this to cut down on the amount of SPAM that is generated from their network (through virus infected computers and such). Thankfully my ISP also offered a SMTP server that I could forward mail through, however it requires authentication.

I am using an Ubuntu server and it runs Postfix as the default MTA, so I figured I would just use it to forward the mail from my home server, through my ISP’s server and then out to the world.

Here is what I had to do to get it working.

First I opened up the main.cf file for Postfix.

# sudo vim /etc/postfix/main.cf

Add these lines to the file. The ‘relayhost’ line might already be in the file. Set that line equal to the server you intend to relay through. I saw some examples that didn’t include the brackets (’[]’), but mine wouldn’t work without them.

relayhost = [smtp.my.isp.com]

smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl/sasl_passwd
smtp_sasl_security_options =

After you save that file, create a directory to store your password files in.

# sudo mkdir /etc/postfix/sasl

Next you need to create your password file.

# sudo vim /etc/postfix/sasl/sasl_passwd

Inside that file you need to add one line that defines the username and password for the smtp server you want to relay through.

smtp.my.isp.com username:password

Once you create the password file, you need to create a hash of it.

# postmap /etc/postfix/sasl/sasl_passwd

This should create a file called sasl_passwd.db in the same directory. At this point you can either change the permissions on the file ’sasl_passwd’ to protect your login information or I think you can just get rid of it.

After that all you have to do is restart the daemon.

# sudo /etc/init.d/postfix restart

Now your server should be able to send mail out the the real world by relaying it through the other server.

This article below helped me greatly in figuring out how this is done.
http://ben.franske.com/blogs/bensbits.php/2005/09/06/postfix_smtp_auth_support_for_relayhost

Linux/Unix Cheet Sheet Collection

This is a great article that compiles over fifty references for both Linux and Unix. It pretty much all command line references, which can be really handy.

Thanks to Scott Klarr for compiling this list of references.

Linux-Unix cheat sheets - The ultimate collection

Color Scheme Tool

This is a great tool for generating color scheme ideas from a single color. You can generate complements, split-complements, triads, tetrads, analogous and monochromatic colors from your source color. The thing I really love about it is that has a button that will give you a random color to generate a scheme from, this is really useful for brainstorming color ideas.

I used this tool to come up with the colors on this theme (as of the writing) based on the triad colors of the shade of blue. This is one of the many applications that I enjoy that you can’t find anywhere except on Linux.

Project Homepage
http://home.gna.org/colorscheme

Free Ubuntu Workshops

With the coming release of their new version the people at Canonical are running some free workshops all through the week of October 22nd through the 27th. I am pretty excited. The schedule looks like it has a lot sessions related to the different derivatives of Ubuntu as well as some Q&A. It seems that they are focused on how to get involved, but I am sure that it will be an informative event even for the casual Ubuntu user.

I am going to try and attend what I can and then just transcribe the rest for later reading.

Information about the sessions.
https://wiki.ubuntu.com/UbuntuOpenWeek

The workshops will be done over IRC. Below is a list of IRC applications for the different platforms, so you can join in. I would encourage anyone looking for volunteer opportunities to consider giving time to worthwhile open source projects.

Linux
Konversation - http://konversation.kde.org
XChat - http://www.xchat.org

Mac
Colloquy - http://colloquy.info

Windows
XChat - http://www.xchat.org

...older
{
}