Linux on a Laptop?

How this issue of Linux@UK is being edited! I have to earn a living as well as editing "linux@UK" and as part of this I recently started a long stint of commuting from Birmingham to London every day on the train. The journey is about 100 minutes each way so I though I must put it to good use by making it Linuxing time rather than just snoozing and reading the paper.

I scanned the ads for laptops in the glossy magazines for some time but the spec for the sort of machine I wanted was about 1500 and then some for memory above the poultry 4MB that all but the most dazzlingly specified systems seem to think is enough. I wanted to spend less than a thousand pounds if possible (don't we all) so something in my aspirations had to give. I decided that an older 386 powered machine would be up to whatever jobs I could do on the move; after all just five years ago my main Unix system with X Windows and everything was only a 25MHz 386 with 8MB and I don't remember thinking it too slow to be any use then!

I was drawn to Computer Bargains of Manchester ad for IBM Thinkpad model 300 machines that they had for 499. The price was attractive and had the added bonus that it only came with DOS and not Windows. With only a 120MB hard disk I was intending to make a dedicated Linux machine anyway.

As supplied the machine only had 4MB of memory. Once I was happy that the Thinkpad was working I ordered an 8MB memory module. This was quite a price compared to the machine but at 280 for 8MB equating to 140 per 4MB was at the lower end of the price scale for portable memory. A 4MB module bringing the total memory to 8MB would have been enough but the expansion choices for the Thinkpad are a 2MB module or an 8MB module occupying the same space.

I digress slightly.. Until my extra memory arrived I has faced with the problem of getting Linux up and running on a 4MB machine. I think that this would be a good experience to relate.

The first important point to note is that modern 1.2 Linux kernels, even when compiled with the minimum of options, seem to be just too big to do an initial system build with (because Slackware insists on using a lot of your meager supply of memory as a ram disk to run the installation system). The critical point after which all should be well is the partitioning of your hard disk with fdisk and the creation of a swap partition with mkswap. Once a valid swap partition can be added with swapon even the tiny amount of working program memory (around 80k with the ramdisk in place) is enough to carry on with the build process. This first stage should be done by booting an old 1.0.9 bare boot disk - it is the only one that seems small enough for my system.

The best way to go about putting linux on a portable is to load the base operating system disks (A set in Slakware) and then the networking disks (N). This gives you a bootable system that a modern kernel with the parallel IP driver compiled into it can be copied onto. This is assuming that you, like me already have a working Linux system to hand to build kernels on.

The next step is to obtain a printer port to printer port parallel transfer cable. This should be available from places like the Byte computer superstores (where I got mine) labeled as a 'File transfer Kit' or 'Laplink/Interlink cable' These only cost a few pounds and are jolly handy to have!

Spurred on by the excellent treatment of the subject in Olaf Kirsh's "Linux Network Administrators Guide" I then set up a TCP/IP link over the parallel port with the aim of mounting the CD ROM on my base computer so that the Linux installation could be completed without any more swapping of floppy disks.

The first hand thing that the "Linux Network Administrators Guide" taught me that there are some ranges of internet addresses that are usable for local networking without having to be registered. What happens is that net gateways will drop packets originating from such addresses. What this means is that as long as through routing of traffic from the net is not desired the choice of a network to act as my humble desktop to portable link is easy and safe rather than just 'borrowing' an address and hoping for the best. The network I chose was 192.168.0.0 - you are free to choose the same one as there is no way the two networks will ever meet!

The /etc/hosts files on both machines carry the following entries

192.168.0.1	base		# the base computer (with a CD ROM)
192.168.0.2	thinkpad	# the portable that needs to be loaded
Setting up the point to point network interface is very simple. In /etc/rc.d directory there is a file called rc.inet1, here is a copy of mine:

#! /bin/sh
#
# rc.inet1	This shell script boots up the base INET system.
#
# Version:	@(#)/etc/rc.d/rc.inet1	1.01	05/27/93
#

HOSTNAME=`hostname`

# Attach the loopback device.
/sbin/ifconfig lo 127.0.0.1
/sbin/route add -net 127.0.0.0

/sbin/ifconfig plip1 ${HOSTNAME} pointopoint base
/sbin/route add base

On the base system the ifconfig and route commands are the other way around:
/sbin/ifconfig plip1 base pointopoint thinkpad
/sbin/route add thinkpad
Note that base has to be given rather than ${HOSTNAME} as it is not the real hostname of that machine - which maps to my proper Internet address. Also there is no reason for a naming scheme more fancy than the two entry hosts file on the thinkpad as it will never route packets anywhere else.

This in place should give the ability to ping, ftp or telnet between the two systems. However the real boon of natural file system access needs a little more effort in setting up.

Firstly in the file /etc/rc.d/rc.inet2 please check that the lines to start the rpc portmapper are NOT commented out. The section of the file should look like this:



# Start the SUN RPC Portmapper.
if [ -f ${NET}/rpc.portmap ]
then
 echo -n " portmap"
 ${NET}/rpc.portmap
fi

And later on in the file...

# Start the various SUN RPC servers.
if [ -f ${NET}/rpc.portmap ]
then
 if [ -f ${NET}/rpc.ugidd ]
 then
  echo -n " ugidd"
  ${NET}/rpc.ugidd -d
 fi
 if [ -f ${NET}/rpc.mountd ]
 then
  echo -n " mountd"
  ${NET}/rpc.mountd
 fi
 if [ -f ${NET}/rpc.nfsd ]
 then
  echo -n " nfsd"
  ${NET}/rpc.nfsd
 fi
#  # Fire up the PC-NFS daemon(s).
#  if [ -f ${NET}/rpc.pcnfsd ]
#  then
#   echo -n " pcnfsd"
#   ${NET}/rpc.pcnfsd ${LPSPOOL}
#  fi
#  if [ -f ${NET}/rpc.bwnfsd ]
#  then
#   echo -n " bwnfsd"
#   ${NET}/rpc.bwnfsd ${LPSPOOL}
#  fi
fi
Note the PC-NFS part is optional - but don't forget to uncomment that trailing 'fi'!

If any changes have been needed then restart the machine in question.

On the base machine an /etc/exports file should be created looking like this (assuming you want to export your /cdrom directory to a machine called thinkpad):

#
# exports	This file describes which parts of the local file
#		system are available for mounting by other systems
#		with the NFS system.  It is used by "mountd".
#
# Version:	@(#)/etc/exports	2.00	04/30/93
#
# Author:	Fred N. van Kempen, 
#
/cdrom	thinkpad(ro,insecure)
# End of exports.
On your portable edit the /etc/fstab file add the following line:
base:/cdrom	/cdrom	nfs	timeo=50,soft,intr
Finaly mkdir /cdrom and mount /cdrom. The mount options are a more generous than normal time-out as parallel port IP is somewhat slower than ethernet, together with soft, interuptable file system mounting. What this means is that the portable will still boot even if disconnected from the host file system!

If you now ls /cdrom you should see the contents of the cd rom base directory just as if you had a CD drive in the portable itself.

Form here on it in is a simple matter to install or copy whatever extra software you want onto the laptop. The speed of the parallel IP link is about 20k a second falling to about 16k a second when I was working the Thinkpad really hard at the same time. It seems poor when compared to the 600K a second typically obtained from ethernet. However it is faster than most leased lines, faster even than a dual channel ISDN. I found the performance with X windows very acceptable - I was happily running X terminals and other programs from machine to machine with no detectable speed penalty.

If you want to get a feel about how things will work over a leased line or ISDN internet connection then a plip link is a good and very cheap simulator.

Now you have the Slackware CD mounted extra packages can easily be brought on board the portable using the 'setup' tool. From 'Select Source Media' choose option 4 'Install from a pre-mounted directory' and then enter the path to your NFS mounted slakware area (mine is /cdrom/slakware).

My overall assessment of the Thinkpad? A stylish machine with crystal clear display and reasonable 3 hours plus battery life (thanks to Nickel Metal Hydride battery). No compatibility problems with Linux whatsoever. What I really like is that the suspend/resume and keyboard controls for clockspeed and setup program all work with Linux. An intriguing feature of my 300 model is that it seems to have half an ethernet adaptor built in. If any IBMers reading could supply me with programming information and an adapter cable for the beast I may be able to move my portable to base link onto full ethernet.

I could possibly find some power management code for it if I looked on the net but for the moment it is doing just fine. One thing that would be nice is dynamic switching between high and low clock speed depending on CPU load. As I spend lots of time typing into vi (which 1/4 speed does fine) but need occasional spurts of full power dynamic switching would save me having to remember to change speeds at the keyboard.

This article, and most of this issue of Linux@UK was put together on the train on the Thinkpad. I would not want to have machine that is just a VGA display 386 with 120MB hard disk as my main machine but as a second machine, portable and networked to the first it does its job brilliantly!

By the way - I nice thing that I have discovered about the X Free86 X Windows server: Even the 16 colour VGA driver that I have to use on the thinkpad has an 800x600 scrollable virtual desktop even though the portable screen is strictly 400x800. If I had more video memory I could have had a really big desktop with the portable screen being a smooth gliding window over it. The same sort of capability with Microsoft Windows is the province of very fancy graphics cards. Another question for IBM: is it possible to put more VRAM into my Thinkpad? More VRAM equals bigger desktop!