Debian Wheezy on a ThinkPad 365X
Written 2014-08-06
Tags:Linux Open source Debian ThinkPad
Intro
I've had this old ThinkPad for quite a while. I used to run Linux 2.6.8, but after the libata rewrite, debian wouldn't boot due to a missing root partition. Until today. Today I run debian stable.Prerequisites
Hardware - Thinkpad 365X
- Intel Pentium@120MHz(f00f bug and everything)
- 8MB Integrated RAM(This can't do it alone)
- 64MB expansion RAM(32MB should also work, 16MB would be sketchy)
- 35MB total RAM recognized(try bios upgrade?)
- 2GB CF card(super-cheap, much faster than contemporary spinny-disks)
- IDE44<->CF adapter, approx $5 from Shenzen
Hardware - Other
- USB<->CF adapter or USB<->IDE44 adapter, approx $5 from Shenzen
- Computer with kvm/qemu
Software
Inserting the Disk in the VM Host
Since we're going to be working with raw disk IO, you'll need to unmount any automounting done when you connect the disk over USB to the VM host. Simply put, we don't want two OS kernels fighting for the same block device.Creating a Virtual Machine image(optional, but recommended)
First, create a VM image of exactly the same size as your CF card or target hard disk. For QEMU/KVM, a file full of garbage is fine, or you can just rip the disk with dd using `dd if=/dev/sdX of=~/vmfilename.img bs=1M`.Installing Debian in a Virtual Machine
KVM(or QEMU in a pinch) can be used to simulate a classic Pentium system, but not directly the one in the Thinkpad. `sudo {qemu or kvm} -hda {path to VM image or /dev/sdX} -cdrom {path to debian} -boot d -m 1024 -cpu pentium` Breaking it down:- sudo - run the command as root to allow qemu raw disk access. May also be needed for KVM(but not QEMU). Skip if using VM image with QEMU.
- kvm - run a kernel-virtual-machine. Basically QEMU + hardware virtualization
- qemu - run the old-school cpu emulator. Slower, but works on any host CPU, doesn't require root access
- -hda - tell qemu/kvm where to find the disk image.
- -cdrom - tell qemu/kvm where to find the CD image.
- -boot d - tell qemu/kvm to boot from CDROM this time.
- -m - Set VM RAM. In my case I used 1GB because it makes the installer a bit faster, but default also works.
- -cpu - Set VM core type. In my case I set it to Pentium. This will cause the Wheezy installer to pick an i486-compatible kernel+libc
- Old spinning disks are slow. Mounting partitions with 'noatime' or 'relatime' is quite helpful for this.
- If you are low on disk space / ram, you will likely wish to install zero additional packages; I unchecked all the boxes. The complete desktop environment isn't really an option here either.
Removing The Extras
This topic is best handled elsewhere. Removing daemons will save RAM, removing things in general will save disk space. The 365X is very limited by today's standards.Install Your Favorite Packages
Now(while we have an emulated ethernet connection) is a good time to pull down any WiFi firmware you might need, as well as the pcmciautils package, and any other tools. Here's my list(455MB used/2GB total), less than 9MB RAM used after bootup:- sudo
- cupt
- htop
- nload
- hexedit
- pcmciautils
- linux-firmware-free
- linux-firmware-nonfree
- linux-wlan-ng
- openssh-client
Building a New, Smaller Initrd
At least with 35MB of usable RAM, the default initrd won't fit. You might be able to do it with bios support for a 64MB stick. The last time debian had an initrd that did fit, it no longer contained the required ATA drivers for the 365X. So, to rebuild:- Copy+rename the existing initrd alongside the current one. You'll find it in /boot/initrd-{somethingorother}
- edit /etc/initramfs-tools/modules to add "pata_legacy". If you want to be able to reboot in the VM, also add ata_piix.
- edit /etc/initramfs-tools/initramfs.conf to set "MODULES" to "dep"
- sudo update-initramfs -u
Burning the Image to Target(required if using VM image, otherwise skip)
Burning the image back to the disk is just the reverse of ripping it. Flip the arguments on dd, taking care not to use the partition number.Ejecting the Disk
Just run `sync`, then `eject /dev/sdX`, then wait for any lights to stop blinking, then unplug.Booting up the 365X
Unplug power and battery, click the power button to make sure the board is drained, insert the card, replug power, hit switch.It should just work. However, here's some of the problems I had along the way, in the order I had them, that should've been fixed by following the above instructions:
- Hung up in Grub - turns out Grub is just really slow on this box.
- Hung up loading initramfs - caused by initramfs too large for current RAM. The kernel used to give a nicer message about this. Fixed by removing unused modules in initramfs rebuild above.
- Hung up in (initramfs) prompt - caused by missing ATA driver pata_legacy. Fixed by initramfs rebuild above.