Thursday, May 29, 2014

Porting a Preseed file to Debian 7

I script the installation of Linux of my personal computers and today it was time to start upgrading one of them from Debian 6 (Codename "squeeze") to Debian 7 (Codename "wheezy"). For this Debian has "preseed" available. So the first task was to change the preseed file i used for debian 6 to work with debian 7. When you change to a new version of a distribution it is not unreasonable to change some settings in such a configuration system. But as always, in practice it was more work than expected and also more than needed. And one reason is the lack of documentation.

 The preseed file contains  settings that are needed for the debconf system of the installer. In order to get an up-to-date version of the available settings, i did a manual installation. After the installation is finished, you can install the debconf-utils package. This contains some script to work with the debconf system.
If you run the command: debconf-get-selections --installer , you get a list of all available settings and their values. Unfortunately, the list is more than 600 lines, including comments. And it contains all setting, also the default ones and the ones you will never use. So selecting the ones you actually want to include in your preseed file is tricky.

The simple change was replacing:

d-i console-keymaps-at/keymap select us

with:

d-i keyboard-configuration/xkb-keymap select us 

But since i did not find a complete list of available settings and their meanings, it is an educated guess. But then the real problems begin.

During the manual install i encountered one problem, missing firmware for the network card. The debian repositories do not contain firmware that is "non-free", according to the very strict definition of the debian organisation. You get the option of loading this from some media, but if you ignore it and just continue, the networkcard works just fine. But doing this automatically in an unattended installation turned out to be a bit of a problem.  

To solve these kinds of problems, you could really benefit from proper documentation. And although i really like opensource software, that is lacking in a lot of situations. In the end you end up (almost) reverse engineering the system in order to determine what happens in what order. The advantage of opensource software is that you actually have the sourcecode, so you can see what is going on. But this takes a lot of time specially if you want to do something non-trivial. And looking for answers online does not help much either. If something is not documented online, it is not indexed by search-engines, so it will never end up in the search results. The only thing you can hope for is a hint in the right direction.

And i had one of these hints in this case.  Someone mentioned that you could add debconf parameters to the kernel that is loaded during the automatic install. The way the unattended install works is that you use pxeboot to download the installation kernel from a server. You need to setup a tftp server and based on the mac address of the machine you want to install and the tftp configuration, the machine gets a kernel and some parameters to start it with. One of them is the location of the preseed file that has to be used.

This was the line in the file i used for the squeeze installation:

     append vga=788 initrd=debian-installer/amd64/initrd.gz 
     auto=true 
     url=http://{hostname_of_webserver}/d-i/squeeze/preseed.cfg 
     priority=critical -- quiet   

I added the following setting (in bold):

     append vga=788 initrd=debian-installer/amd64/initrd.gz 
     auto=true 
     url=http://{hostname_of_webserver}/d-i/wheezy/preseed.cfg 
     hw-detect/load_firmware=false 
     priority=critical -- quiet   

(In the pxeboot config file it should be on one line, here i added newlines for readability)

Adding this line prevents an error that causes the installer to prompt for manual intervention. Since i could not find some document that contains a detailed description of the debian installer, i have to deduce it from the logging that is generated during the installation. All the output goes to the file: /var/log/installer/syslog If you read this file you still see that it detects the fact that it is  missing the fireware, but it will continue anyway. I tried adding the setting in the preseed file, but that did not work. Which can be explained off-course by the fact that you have to setup a network connection before you can download the preseed file. But this is speculation on my part, since i could not find exactly which programs runs during the installation in which order and what they exactly do and how you can configure that using preseed.  

The syslog file also gave the information i needed to solve the other problem with the preseed file, Language and Country selection. This also changed in the new version and i kept getting the selection dialogs, despite having settings in my preseed file. It turns out that there are a lot of "localechooser" settings available, but they are probably only used inside the dialogs. But it you look into the syslog file, you see that certain other values are set. And if you add these to the preseed file, everything works as expected.

When i was finished i closed most of the tabs in my browser. When searching for the solution for these type of problems you end up with dozens of sites that are related, but in the end not relevant to the problem. But one of them was http://www.debian.org/releases/squeeze/example-preseed.txt This is an example of a preseed file for the old version, one i used to create my version with. Feeling lucky, i decided to see the new version http://www.debian.org/releases/wheezy/example-preseed.txt And indeed, this had some of the changed setting and even some comments. Somehow this version had never come up in any of the search results.

Then i looked further and saw that another interesting document http://www.debian.org/releases/stable/amd64/index.html.en which is the installation manual. This one also did not end up on the top of the search results. But it contains an appendix about preseed, with some valuable information on how preseed is supposed to work. I should have read them first, specifically now that i know what the problem was, but it interesting to notice that these documents did not end up in the top of the search results. But still it would not have been enough to make porting the preseed file a simple task.