Etchnhalf on a Stick: Portable Linux

Install Debian Etchnhalf GNU/Linux on a USB flash drive, thumb drive, stick, pendrive, key, or whatchamacallit.

What’sit?

In the former article, I described installing Debian Etch Netinst on a 2-gig stick. In this article I will describe the installation of Debian Etchnhalf to a 2 gig stick. Note that it is somewhat difficult to keep exact notes while running an installation (one must backport to ink and paper). However, I’ll try to do better than the last time ;-). This version is a little more detailed in the install.

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 like that, or better, add selected packages to it for a fully customized system.

What’s Etchnhalf?

Debian Etchnhalf is a Debian release that sort of sits between Stable and Testing. Etchnhalf also uses a patched Lenny installer, instead of the Etch installer. Before deciding to install the “stable” Etch Netinst, or the Etchnhalf Netinst, see this Debian article. As of this writing (Dec 2008), the Etch kernel is 2.6.18, while the Etchnhalf kernel is 2.6.24. By contrast, the Ubuntu folks are running 2.6.27.9—they do things a little faster than the more conservative folks at Debian. Either way, if you have auto updates installed, your system will be wanting you to grab the latest kernel as it appears, whenever it’s gurus think it’s ready for prime-time.

Git’um!

Go there, select your arch (i386 or amd64), then select iso-cd/, then locate and download the etchnhalf-yourarch-netinst iso, which will be about 150-165 megs. If you don’t want to try etchnhalf, scroll down and look for the regular (non-etchnhalf) netinst iso, or if you want to install the latest daily build of Testing, see the next article in this series.

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.” I always use a DVD-RW for these experiments: I save the various ISOs on hard drive, then burn the one I currently need, using the same disk over and over. Why DVD for a 150 meg ISO? It’s a lot faster than a CD! It’ll burn at 5 megs/sec and read a whole lot faster than that.

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, such as SanDisk Cruzer or Kingston Data Traveller, so disconnecting everything else isn’t really necessary unless you’re a bit paranoid. Still, don’t say I didn’t warn you!

Do not rush through the installer! Read carefully and consider your actions.

Before booting the installer, you might wanna select and print the rest of this article.

Now boot it. At the Boot Menu, select Advanced Options, then Expert install.

Go through the installer, deselecting all the modules you know you don’t need. Unless your stick is 4 gigs or more, do not select any other meta-packages such as KDE or Gnome (the full-blown meta-packages won’t fit on a 2-gig stick).

Partitioning: Select your stick (be careful!) as the drive to partition. Select the “all in one” automatic partition. It’ll make 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 sdb), 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 device as it partitioned and formatted above). Be careful! Don’t blame anyone else if you wipe out a hard drive or overwrite your existing Grub.

Reboot, 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. Well, now that you are booting the stick, it isn’t the same Grub hd# as it was during the install, so you have to drop to the Grub command line and use tab-completion to locate what Grub now thinks is your stick. Once located, don’t be surprised it just sits there for 2-3 minutes. Remember that most BIOSes will load the two boot files at low speed.

Now I have to actually start the install and keep notes on paper. Here we go! See you after a while.

Three hours later…

We’re back! Now running from the USB stick, editing this file in Midnight Commander’s internal editor.

Here’s what happened in the meantime. Paper/ink notes:

Debian Etchnhalf Netinst, to Kingston DataTraveller 2.0:

Boot installer CD at 6:46 AM.

Boot menu: Advanced Options, Expert install.

Language: English, US. Locale: en_US. Other locales: (none)

Keyboard: PC-105. Map: American English.

Detect and mount CD-ROM. Yep. PC Card: Nope.

Load Installer Components: cfdisk-udeb, choose-mirror, console-setup-udeb, parted-udeb, (ppp if you need it, speakup if you need it, wireless if you need it); leave things you don’t need unselected.

Config the Keyboard: Generic 105 USA. My AltGr: Left Logo. My Compose: Right Logo (YMMV). Console: Latin-1 and 5. Console font: TerminusBoldVGA, 16. Virtual Consoles: /dev/tty[1-6] (the default).

Detect Network Hardware: Start PC Card Services? Nope.

Configure the Network: Auto-config? No. (I don’t use a DHCP server, select Yes if you do, and most people do, it’s hiding in your router, unless you deliberately disabled it.).

Manual: IP address: 192.168.x.x (replace x with your numbers)
Netmask: 255.255.255.0 (the typical class-c lan)
Gateway: 192.168.x.x (my ADSL modem/router)
Nameserver (ditto).
Correct? Yep.

Hostname: debra. Domain name: (blank). Mirror: HTTP, United States, mirror.anl.gov (I have found Argonne National Laboratory to be very snappy).

Config the clock: Use NTP? Yes. NTP Server: (default). Time zone: Central.

Detect Disks: PC Card? Nope.

Partition Disks? Manual. Select: SCSI1 (0,0,0) sda 2.0 Kingston DataTraveller 2.0 (YMMV).

Since I used mine in previous tests, and deleted it’s partitions afterward, it shows Free Space. If your stick is new or default, it’ll show a FAT partition. You’ll want it ext3.

Select the free (or FAT) partition with Enter.

Automatically partition the free space.

Partitioning Scheme: All in one…

Now, back at the Partition Disks screen, look and MAKE SURE it doesn’t wanna format anything else!

SCSI1 (0,0,0) sda Kingston DataTraveller 2.0
#1 primary 1.9 GB   B     f    ext3  /
#2 logical 148 MB   -     f    swap  swap
   ( type   size   boot  fmt    fs   mount )

Yep, that looks right. Watch out for those “f” flags, that means “format!” Remember, sda1 (or whatever it is) will be needed later to install Grub, so write it down, such as /dev/sda. You could put it in the stick’s MBR with /dev/sda (or whatever it is, without the number), but I’d rather put it in the partition so if I delete it later, Grub stage 1’ll be gone, too.

Finish.

Review: “The following partitions are going to be formatted:”

“The partition tables of the following devices are changed: IDE Master (hda)”

No, it isn’t! I didn’t change anything about hda! Another installer annoyance. But it never hurts to go back and check.

Write it.

Install the Base System: Takes a while, with this slow USB stick writing speed. Wait about 45 minutes.

7:55: Finally!

Choose kernel: Ok, I choose Linux-image-2.6.24-etchnhalf.1-686 (the freshest one listed).

Configuring udev: Generic if you wanna roam, targeted if you don’t. I don’t, so I choose targeted.

8:05: Done installing base.

Set up users and passwords: Enable shadow? Nope.
Allow login as root? Yep.
Root password:*******.
Create a normal user account now? Yep.
Full Name: Debra.
Username: debra.
Password:*******.

Configure the package manager: Scan another CD? No (not unless you happen to have the full repository on a DVD or something like that).
Use a network mirror? Yes (didn’t we do this already?)
Protocol: HTTP. United States. mirror.anl.gov. It remembered that one.
Use non-free software? Yes.
Please wait… (long wait)

Services to use: [*] security, [*] volatile.

Select and install software: Participate in user survey? No. So it installs it anyway (another annoyance). I don’t mind the user survey, but this is a stick experiment, not a real installation that I will be using day-to-day.

Choose software to install: [*] standard system (only: we’ll be installing other stuff later, from within the new system).

I thought the whole base system was on the CD, but here it goes again, downloading and configuring. What’s this? SELinux Policy? SELinux should be optional! More stuff to delete later…

8:40: ET: 2 hours.

Install GRUB…: Install GRUB 2.0? Yes. What!? Red screen! FAILED! Continue. (Another little confusement here: no <Go Back> option, but it does anyway).

Install GRUB…: 2 instead of legacy? No (let’s do legacy this time). Installing… Preparing…

Install to Master Boot Record? No. Device for boot loader installation: /dev/sda1 (you did write it down earlier, didn’t you?)

Grub password: None.

Finish the Installation: Is the system clock UTC? No. Ejecting CD-ROM. Remove it. Continue. Reboot. Press Delete (or whatever) repeatedly to catch BIOS setup. Choose first boot device: USB-HDD. Save, yes, reboot.

At this point, expect Grub to fail because now the stick is the first boot device, not what is was during the install.

Grub: Error 17: Cannot mount… No surprise there. Any key.

e e -- Backspace to (hd, and press Tab. Possible disks are hd0 hd1. Since we just told the BIOS to boot this first, it should be hd0,0. (hd Tab comma Tab: Possible partitions are: 0: ex2fs 0x83, 4: unknown 0x82 (which means a Linux swap). Yep, that looks like it. (hd0,0) b (boot) and away it goes. Now it’s waiting 3 minutes (loading at 1.0 speed), then booting the kernel. FAIL!? Rebooting. Grub e e (hd0,0) b. Long wait. There is goes again. Ah, this time it booted right to the login prompt. Login: Root, *******.

debra:~#_

Ah, what a nice sight! A brand new li’l Deb is born (birth weight: 4 grams).

Ok! Now let’s see what it has:

mc - nope

lynx - nope

aptitude - yep! q (exit).

Now let’s get some essentials:

apt-get install mc gpm lynx localepurge

There is goes. Configure localepurge to your desired locale(s). In my case, [en] and [en_US].

What we now have: A full-featured text-console Gnu/Linux system with a file manager, mouse, email, web browser, aptitude, and etc. From here you can go many different ways:

At this point it’s text-based, and what one does with it is a matter of curiosity, skill, science, and innovation. Don’t be so quick to install the graphical desktop! A barebones Linux system is the foundation for hobbies, education, and research. Do something really cool and get the kids involved. Computers were never meant to be just entertainment devices.

Cleaning Up

df shows 495 used and 1193 free megs.

Let’s get rid of some fluff:

apt-get clean removes the package archives for stuff already installed.

df now shows 418 used and 1270 free.

Start aptitude and choose Options, Dependency Handling and un-check “Install Recommended packages automatically.” That’ll save a bunch of space later on. On this slim install, we want the dependent packages, but not the recommended packages.

In aptitude, search (hit / key) and remove selinux-policy-refpolicy-targeted, python-selinux, policycoreutils and that’ll free up 21 megs. Ha! I just did that in aptitude, and that followed by localepurge freed up another 45 megs!

There’s a ton of docs in /user/share/doc, you should probably keep. However, you may have these on another drive, or a CD, and they are all available somewhere online, so those can be blown out without hurting anything. Be sure to keep info and man pages, you always need those.

du -h | less will show you where the fat is, and most of it’ll be in /usr and /var.

Installing NTFS Support

Debian, by default, will mount ntfs (Windows) filesystem only in read-only mode. To be able to write to an ntfs partition, you need ntfs-3g. To install ntfs-3g,

(Update: ntfs-3g is now in the lenny repository, so if that’s in your sources.list, you can install it like any other package and not do the stuff below.)

Install these two dependencies: apt-get install fuse-utils libfuse2

wget these two files:

wget http://snapshot.debian.net/archive/2007/03/01/debian/pool/main/n/ntfs-3g/libntfs-3g0_0.0.0+20061031-6_i386.deb
wget http://snapshot.debian.net/archive/2007/03/01/debian/pool/main/n/ntfs-3g/ntfs-3g_0.0.0+20061031-6_i386.deb

Now install the two downloaded files:

dpkg -i libntfs-3g0_0.0.0+20061031-6_i386.deb
dpkg -i ntfs-3g_0.0.0+20061031-6_i386.deb

To add a Windows ntfs to fstab, edit /etc/fstab and add something like:

/dev/hda1 /media/Windows ntfs-3g defaults,force 0 0

…and don’t forget to make a mount folder: mkdir /media/Windows

mount -a will make it re-read fstab, and if any mount errors, you’ll see them.

df now shows 336 used and 1352 free!

Well, there you have it. Linux on a stick! In the next article, we’ll focus more on adding a graphical desktop and some nice applications.

Enjoy.

—kv5r

What’s Next?

Why stop here? Let’s get today’s Daily Build and try that.
Please see Lenny on a Stick

— KV5R is disabled. Please help. —

Valid HTML 5 Valid CSS WCAG 1 conformance Handmade with Ultra Edit Studio Xara Xtreme