Building a custom Debian system, part 1

I wrote a few days ago about the advantages of building a Debian-based system from scratch. Now I’m going to explain how to do this. Remember that, while this isn’t the most complicated thing to do, it takes a fairly solid knowledge of how a Linux system is structured and how the apt package manager works, so if you’re just looking to try out another desktop environment then this isn’t for you. If you have a solid idea of exactly what you want in a Linux system, but you can’t find a distro that doesn’t need considerable hacking up to get it to work the way you want it to, then this may well be the right choice.

This is the first part of a three-part tutorial. It covers downloading, preparing, and booting the installation image. The next part will walk you through the installation process, and the final part will cover the range of customisation options available after installation.

Downloading an installation image

There are a few installation images to choose from depending on how you want to complete the installation, and finding the right one isn’t always easy, so let me explain it in a little more depth.

There are four main types of image that can be used:

  • Minimal installation image – this will allow you to boot a computer into the Debian installer, then complete the installation by downloading the packages from the internet. This is the simplest way if your computer has an internet connection and you’ve got a CD or a flash drive to spare.
  • Full installation image – this will allow you to boot a computer into the Debian installer, then install the required packages from additional CDs. This is not recommended unless you absolutely cannot download the packages at installation time, as it requires you to download and burn a lot of images. Note that I have not tried this method myself.
  • Network installation image – this will allow you to boot the target computer from a network boot server and complete the installation from the internet as with the “minimal installation” image. If you already have a boot server set up, like me, then this is by far the easiest method, but if not then setting up a boot server can be tricky and is not recommended unless you absolutely cannot use bootable media. Note that if you use the network installation image you will still need to have a keyboard and monitor attached to the target computer.
  • Live image – this will allow you to try Debian out before you install it, but if you’re building a custom system then it’s difficult to properly try it out beforehand and if you’re building a custom system then you hopefully don’t need to try out the live environment before you can decide if you want to install it. The live images do include the installer, but unless you have additional requirements I do not recommend using a live image.

Once you’ve decided what kind of image you want to use to install Debian, it’s time to go ahead and download it.

Download instructions for most images

For all images except network installation images follow the instructions below:

The main Debian download repository is located at http://cdimage.debian.org/debian-cd/. There you’ll see an index of the files in that directory on the server. If you want the latest stable version of Debian, choose “current”, otherwise choose the subdirectory for your desired version (as of the time of writing the only “other version” available is 8.2.0, which is in fact the latest version). If you do decide to use a live image, choose the directory with the “-live” suffix.

The next listing shows the available architectures. You’ll almost certainly want to choose “amd64”, or “i386” if you’re working with an old system which lacks a 64-bit processor, or if for some reason you want to use 32-bit Debian on a 64-bit processor. Some images are also available in “multi-arch” variants which are supposed to boot in 64-bit mode on a 64-bit processor, but can also boot in 32-bit mode on a 32-bit processor; I have not tried these. (Images are also available for a range of other less-common architectures such as ARM, however I don’t know how these work as I do not have experience with those architectures; consult the documentation for your platform for more information on booting and installing Linux images on those platforms.)

Now you’ll want to choose “iso-cd”, unless you’re using a DVD in which case you’ll want to choose “iso-dvd” (although apparently the CD images will work on a DVD). Note that although these images are in fact hybrid ISOs which will also boot from a flash drive or hard drive. If you’re getting a live image, the directory is labelled “iso-hybrid” instead – use this one.

Now you’ll see a list of .iso files. The one you want depends on what type of image you’re downloading:

  • For minimal installation images, choose “debian-<version>-<arch>-netinst.iso”. Note that despite the name these images are not network boot images; “netinst” refers to the fact that the installer downloads the packages from the internet rather than getting from CD.
  • For full installation images, choose “debian-<version>-<arch>-CD-1.iso”. Subsequent images containing additional packages will have the suffixes “-2”, “-3”, and so on. (If you’re downloading DVD images rather than CD images, the image filename will read “DVD” rather than “CD”.)
  • For live images, choose “debian-live-<version>-<arch>-standard.iso”. The other images include pre-installed desktop environments as per the suffix, however those are redundant if you’re going to install Debian as you will need to re-install the desktop environment anyway. Only choose these images if you need the desktop environment in the live environment.

(“<version>” is your chosen Debian version, and “<arch>” is your chosen architecture.)

Download instructions for network installation images

The network installation images are located in a different place, at http://ftp.nl.debian.org/debian/dists/. In the left-hand column, choose your desired version of Debian. If you want the latest stable version, choose “stable”. For the previous stable version, choose “oldstable”. For the stable version before that, choose “oldoldstable”. Otherwise choose a specific version either by version number (e.g. “Debian8.2”) or codename (e.g. “jessie”). Be careful not to choose anything with a suffix (e.g. “oldstable-backports”).

Then, again in the left-hand column, choose “main”. Now decide on your desired architecture (don’t click on anything yet). You’ll almost certainly want to choose “amd64”, or “i386” if you’re working with an old system which lacks a 64-bit processor, or if for some reason you want to use 32-bit Debian on a 64-bit processor. (Other less-common architectures, such as ARM, are also available, however I don’t know how those work as I do not have experience with those architectures; consult the documentation for your platform for more information on booting and installing Linux images on those platforms.) Once you’ve decided on an architecture, find the directory in the left-hand column which says “installer-<arch>”, where “<arch>” is the mnemonic for your desired architecture.

Then, continuing in the left-hand column, choose “current”. Note that this does not mean the current version of Debian; it means the latest subversion of your chosen version. Then choose “images”. Then “netboot”. Now choose “netboot.tar.gz” in the right-hand column.

Preparing the bootable media

Instructions for most images

Unless you’ve downloaded a network installation image, you should have a .iso file of some kind or another. These files can be burnt to CD (or DVD if you chose a DVD image), but they can also be written directly to a flash drive or hard drive (usually an external hard drive ;-) ). If you’re writing to a CD or DVD, use your favourite CD/DVD burning application to burn the image to disk. If you’re using a flash drive or hard drive, make sure to perform a raw write (such as using the “dd” command on a Linux system) – note particularly that this will destroy any existing partition table and bootloader on the drive.

Instructions for network installation images

If you downloaded a network installation image, you should have a tarball (.tar.gz file). Extract the tarball. Find the directory named “debian-installer” with a subdirectory named by your chosen architecture. Inside the subdirectory are the “linux” (kernel) and “initrd.gz” (initial ramdisk) files that you will need to put on your boot server.

The tarball also includes a few other files that are supposed to make it easy to set up a boot server, but the fact is that those files alone will not make the task of setting up a boot server any easier. But you’ll need to configure your server’s client bootloader (such as PXELINUX) to correctly boot the system. You could dig in all the extra files to find the correct parameters to add to your boot server’s bootloader, but I’ll just put them here:

kernel debian-installer/<arch>/linux
append vga=788 initrd=debian-installer/<arch>/initrd.gz --- quiet

As before, replace “<arch>” with the mnemonic for your chosen architecture. Of course if you’ve put the files in a different place relative your server’s root, then edit the lines as appropriate. If you’re using a bootloader other than PXELINUX, then perform the equivalent configuration for your bootloader.

Loading the installer

This couldn’t be any simpler. Insert your bootable CD or flash drive and turn the target computer on. If you’re network booting, make sure the target is configured to boot from the boot server. Depending on what image you’ve used and how it’s configured, you’ll see a variety of options once the bootloader has loaded. You should choose the option labelled “install”. If you’ve got a live image and you want to try out the live system, choose the “live” option – there might be more than one of these, so choose the most appropriate one for your system. Using the live system is beyond the scope of this tutorial, so come back when you’re ready to install and choose the “install” option. If you’re network booting, the correct option to choose will depend on the configuration of your boot server.

The installer will load. Once it has loaded, head over to part 2 of the tutorial to install the base system.

Advertisements

Leave a comment...

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s