Remote installation of Debian w/ multiple network interfaces

Share your own howto's etc. Not for support questions!

Remote installation of Debian w/ multiple network interfaces

Postby otrojake » 2010-08-05 03:43

I'm going to detail a process I've used recently at my work to install Debian on a computer already running Linux that was located hundreds of miles away from our location. The distance and cost of having a tech at the facility where the server was located necessitated using a method where we could install Debian without having anyone physically touch the machine.

Most of what I'm going to detail has been gleaned from the DebianInstaller wiki on remote installation. Many thanks to the author for providing a groundwork for this article. That article, however, does not mention what to do if there are multiple interfaces on the remote machine. As one does not have physical access to the remote machine, it is imperative that the remote computer has the correct address bound to the correct interface.

Some Caveats
As noted in the above link, this process is not to be taken lightly. You are most likely looking at this article because you need to install on a machine that you have no access to. If improperly configured, the kernel will either fail to boot on the remote machine or fail to bring up the network resulting in physical intervention being needed on the target computer. Triple-check your set up and test, test, test before deploying. I highly recommend using a virtual machine to make sure that the compiled kernel and initrd function as expected.

The process
1. You'll need a running Debian system somewhere to compile the installer kernel. I used a virtual machine and it made the process much easier.

2. Get the source for the debian-installer package:

Code: Select all
# apt-get source debian-installer

3. Get the build dependencies:

Code: Select all
# apt-get build-dep debian-installer

4. Install
Code: Select all
if not already installed:

Code: Select all
# aptitude install nameif

5. Change into the debian-installer directory and insert the following line at the beginning of
Code: Select all

Code: Select all
#include "network-console"

6. Create a preseed file with--at the very least--the following, changing values as needed and placing it somewhere you can remember:

Code: Select all
d-i preseed/early_command      /bin/nameif
d-i debian-installer/locale            string en_US
d-i debconf/priority               select critical
d-i auto-install/enabled            boolean true
d-i netcfg/choose_interface         select installer0
d-i netcfg/disable_dhcp            boolean true
d-i netcfg/get_nameservers         string
d-i netcfg/get_ipaddress            string
d-i netcfg/get_netmask            string
d-i netcfg/get_gateway            string
d-i netcfg/confirm_static            boolean true
d-i netcfg/get_hostname            string myserver
d-i netcfg/get_domain            string myhome.none
d-i network-console/password         password password
d-i network-console/password-again      password password

7. Add the following to
Code: Select all

Code: Select all

8. Create
Code: Select all

Code: Select all
deb stable main/debian-installer
deb testing main/debian-installer

9. Once you are sure of your configuration, you can build the netboot image:

Code: Select all
fakeroot make rebuild_netboot

10. Normally, this is where we would be done, but we need to make some modifications to the initrd we just created. (You can make these changes in the Make file if you feel so inclined. I found it much easier to make minor changes to the initrd rather than recompiling each time I need to make a change.):

Code: Select all
cd tmp/netboot
mkdir initrd
cp initrd.gz initrd/
cd initrd/
gunzip initrd.gz
cpio -i --no-absolute-filenames < initrd #IMPORTANT! Without the --no-absolute-filenames option this will extract into root "/"

11. We've now extracted what is contained in the initrd. We've got to do some editing to make sure the correct interface is assigned the correct IP address. Take a look at the MAC addresses on the remote system. For this example we'll assume that we want installer0 to be our main interface and to be bound to 00:00:00:00:00:01 with another interface with a MAC address of 00:00:00:00:00:02.

Code: Select all
cp /sbin/nameif bin/nameif
echo -e "installer0 00:00:00:00:00:01\n\ninstaller1 00:00:00:00:00:02" > etc/mactab

12. Now that we've got the system in place to bring up the correct interface for installer we can get the initrd ready for boot again:

Code: Select all
find . | cpio -o -H newc > initrd
gzip -c initrd > initrd.gz

13. You'll probably want to copy the kernel and initrd to some place convenient:

Code: Select all
cp initrd.gz ~/debian-installer-rd.gz
#cd back to the build/tmp/netboot directory
cp vmlinuz ~/debian-installer-vmlinuz

14. Now we need to configure the bootloader on the target system.

If grub1, add the following to the top of the /boot/grub/menu.lst:

Code: Select all
title debian installer
        root (hd0,0)
        kernel /boot/debian-installer-vmlinuz rw ramdisk_size=24000 root=/dev/rd/0
        initrd /boot/debian-installer-rd.gz

AND copy
Code: Select all
Code: Select all
to the boot folder on the target system.

If grub2, rename the kernel image and initrd to include a kernel version. For example
Code: Select all
Code: Select all
and copy those files to the boot folder on the target system. Then run:

Code: Select all
# update-grub

If lilo, NOTE: I have not tested this under lilo. If this is incorrect, comment and let me know. The source article used this configuration to boot the installer kernel and initrd. I imagine since there hasn't been any major revisions to lilo lately that this will still hold true.

Code: Select all

15. Now for the moment of truth. Check everything again to make sure that your interface is correctly configured in the preseed file. Also check your mactab again to make sure that you entered the MAC addresses correctly. If any of these values are wrong, the installer kernel will boot an fail to bring up the interfaces, leaving you with an unreachable machine. This is where a virtual machine pays off. You'll be able to boot the installer kernel and make sure there are no errors. I highly recommend using a virtual machine for this purpose.

16. After you are absolutely sure everything is configured correctly, reboot the remote system.

17. SSH into the remote system:

Code: Select all

18. Run through the installer process. Do NOT finish the installation without performing this step, or the new installation will not be guaranteed to bring up the interfaces with the correct interface names. Before selecting "Finish the installation" select "Execute a shell" and run the following commands (assuming /dev/sda1 is the device name of your newly created root partition--check this with fdisk -l):

Code: Select all
mkdir /mnt/newinstall
mount /dev/sda1 /mnt/newinstall
rm /lib/udev/rules.d/75-persistent-net-generator.rules
rm /mnt/newinstall/lib/udev/rules.d/75-persistent-net-generator.rules

Now edit
Code: Select all
to make sure that the MAC addresses line up with the interface names. For example, change the line

Code: Select all
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:00:00:00:00:01", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"


Code: Select all
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:00:00:00:00:01", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="installer0"

19. Once those commands have been executed run
Code: Select all
to drop back to the installer screen. Now you can finish the installation.

20. If you've done everything right, your remote computer will now boot into the newly installed Debian system. A couple of housecleaning items once booted into the new system:

-Change the interfaces from installer0,installer1 back to eth0,eth1:

Code: Select all
, changing all instances of installer0 to eth0 and also edit
Code: Select all
, also replacing instances of installer0 or installer1 to eth0 or eth1.

21. Reboot one last time to make those changes final and configure your system however you see fit! And congratulations on installing a new OS without ever touching the machine!
Posts: 1
Joined: 2010-08-05 03:36

Return to Docs, Howtos, Tips & Tricks

Who is online

Users browsing this forum: No registered users and 2 guests