2009-12-22

How-to build an independant Debian USB-stick.

(This is the first part of a (for me) funny story, the second part is mentioned in the end).

As I do not have the time or space for writing a nice article, I'll just start (again) to write down the steps, how I tried to build an independant bootable USB-stick with Debian for all platforms from i486 to amd64 (slow but true) - so this is a real work in progress that starts NOW and only the positives will be posted - so don't worry.

Start 09/12/22:
- Get a good stick (f.ex 2GB non-cheapo).
- Prepare an ext-system on it (fdisk and mkfs.ext2).
- Copy exactly this fresh filesystem via 'dd' to a local image on your regular system (backup, baby).
- Use 'qemu' for an emulated installationon the backup: 'qemu-system-i386 -m 512 -localtime -boot d -cpu 486 -std-vga -no-acpi -hdb usbstick.img -cdrom debian-503-i386-businesscard.iso'
- In expert mode, install a minimal system (even w/o the base-system[!]) - at the end as kernel select an -486-kernel for all platforms (link?).
- Fact: 482MB will be in use for this minimal system - but we could shrink it.
- Use qemu again to boot the system, log in and edit the grub-menu using 'vi' to shut down the ACPI-detection for all platforms: 'vi /boot/grub/menu.lst'
- On the 'kernel'-line append directly after the 'ro' the 'acpi=off noapic'.
- Log out and shut down regulary the emulated system.
- Now copy the .img-file back to the stick, again with 'dd'
- Try out the stick for real on the computer (or another one).
- If it stops while booting, try to switch within the grub menu-editor the root-device as detected: f.ex. this installation within qemu has been made using 'root=/dev/hdb' - in the real world, mainly 'root=/dev/sdb' or 'root=/dev/sdc' are common for USB-sticks (I do know that this is still strange, maybe someone else has a solution?).

It boots.
Now for the funny things:
- Reboot your system with your regular production system and fire up the USB-stick with qemu directly (just to get rid of the 'dd'-command to copy back and fro) like this: 'qemu-system-i386 -m 512 -localtime -cpu 486 -std-vga -no-acpi -hdb /dev/sdb' - qemu now should start its emulation from the stick using '/dev/sd?' (check dmesg) as boot device [2].

Good software:
- As a root login all the times does enerve, install 'sudo' and get rid of unnecessary country-encodings with 'localepurge': 'apt-get install sudo localepurge'
- To test your 'sudo'-installation after configuration try a 'more /var/log/dpkg.log'.
- Directly after the installation of 'localpurge' do a 'sudo localepurge' and watch those occupied MBs decreasing (~36MB less).

UPDATE 09/12/23:
A perfect moment for a backup:
- This is a moment to backup a full functioning system using 'dd' again, but do not forget to halt your 'qemu'-system before.

A X-System:
'xfce4' (Debian) should be ok - you could take 'fluxbox' if you like, but 'gnome' or 'kde' is a bit overdone, isn't it?
- To cite myself (which I do truly hate), try out the following for a small X-system: 'apt-get install --no-install-recommends xinit xserver-xorg-video-vesa xserver-xorg-input-synaptics xserver-xorg-input-kbd xserver-xorg-input-mouse xfonts-base xfce4' (~150MB). Instead of 'xfce4' you can use 'fluxbox' for an even smaller system (~105MB)[3]

UPDATE 09/12/24:
- 'apt-get install discover' for hardware detection. F.ex. needed for Ethernet-devices.[4]
- 'apt-get install wicd' from lenny backports as network-manager - I give it a try instead of the gnome-monster.

Upcoming whoes:
- Fit in multiple network device drivers(!)
- Tests with multiple UMTS-sticks

Stick-bootings tested:
- AMD-64 Toshiba Satellite
- ASUS eeePC 901 (Intel)

What's the point for this strange idea anyway?
I began this project for the German Pirate Party (Piratenpartei Deutschland) as an idea for a mobile communication center device, based upon pure open source and no idea which hardware is on avail. So for a free mixture of DHCP, DNS, load balancing, Transparent Proxy, squid, mb Privoxy, asoasf.

Why haven't you tried KNOPPIX or DSL (Damn Small Linux)?
I do appreciate both ideas as both are based on Debian Linux, but KNOPPIX uses unstable, testing and non-free sources - three ways against stable, in production or free digital systems. The package support for DSL is not as broad as needed - f.ex. missing Privoxy. So I started with a simple question: "Install Debian on USB" and landed for the first tests on flimzy's site [5] - a good start at least for a proval of problems using 'chroot', which I do not like for this kind of experiment, but also the 'moo'- and 'casper'-ways stopped me.

External stuff that helped me:
[2] http://qemu-forum.ipi.fi/viewtopic.php?f=3&t=4177
[3] http://gamlingen.blogspot.com/2009/03/personal-how-to-for-tiny-debian-lenny.html
[4] http://linuxmafia.com/faq/Debian/hardware-detection.html
[5] http://wiki.flimzy.com/index.php/Install_Debian_on_USB

ONGOING: At last I did manage do get a mobile connection after two months - read on in the second part ;-)

1 comments:

Andreas said...

So far everything works on the qemu and only the acpi is probably still on my knackers... But whats really hard currently is that grub is giving me head-aches is the GRUB when booting directly from the USB-Stick but about to find out. Thankstough for this nice intro!