Visit Jeremy's Blog.
Go Back > Blogs > Debian, This That and the Other
User Name


Over several years of using Linux distros (Debian happens to be my fave) and BSDs for my primary computing, I've picked up the odd piece of useful info.
Rate this Entry

Debootstrap Yourself, or "What is a good distro for my old computer?" (2)

Posted 12-01-2009 at 10:28 PM by ofaring
Updated 12-04-2009 at 10:53 AM by ofaring (Just a couple of minor changes.)

And why am I doing this instead of a normal install? Well, that involves a rain storm, an experiment, and an eBay purchase. The end result was not being able to boot from the CD-ROM. Since it's too old to boot from USB, and flashy new Linux kernels have forsaken floppy installs, my options narrowed considerably. During the course of my research I stumbled across "debootstrap", and the rest is written below.

This entry is the continuation of this post.

An obvious note: # = root, % = regular user.

These instructions are very sparse. They are literal terminal commands. In order to get more info, you'll have to read. And since we all keep spare room on our hard drives for just such emergencies...

BE CAREFUL. You will destroy your system if you randomly delete partitions. If you already have a running system installed, I recommend doing thorough backups of any vital information before continuing. Also, if you don't have any free space available, I would recommend that you do a clean install with your *nix of choice and leave the necessary space during the install process. Just remember: with standard PC systems you are allowed a maximum of four (4) primary partitions, and an "extended" partition is counted as one of these. Also, different operating systems have differing requirements for installation. Read their docs. But, if you are using a Linux distro, chances are that you can make an extended partition during install, leave sufficient space in it, and partition your little heart out. Read up on it. Or experiment, run in little circles in a panic, read, and then experiment again. That's how I started.

There are other methods of freeing space, but I'm not going to get into them.

# cfdisk /dev/hda
(Navigates to unused space on my drive...)
	New --> 1024MB --> beginning --> hda5
	New --> 4096MB --> beginning --> hda6
	New --> 4096MB --> beginning --> hda7
# Reboot.
Personally, I create "/" (root), "/var", and "/usr" partitions. (Have you made those backups? Are you being careful? Run "df -h" to see which partitions are currently being used, but your swap partition will not show in this list. "fdisk -l" will show you all partitions, but not the ones currently being used.)

mkfs -t ext3 /dev/hda5
mkfs -t xfs /dev/hda6
mkfs -t xfs /dev/hda7
If you have to use the -f option while creating an XFS filesystem (You're not destroying relevant data...?), the correct syntax is:
# mkfs -t xfs -f /dev/hda6
Let's hook it up.

# mount -v /dev/hda5 /mnt (This will be root)
# mkdir -v /mnt/var /mnt/usr
# mount -v /dev/hda6 /mnt/var; mount -v /dev/hda7 /mnt/usr
Now ensure that debootstrap is installed on your system:
% dpkg -l | grep bootstrap
Not there?
# apt-get install debootstrap
Or get the source here.

All systems are go. Read the relevant section and change the following command as befits your system.
# /usr/sbin/debootstrap --arch i386 lenny /mnt
Sick! You've now got a truly minimal Debian system. So minimal, in fact, that it's not useful right now. Let's amend that.
# mount --bind /dev /mnt/dev
# cp -av /etc/fstab /mnt/etc
Edit, making certain to change the location of /, /usr, and /var. And now...
# cp -av /etc/network/interfaces /mnt/etc/network/
# cp -av /etc/resolv.conf /mnt/etc
# cp -av /etc/hosts /mnt/etc
# cp -av /etc/apt/sources.list /mnt/etc/apt
Edit, if you have changed your Debian release.
# cp -av /etc/kernel-img.conf /mnt/etc
Edit as necessary. For instance, I'm removing unnecessary sources from the new "sources.list" because I'm setting up a testbed install. I'm also commenting out references to updating GRUB in "kernel-img.conf". (See further below.) With the references to networking, if you're handicapped by Network Manager or some other such GUI, guess what. You'll have to brush up on your networking skills, unless you just want to get back to using your slow system. (In that case, feel free to follow these instructions and then install 500,000 pieces of software, half of them running at bootup.) As an aside, make sure that your "/etc/hosts" is set up correctly. This is vital for overall OS speed and trivial matters like printing. Check this. Here is what mine looks like, and it's good to go.
Code:       localhost your

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
Now it's time to hop into a chroot. Note. Every command from this point on is meant to be used in your chroot.
# LANG=C chroot /mnt /bin/bash
# export TERM=xterm-color
Because I'm an addict I uncomment two options in ".bashrc".
# nano ~/.bashrc
export LS_OPTIONS='--color=auto'
alias ls='ls $LS_OPTIONS'
# source ~/.bashrc
Excccellenttt. And another personal preference (You are in the chroot, right?)
# mv -v /opt /usr/
# ln -vs /usr/opt /opt
Wanna double check what you've just done?
# ls -l /

# mount -vt proc proc /proc
(Yes, mount the proc partition manually.)
# mount -a 
(The manual recommends this, however, unless you have other partitions than the ones we mounted manually, which you now wish to mount, this is pointless.
You may also want to do this:
# cd /media
# mkdir -v cdrom0 floppy0
# ln -vs cdrom0 cdrom && ln -vs floppy0 floppy
Now, depending on whether you use Coordinated Universal Time (UTC) or not, check "/etc/default/rcS" to ensure that it is setup correctly (If your other operating system is Windows, make sure this is set to: "UTC=no". Use a Mac? Use UTC.), and then:
# dpkg-reconfigure tzdata
# apt-get update
# apt-get dist-upgrade
If you have a flaky connection and there are connection errors during the update process, and you know that your sources.list uses reliable servers, try running the command more than once. One thing. Even if you see it crapping out, let apt finish the run each time. Let's say that two servers didn't connect for whatever reason. On the next run apt connects to one, but the other doesn't connect. Apt uses the results of the successful connection, presuming that you let it finish, and next time you will (usually) only have to download changes from the single remaining site.

# apt-get install locales
# dpkg-reconfigure locales
In Debian it is usually recommended that you choose UTF-8 locales. E.G., I personally use: "en_CA.UTF-8 UTF-8".
# apt-get install console-data console-common console-tools kbd-compat
I do this because I prefer "console-tools" to "kbd". When dpkg configures "console-data" during the install, depending on your hardware, you might answer like this: Select keymap from arch list --> qwerty --> US american --> Standard. And at this point I like to run:
# dpkg-reconfigure -a
Which will allow you to set basic system preferences. (This will take ~5 minutes on old hardware. Longer if you have more installed.)
# apt-cache search linux-image
Or just:
# apt-get install linux-image-2.6-686
This will install the latest -686 kernel update specific to your Debian version. Or install whichever kernel you happen to want or need. Because I have an existing bootloader (GRUB) which I don't need to mess with, I'm not installing GRUB or LILO. Instead I'll update the existing /boot/grub/menu.lst in my working Debian system to give me the option of booting my new system. That entry (tailored to my laptop) looks like this:



##      This is a divider
title           Other Systems

title           Debian GNU/Linux, Lenny test system
root            (hd0,4)
kernel          /vmlinuz root=/dev/hda5 ro vga=771 acpi=off 
initrd          /initrd.img

title           Debian GNU/Linux, Lenny test system (single-user mode)
root            (hd0,4)
kernel          /vmlinuz root=/dev/hda5 ro vga=771 acpi=off 
initrd          /initrd.img
"Well, all this is great, and stuff, man. But I don't even have "less" installed (which really is more)." Yes, it's true. Type "dpkg -l" and watch that minimal list barely take more than a screen. It's time for tasksel. After this you will have a nice, clean system with minimal software which you can then further customise.

# tasksel install standard
# tasksel install laptop
Don't worry about the X11 warning on the laptop install. We haven't even installed xorg yet.

And finally, the most important real-world steps:
# passwd
# adduser
There you have it. A bona-fide, lean, mean operating system. This is the foundation of what I am running right now, with a few additions obviously. And about those additions, like the marvelous Fluxbox (not the Debian version), well, that'll be a story for another time.
Posted in Examples, Tome
Views 3489 Comments 1
« Prev     Main     Next »
Total Comments 1


  1. Old Comment
    Yeah. It's a beast of a post.
    Posted 12-01-2009 at 10:31 PM by ofaring ofaring is offline


All times are GMT -5. The time now is 11:35 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration