2009-09-15

IP address on GDM login page

I have several virtual machines that I keep around for various reasons. To save room I usually 7zip them and burn them to DVD. Then I can keep on my drive just the virtual machines that I am currently using.

Often times when I restore a virtual machine and start it running. I will need to access it from another machine on the network, or in the case of a web server, make a firewall rule that will let me be able to access the service from the Internet. Either way, it is a waste of time to have to log into the virtual machine, bring up a shell and run ifconfig to determine the ip address.

This little trick will make it so the ip address of the computer will show up on the GDM login screen. In a nutshell we will edit the GDM startup script to draw the ip address on the background for the current GDM login theme.


I am a big command line guy. So all of the work we will be doing will be done with a shell. So open up Konsole or Gnome Terminal or whatever shell you typically use.

Step 1: Install imagemagick

sudo apt-get install imagemagick


Step 2: Determine the current GDM theme.

cat /etc/gdm/gdm.conf | grep GraphicalTheme=


Will print the current theme. Make note of what it is. In my case it the output of the above command yields:

GraphicalTheme=Human


So I will be working with the Human theme.

Step 3: Determine the background file name.

cat /usr/share/gdm/themes/Human/Human.xml | grep background


Note that I used the theme name exactly as shown noting both uppercase and lowercase letters. The folder the theme files are in matches the theme name and the configuration file matches the theme name and ends in .xml. The output of the above command yields:




So we can see that the name of the background file is background.png.

Step 4: Rename the original background file so we can use it as a "template" to write on when we generate the background file with the ip address written on it.

sudo cp /usr/share/gdm/themes/Human/background.png \

/usr/share/gdm/themes/Human/background-original.png


Step 5: Edit the GDM startup script to take the original background and write the ip address on it and save it out with the name GDM expects to find for the background. Use whatever editor is on your system to do this. For Gnome it will be gedit. For KDE it will be kate for Xubuntu it will be leafpad.

sudo gedit /etc/GDM/Init/Default

Step 6: Change the section that says:

sysmodmap=/etc/X11/Xmodmap
XMODMAP=`gdmwhich xmodmap`

To read:

sysmodmap=/etc/X11/Xmodmap

cd /usr/share/gdm/themes/Human
convert -pointsize 40 -draw \
"fill yellow text 10,50 \" \
`ifconfig eth0 | awk '/inet addr/{print $2 }'`\"" \
background-original.png background.png

XMODMAP=`gdmwhich xmodmap`


Please note the theme name, what network interface you are using (eth0, eth1, etc) and both the name of the original background file and the background file you writing to.

Step 7: Reboot

After rebooting, in large yellow text you will see the ip address of the computer written on the background of the GDM login screen.

2009-05-16

Slax...or every jedi must make his own lightsaber

Slax is a portable version of Linux that can be run from a cd-rom, a flash drive, or even launched from a hard drive. What makes Slax so special is how easy it is to modify. Slax is made up of modules and magic.

The by default Slax runs a simple KDE desktop. It can be extended by adding modules to it. Modules can be downloaded from the internet while it is running and installed and used immediately. There is also a "modules" folder for adding modules that will run when slax is started. There is a limited amount of memory and a limit to how many modules can be loaded. There is also a folder called "optional" where you can place modules that you want to load only when they are going to be used. For example you could load one set of modules for reformatting a hard drive (gparted). At another time, load a set of modules for working with encrypted file systems (truecrypt). At another time, load a set of modules for recovering pictures from a memory stick (testdisk).

Then for the magic. There is a folder called "rootcopy" when slax boots the followng happends
  1. The kernel loads
  2. The base modules for linux, x, kde, etc are loaded.
  3. Services are started
  4. Modules from the "modules" folder are loaded
  5. Everything in root copy is copyed to the root of the linux system.
  6. rc.local is run
  7. a text prompt or kde session starts.
So it is possible to drop in scripts and files into users folders. Scripts can be run before users are logged in, or a kde session can be started and KDE can autorun any programs or scripts desired.

A typical Linux guru can install slax on a memory stick, set the stick to be bootable, copy modules into the modules folder. Copy files into the rootcopy folder. Then have a customized copy of linux that does exaclty what they want it to do. That is the beauty of Slax. Any other live Linux distro can be remastered. However it takes much more work and skill to do so. Slax makes it easy and fun.

My copy of Slax has the following tools on it.
  • ssh to allow remote logins
  • x11vnc to allow remote control of the KDE desktop
  • dmraid to deal with systems with RAID arrays
  • gparted to rezie drive partitions
  • partimage to backup and restore partitions
  • samba to connect to smb shares for back/restore jobs
  • testdisk to recover deleted files on flash drives
  • truecrypt for working with encrypted drives
Over the course of the next several blog entries I am going to show how to do the following.
  1. Download Slax with most of the needed plugins
  2. Add the remaining plugins and to be able to dual boot Slax and Windows
  3. How to resize paritions, mount windows folders from the network
  4. How to backup and restore windows over the network
  5. How to create a "recovery CD"
  1. When this series is done you will be able to remotely reboot a windows machine to run Slax and then create a backup image or restore a backimage. This makes it possible in a company to fix a broken windows install. From 1000 miles away you can reboot a broken windows install and replace it with a backup copy to get everything working again.