Lenny on a Stick: Portable Linux
Install Debian Lenny to a USB flash drive, thumb drive, stick, pendrive, USB key.
Installing the Latest Daily Build of Debian Lenny on a Stick
In the this article I will describe the installation of Debian Lenny to a 2 gig stick. I located the latest daily build, which was the Dec. 12, 2008 Netinst, installed it to another 2-gig USB stick, then added a bunch of stuff. I found that:
- The Lenny/Sid installer worked well
- Lenny RC1 is inexplicably slow at times, compared to Etch and Etchnhalf
- Manually adding just the right packages is still a somewhat confusing matter
I’ll write less about the installation, and more about adding things. I installed a lot more packages in this one and ended up at about 1.4 gigs on the stick, with full audio, media, automounting, printing, and pretty much all the system utilities. Lenny finally comes with Iceweasel 3, but it still doesn’t install ntfs-3g. It offered me nvidia kernel modules, but it didn't work right, and I still had to install the kernel headers and run the proprietary nvidia driver-builder and let it build the module.
Disclaimer: The installation instructions described in these articles are to be considered experimental. They may or may not work for you, nor turn out as described or expected. The author bears no liability for your actions or any direct or indirect consequences thereof. If you are not experienced in partitioning drives and installing operating systems, you should not do so.
What’s Netinst?
Debian Netinst is a 150-or-so meg ISO that you can boot to start a Debian installation. It will install a nearly complete text-console-based Gnu/Linux system, which you can use as is, or better, add selected packages to it for a fully customized system.
What’s Lenny?
Debian Lenny is the latest version of Debian, called “testing,” but now frozen and released as Release Candidate 1 (RC1). It uses the Lenny installer. As of this writing (Dec 2008), the kernel is 2.6.26-1, and I used the -686 architecture.
The Installation
Get the latest daily build, then select today’s date, select your arch (i386 or amd64), then select iso-cd/, then locate and download something like debian-testing-i386-netinst.iso.
Burn the iso to a CD or DVD. Note: You can’t just copy the iso to a CD, you have to burn it in disk-at-once (DAO) mode. Look in your burner software for an option such as “Burn Image.”
Note: If you’re not experienced in this type of thing, it might be a good idea to unplug your hard drive and any other sticks you might have plugged in. The installer will identify your target stick by manufacturer’s name, as reported by probing the stick.
Before booting the installer, you might want to select and print the rest of this article.
Now boot it. At the Boot Menu, this time I decided to try to regular install, not expert, so I just hit Enter on the default “Install” option on the installer’s main menu. This was lot faster than using expert mode, since one does not have to select every menu item manually.
It asked the usual language and keyboard questions, and all the defaults were fine. It then probed for a DHCP server, which I do not have, and I promptly put in my IP numbers without any problems. In fact, I put in the first number and the installer correctly guessed the rest.
Partitioning: This time I decided to use the “Guided - Use Entire Disk” (not Manual) partitioning option. It probed drives and then offered the hard drive (hda) and the Kingston stick (sda). Choosing the stick, it promptly made an ext3 partition (about 1700 megs), and a small swap partition (about 150 megs). Write down the drive designator the installer is using (something like sda1), because you’ll need that after a while to tell it where to install the Grub bootloader.
Near the end of the install, it’ll recommend installing Grub to the hard drive, but since this is a stick and we want it portable, make it install Grub to the stick (same ext3 partition as it created and formatted). Be careful! Don’t blame anyone else if you wipe out a hard drive or overwrite your existing Grub.
The installer still insisted upon making a 150 meg swap. Later, I loaded up about 6 big applications and it still wasn’t using but about half of my 1.5 gigs of ram, so I booted another Linux and used GParted to resize the swap down to 24 megs, and increased the ext3 by 133 megs. So, if you have about 512 megs or less, keep the swap. Note that using suspend/resume requires you have a swap at least as large as your ram—having a swap that size isn’t practical on a 2-gig stick, so forget suspend/resume (and why would anyone want to suspend to a stick?)
The partition confirmation screen still gives the confusing:
The partition tables of the following devices are changed: IDE Master (hda) <--NO IT ISN’T! SCSI1 (0,0,0) (sda) <-- yes, that’s what I changed.
Why the installer drags a partition that one didn’t touch into the confirmation screen is an ongoing mystery. Anyway, Write it? Yes.
It then installed the core for about 45 minutes (slow stick writing), asking to pick a kernel (only one offered this time), root password, and new regular user. Then it asks for software selection. I chose [*] Standard only, since anything else would overrun the stick. It then grabbed 91 files from online and spent about 30 minutes installing them.
Install Grub: As before, it forgot what drive/partition it was installing to, and recommended I install to the first hard drive. I suppose that if I had unplugged the hard drive before booting the CD it wouldn’t do that, but still, it should default to install Grub to the target media, with other drives as options, not defaults.
Install GRUB to Master Boot Record of the first hard drive? NO! /dev/sda1
Now it finishes up, ejects, and boots. Catch the BIOS setup, change the first drive to USB-HDD, save and reboot. The stick should boot Grub, and Grub should boot the new Debian. Once again as before, BIOS-booting the stick gives it a different drive designator (hd0,0), while the installer set Grub (in menu.lst) to boot to (hd1,0). Hit e e and change the hd, then hit b to boot. Once located, don’t be surprised it just sits there blank for 2-3 minutes. Remember that most BIOSes will load the two boot files at low speed. Also remember to edit it’s menu.lst file after you get it booted.
Other than the couple of noted points, the install was very smooth and intuitive. Using the regular, non-expert install, it doesn’t ask questions about which installer modules to load, or how to configure udev, but it all worked out fine.
Initial Console Additions and Clean-up
lenny:~#_ # apt-get install localepurge mc gpm lynx # apt-get clean # df 473 used, 1214 free # aptitude
Now in aptitude, we know to search for and delete some fluff. Hit / to search, and Sh- (shift minus) to mark for removal. When searching runs out of the Installed section and into the Not Installed section, it’s pointless to keep searching, so hit Ctrl-Home to go to the top and then start a new search. Don’t delete anything with dependencies, unless you know they should be deleted also. Here’s what I deleted:
selinux-policy-default python-selinux libselinux1 -- WOOPS! Too many deps! Sh+ (un-mark it) policycoreutils doc-debain doc-linux-text python-semanage debian-faq ed vim-tiny vim-common ibritish (or whichever spelling dictionary(ies) you don’t need) g To be removed: (review it) g (do it) Ctrl-T (Menu, Actions) Clean package Cache Ctrl-T Clean Obsolete q (quit) Yes # df 373 used, 1315 free. That’s better! 100 more megs.
Now, before we start installing, let’s fix our package sources. Run mc and navigate to /etc/apt/ and edit sources.list, adding contrib and non-free to two lines:
…lenny main contrib non-free
Save and exit, then update your package databases:
# apt-get update # apt-get upgrade
Now let’s fix Grub: Navigate to /boot/grub/ and edit menu.lst, changing the root drive to the one you used to make it boot, probably (hd0,0). Save and exit.
Adding Useful Stuff
Compiler (optional)
If you know will want to compile software from sources, install these:
# apt-get install build-essential checkinstall apt-file 62.7 megs? Yes or No? Yes. (cruch-crunch…) # apt-get clean # df 428 used, 1259 free
Note that checkinstall has replaced make install, so now when you compile, it’ll now be like:
./configure make checkinstall
The new checkinstall does a make install, then it makes a package of it, so you can later manage it with any of the package managers. This allows you to uninstall it, or reinstall it without compiling it again. The compiled package should be your sources directory.
Installing Gnome
Now is where it get’s tricky. Only with experience and research will one learn which packages pull in which other packages, and some pull in way too much for a 2-gig stick, so we have to go about this with some planning. Each package may have depends, recommends, and suggests. The depends are mandatory for the package; the recommends are just that, but unless instructed otherwise, the package manager will treat them as depends; and the suggests are not installed with the package unless you specifically do so. This interdependency creates a massive web, such that one package might pull in dozens or hundreds of others. For example:
- gnome pulls in 1598 megs—way too much!
- gnome-desktop-environment pulls in 1128 megs—still too much!
- gnome-core pulls in 524 megs—that’s the one we want.
Run aptitude and hit Ctrl-T (menu), Options, Preferences, un-check “Install Recommended Packages Automatically”. Now, if we select gnome-core, it’s 348 megs, not 524, because it isn’t grabbing all the recommends.
search (/) for and select (Sh+) these:
These I consider pretty much essential: xorg autofs5 Kernel-level auto-mounter ntfs-3g Windows drive support gnome-core Gnome Core files gnome-common Common scripts and macros gnome-commander Dual-pane file manager gnome-backgrounds A few pretty pix gnome-network-admin Helps with networking gnome-netstatus-applet That blinking network icon gnome-menus gnome-mount Helps mount drives gnome-app-install A friendlier software installer gnome-themes Clearlooks, Industrial, etc. gnome-system-tools Configuration utilities gnome-utils Dictionary and other handy stuff gnome-volume-manager Helps dbus auto-mount things desktop-base More useful stuff update-manager Notifies of available updates alacarte Menu editor file-roller Multi-archive handler gksu Run some programs as root gtkorphan Find and remove orphaned libs synaptic Package manager These are optional or substituted by your preferences: brasero CD/DVD burner gcalctool Calculator gnome-system-monitor Watch your processor and drives gparted Partition editor msttcorefonts Arial, Times New Roman, etc. evolution Email and scheduler/calender evince PS/PDF viewer iceweasel Firefox rebrand, now v.3. iceweasel-gnome-support transmission Bittorrent client For audio: alsa-base Advanced Linux Sound Arcitecture alsa-utils alsa-oss gnome-alsa-mixer gnome-audio discover Hardware identification system For printing: cups Common unix printing system (Also gets Samba) foomatic-gui Makes controlling printer easier hplip Supports most non-PCL HP printers sane If you have a scanner
Note that my list is not perfect, may not be what you need, may not be in the right order, and that if you did this type of install 100 times, you’d never do it quite the same way twice. You'll have to figure out what video and audio drivers to install, if those don’t work. Also, look for other packages you might need to talk Internet phone, chat, instant messaging, support camera or web-cam, etc.
The above list ran the stick up to about 1400 megs, with 300 free. If you have lots of ram, you can now boot into another linux and run gparted and shrink your swap and grow your ext3 partition, recovering 130 megs or so.
What’s Next
I want to get a couple hi-speed 8-gig sticks (probably Corsair Voyager GT) but I’ll wait until these wacky prices settle down. Then try some full (everything) Ubuntu installs.
Enjoy!
—kv5r

