Installing Debian remotely using the network console

The ?DebianInstallerNetworkConsole is really neat. It allows you to do some really cool stuff- like a completely remote full installation of Debian. These instructions detail how to do that.

Notes about this process

These instructions are not for the weak of heart. You'll need to be able to build and configure stuff for yourself. But they're a good dive into hacking the debian installer to do kinky stuff.

The target system is assumed to be running another version of linux (any one will, hopefully, do, as long as they're using a regular bootloader like lilo or grub (both tested)).

Why?

Because I can :)

Seriously, I wanted access to some of the new features of sarge, such as LVM on software RAID as root. This is quite easy to do if you use the installer, but a screaming nightmare otherwise. It really is easier to do it this way than to try and debootstrap something.

Cheesy disclaimer

I tried this only on i386 machines, running various versions of RedHat Enterprise Linux (at the start :). I spent about 2 days on and off figuring this little sequence out. YMMV.

So let's roll

1. Grab the debian installer source:

        apt-get source debian-installer

2. Get the build deps:

        apt-get build-dep debian-installer

3. Modify the build/pkg-lists/netboot/i386.cfg file, add to the top:

        #include "network-console"

4. Create a simple preseed file, with at least the following, and copy it to the /tmp directory:

 d-i netcfg/choose_interface            select eth0
 d-i netcfg/disable_dhcp                boolean true
 d-i netcfg/get_nameservers             string 192.168.2.3
 d-i netcfg/get_ipaddress               string 192.168.2.25
 d-i netcfg/get_netmask                 string 255.255.255.0
 d-i netcfg/get_gateway                 string 192.168.2.1
 d-i netcfg/confirm_static              boolean true
 d-i netcfg/get_hostname                string myserver
 d-i netcfg/get_domain                  string myhome.none
 d-i debian-installer/network-console/password password password
 d-i debian-installer/network-console/password-again password password

Note that you'll need the patch to bug [http://bugs.debian.org/315030 315030] to get the nameservers to work- if not, you'll have to ssh to the shell to fix your resolv.conf. A more serious problem might be if your gateway is not on a .1 ip address, see bug [http://bugs.debian.org/314618 314618]

5. Modify the build/config/local file, add:

        EXTRA_FILES=''tmp''<mypreseed.cfg>

6. Modify the file build/pkg-lists/netboot/common, replace network-preseed with file-preseed. Note that with the sid version of the installer, there may be new mechanisms which allow for easier feeding of this information.

7. Build your netboot image:

        fakeroot make rebuild_netboot_2.6

8. Deploy your image to the target linux box. In the build/tmp/netboot_2.6/ directory, there's a vmlinuz and initrd.gz. Copy these files to your target box. Rename vmlinuz to debian-installer, the initrd.gz to debian-installer-rd.gz, and move them to the boot directory.

9. Modify your target box's bootloader config to add in the debian installer image.

Note that in the samples below, the append= or kernel lines should be one line. I've broken them up for readability sake. (remove the \)

For recent grub versions I used this:

 title debian installer
        root (hd0,0)
        kernel /debian-installer DEBCONF_PRIORITY=critical rw ramdisk_size=24000 root=/dev/rd/0 \
 languagechooser/language-name=English countrychooser/shortlist=US console-keymaps-at/keymap=us preseed/file=''tmp''<mypreseed.cfg>
        initrd /debian-installer-rd.gz

For lilo:

 image=/boot/debian-installer
        label=debinst
        read-write
        ramdisk=24000
        initrd=/boot/debian-installer-rd.gz
        append="root=/dev/rd/0 DEBCONF_PRIORITY=critical \
 languagechooser/language-name=English countrychooser/shortlist=US console-keymaps-at/keymap=us preseed/file=''tmp''<mypreseed.cfg>"

(Note the root= is missing in this lilo image- this is because lilo tries to check that the root exists- which it probably won't. So I added it to the append instead. It seemed to work).

10. Finally, reconfigure your bootloader default image to be the debian installer, and reboot your target machine.

You can then ssh to installer@<target> once it starts responding to pings (remember to switch your terminal to UTF-8) and select to start menu. Heck I normally open 2 or 3 ssh sessions to tail the log files. It's awesome- the whole debian-installer experience from 3000 miles away. Sweet.