[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

emdebian install report



tl;dr - I brought up Wheezy with an i486 kernel using under 200MB
of storage. Then I summarized verbosely using markdown and URLs.

# Install of emdebian grip (wheezy) August 2012

Here is an installation report written more as a story as an attempt
to include the context and motivations as well as the technical
details. While working on this task, I realized much of what is
written has come from experts with great knowledge of the subject
punctuated by strange but sometimes enlightening errors found by
people with little knowledge of the subject. In each case the
context and motivation was so well understood by the authors that
it wasn't even written down.

# Motivation

## Origins

A few years back I set up a computer dedicated to a single task,
placed it in a safe place connected to some additional analog
electronic devices. Of course, doing this in the early 21st century,
it all had to be Internet connected. To help keep it safe, I
installed Debian on it, to follow the benefits of security
updates. But it also got the benefits of more general updates
to keep up with progress in the world: I had installed Debian's
Sarge version - and over the years upgraded to Debian's newer
stable versions (Etch, Lenny and finally Squeeze). It became
reachable via IPv6 as well as IPv4 and kept chugging away at its
few tasks. It was a happy little computer.

## Natural Disaster

[June 2012 North American derecho](http://en.wikipedia.org/wiki/June_2012_North_American_derecho)

The effects of combining wind, trees and power lines meant
that the main power to this happy little computer became
quite disturbed. Several cycles of power on / power off / power on /
power off were observed over just a few minutes, possibly accompanied by
unobserved voltage spikes. (The lightning accompanying the
wind was well observed.)

Then the power was off for several days. When the lights
came on, the happy little computer did not boot.
Even the power supply for the analog electronic devices
no longer supplied power.

## Post mortem

The happy little computer was no longer happy. The
motherboard BIOS would run, but not find a hard drive.
The hard drive was no longer working, and would not
come up even when attached to a newer, non-traumatized
computer. But what's more - even known good hard disks
were not found by the unhappy little computers BIOS.

Time to put the old hard disk, the motherboard and its
power supply into the appropraite recycling dumpster.

## More crufty old hardware

It's now August 11, 2012.

I was remarking that failure of an old IDE hard drive
was really no surprise, and I really think I've got
good backup copies of the important stuff. While that
vintage technology did the job just fine, I was worried
that any technology refresh would bring us into a
new motherboard with SATA interfaces, and a new SATA
hard drive, and associated power supply with SATA power
pins....

"I've got some extra solid-state disk chips from retired
thin client computers that you could use...", said
a compassionate, helpful colleague. These turned out
to be 40 pin PATA Disk on Module devices with a whopping
256MB capacity. I also got two with only 32MB. Thanks!

SimpleTech 256MB IDE Flash Drive Disk On Module DOM
[like](http://www.ebay.com/itm/SimpleTech-128MB-IDE-Flash-Drive-Disk-On-Module-DOM-060130-FL1-003-94000-01201-0-/140742916320?pt=US_USB_Flash_Drives&hash=item20c4ee78e0)

[PQI DiskOnModule DOM 32mb Flash Memory p/n FD032-019PR](http://www.5rltd.com/productcart/pc/viewPrd.asp?idproduct=790&idcategory=73)

This will let me use some other cast-away pre-SATA
motherboard to rebuild the system. (Yes, I know very
well that even in these trying times we can afford to
buy new stuff. But that's beside the point. The old
system was built of dumpster-grade parts - so should
the new system to replace it. Using other people's trash
is a design goal.)

## A new (old) computer

I found a motherboard: a mini-ITX VIA EPIA system.
Nice, small. No gigabit ethernet. No SATA. 256M RAM.
Perfect. It does have a parallel port. (Try that
trick with a new Atom-based board...)

So off I went to install Debian. I was able to netboot
the beta version of the debian-installer for Wheezy.
(Easy for me, but I do not recommend that Beginners
try this if they wish to retain their Beginner status.
I happen to already have a pre-existing up to date
Debian system providing DHCP and tftp for my home
network, and I've netbooted plenty of things before.)

I turns out that 256 MB of disk space is not enough
to install Debian Wheezy. So I put aside the flash
disk-on-module device and went ahead and installed
Debian Wheezy on a 12 GB laptop hard disk.

The sensible thing to do, of course, is just run
standard Debian on the available laptop hard disk,
and move on to replace the failed computer.

Instead of doing the sensible thing - I figured it
was time to use the Embedded version of Debian.

# Emdebian

	"Why use Emdebian rather than Debian?

	The most obvious reason is installation sizes."

-- [Embedded Debian](http://www.emdebian.org/)

	"What's Emdebian Grip all about?

	Simply a smaller Debian. Smaller packages, smaller downloads,
	smaller sets of packages, smaller installation sizes and smaller
	update sizes; yet always and completely binary compatible with
	Debian. Every backtrace from an Emdebian Grip device will match
	the backtrace on a Debian machine of the same architecture,
	package version etc. Packages can be mixed trivially (with some
	allowances for strict dependencies like -dbg packages). The name
	is a derivative of Squeeze - to make Debian smaller, we take a
	hold of it; Grip it."

-- [[Neil Williams, 15 November 2010](http://www.linux.codehelp.co.uk/serendipity/index.php?/archives/217-Documenting-Emdebian-intro.html)

It would be cool if I cound make a replacement computer
system that used disk on chip. The old system produced
hard drive noise for years on end. Quieter is better.
Low power is better, since then the power supply, too,
can be fanless. Maybe use
[one of these](http://www.mini-box.com/DC-DC).

Starting with the laptop disk install is good. The Wheezy
base system installs and runs fine on i486 level of
CPU and only 256 MB of RAM. And it gave me a stepping
stone for installing Emdebian on the 256 MB module.

While Debian as a whole is remarkably well documented,
the Emdebian specific methods and tools are minimally
documented. Most current embdebian use is in the realm
of small, battery powered ARM CPU computers, and yet
I find myself using 10 year old computer parts. But there
are good things on the web sites, wiki pages, blogs
and mailing lists that are worth amplifying by quoting
them here.

## Web page wisdom

[Flavors of Emdebian](http://www.emdebian.org/emdebian/flavours.html)
 -  Grip, Baked and Crush flavors.

I am interested in
[Grip](http://www.emdebian.org/grip/).

[Multistrap](http://www.emdebian.org/multistrap/index.html)
[grip-wheezy.conf](http://www.emdebian.org/multistrap/examples/grip-wheezy.conf)

[EmdebianIntegration](http://wiki.debian.org/EmdebianIntegration) -
the work in progress to improve automation and maintainability
so that what began as Emdebian in the form of a project separate
from Debian becomes merely another feature included in Debian.

[Emdebian 2.0](]http://www.emdebian.org/release/squeeze.html) - the
squeeze release.


## Mailing list wisdom

	"Successful debootstrap of armel with emdebian!"
	
	"Just a quick note to let you know that I've just finished setting up a
	debootstrapped armel using almost solely the emdebian repositories. Great work, guys!!"

-- [Bill Gatliff et al, mailing list thread 09 Jan 2009](https://lists.debian.org/debian-embedded/2009/01/msg00013.html)

	"Crush? There are no packages for Crush outside ARM for Lenny. (not
	armel or armhf). There is no method of adding packages to Crush - none
	at all. Until we have MultiArch in Debian and cross-building can be
	migrated to MultiArch, there have been and will be no updates for Crush."

	"The apt-grip manpage is slightly out of date because the bit
	about adding packages to Grip directly is currently postponed."

	"Once the EmdebianIntegration is complete, there will be a mechanism.
	Right now, sid-grip is a best-effort and is still playing catch up with
	a completely rewritten set of tools and wheezy-grip is not being
	updated until sid-grip is in a better state. These things take time."

	"Recommendation is to use Squeeze from www.emdebian.org/grip and
	complement that with the output of apt-grip to create your own local
	repository."

-- [Neil Williams, 30 Dec 2011](https://lists.debian.org/debian-embedded/2011/12/msg00004.html)

## Blog wisdom

	mkdir /media/grip/
	mount /dev/sdc1 /media/grip/
	sudo debootstrap lenny /media/grip/ http://www.emdebian.org/grip/
	cd /media/grip/
	mount -o bind /dev/ dev/
	mount -o bind /proc proc/
	chroot . /bin/bash
	aptitude update
	aptitude install linux-image-2.6.28-1-686 initramfs-tools
	aptitude install what-you-want
	aptitude install grub
	grub-install /dev/sdc
	update-grub
	exit
	umount dev/
	umount proc/
	cd ../
	umount grip/
	
	"Now you have a bootable EmDebian Grip install"
	
-- [Giovanni Toraldo, 20 March 2010](http://gionn.net/howto-install-emdebian-grip-deboostrap)

The [Codehelp blog](http://www.linux.codehelp.co.uk/serendipity/).

# My approach

First spend some time playing around with chroot installs of
several versions of Emdebian, then wrap up by forging ahead
with a wheezy based grip install.

## Cargo Culting

Now I have used the debootstrap tool before, and understand
the workings of chroot and the bind mounts used by Giovanni Toraldo.
Alas Debian's Lenny version is old, and recently security updates
for it have stopped. So I proceeded to give that method a try
using the current stable and supported Debian version squeeze.

I also saw things not work, and failed just like others before me.
The *debootstrap* method has bugs, and more recently people have been
having much better luck and put more effort into developing the
*multistrap* method.

The term "Cargo Cult" came up in discussion, and I entertained the
thought that next time someone asks what my religious affiliation is
I just might answer "Cargo Cult".

I have certainly just been doing some
[Cargo Cult Programming](http://en.wikipedia.org/wiki/Cargo_cult_programming).

However, I am not on a remote Pacific island. I have
lots of Internet resources and now have software running where I
can try things out and see what happens using experimental methods.
(Even back when I was on a remote Pacific island I was able to
obtain documentation and do some low-level programming to get my
computers working better.)

## Wheezy install

Despite the advice of the knowledgeable developers of emdebian
found on the web pages and mailing list posts I was not content
to install the known-good stable software.

I wanted to poke at things as they exist *today*, see what breaks,
and offer some current work-arounds that might just get folded
into the next release.

I figured I'd go with the multistrap install method rather
than try pre-seeding the Debian Installer since it seemed
that multistrap would end up with a smaller installation size.

Time to do some [Yak Shaving](http://theagileadvisors.com/the-agile-team/so-there-i-am-shaving-a-yak/).

# Install notes

It seemed like a good idea to fetch the emdebian archive keyring.

	aptitude install emdebian-archive-keyring multistrap emdebian-grip

Partition and mount embedded storage device. Mine showed up as /dev/sda
yours might very likely be different.

	fdisk /dev/sda
	mkfs.ext4 /dev/sda1
	mkdir /media/grip/
	mount /dev/sda1 /media/grip/

(If you don't run fdisk and instead just use the partitions left on
the device by an embedded Windows installation you may find when
you go to install grub it will fail because there is not enough
room between the start of the disk and the start of the first
partition for grub to store stuff.)

Multistrap: get pre-built gripped binary packages.

	wget http://www.emdebian.org/multistrap/examples/grip-wheezy.conf
	multistrap -d /media/grip -f grip-wheezy.conf

apt-grip: make your own gripped binary packages from standard
pre-built debian binary pockages. These are packages I wanted installed,
but multistrap could not find.

	TMPDIR=/var/tmp apt-grip --build-only -M http://ftp.us.debian.org/debian/ linux-image-3.2.0-3-486 kmod linux-base initramfs-tools klibc-utils cpio udev libkmod2 libuuid-perl libklibc libudev0 grub-common grub-pc grub-pc-bin grub2-common libdevmapper1.02.1 libfreetype6 libfuse2 gettext-base dmsetup libasprintf0c2
	cp /var/lib/apt-grip/output/* /media/grip/root/

Enter chroot:

	cd /media/grip/
	cp /etc/resolv.conf etc/
	cp /etc/hostname etc/
	echo /dev/sda1 / ext4 rw,relatime,user_xattr,barrier=1,data=ordered 0 0 > etc/mtab
	mount -o bind /dev/ dev/
	mount -o bind /proc proc/
	chroot . /bin/bash

I'm not sure it was necessary, but I created a tentative etc/mtab
in case that information was useful to initramfs-tools when installing
the kernel.

## Things done in the chroot

Set the root password in order to be able to log in after reboot.

	passwd

Also add a non-root user:

	adduser user

Install all the fresh-made embedded debs:

	cd /root
	dpkg -i *deb

Get some packages:

	apt-get update
	apt-get install grub-common grub-pc grub-pc-bin grub2-common
	apt-get install ssh isc-dhcp-client ifupdown
	apt-get install what-you-want

Keep an eye on remaining disk space.

Actually, grub might not install the first time, you
might need to fiddle with boot/grub/device.map
or at least examine what's in there to better drive
grub-install.

Exit chroot.

	exit

## Back outside the chroot

Edit the etc/fstab - I used

	blkid /dev/sda1

to some up with a UUID to use for the root partition.

Edit the grip etc/network/interfaces so that eth0 comes
up when booting.

	cat >> etc/network/interfaces
	
	auto eth0
	iface eth0 inet dhcp

Since I'm using the same hostname for the embedded
disk as I am for the laptop disk (after all, it is
the same motherboard, same ethernet MAC address) I
copy the ssh host keys:
	
    cp /etc/ssh/ssh_host* etc/ssh/ssh_host*
	
Reboot and reconfigure the BIOS to boot from the
Flash disk.

# Epilogue

Finally, on 19 August 2012, I have an Emdebian Wheezy
box that boots and runs with a 256 MB IDE flash drive.
df -Th gives me something along the lines of:

	Filesystem Type      Size  Used Avail Use% Mounted on
	/dev/sda1  ext4      241M  199M   30M  87% /

And I've already gotten updated packages from the
emdebian repository. Very nice to see progress.

TODO: see what filesystem tuning might help better
use the flash device, along the lines of
[Tips for running Linux on a flash device](http://www.cyrius.com/debian/nslu2/linux-on-flash.html)

To all who made this possible -
Thank you for all the great work you did!
The remaining work I did went quickly and easily because
you have done such a good job.

-Maitland

(If you've read this far... Comments?
Please trim your replies.)


Reply to: