You are viewing lotso

How to Install a Linux OS using DHCP & TFTP

How to Install a Linux OS using DHCP & TFTP

Update : Ow Mun Heng
Date : 30 July 2004
URLS :  [1] http://www.tnpi.biz/computing/freebsd/pxe-netboot.shtml
            [2] http://www.stanford.edu/~alfw/PXE-Kickstart/PXE-Kickstart-6.html
            [3] http://www.linux-mag.com/cgi-bin/printer.pl?issue=2002-10&article=netbooting
            [4] http://netboot.sourceforge.net/english/index.shtml
            [5] http://etherboot.sourceforge.net/
            [6] http://marc.herbert.free.fr/linux/win2linstall.html

Objective
---------

Get a linux OS installed onto a PC that has no Floppy/Cdrom and there's no option
to put the Hard Drive into another PC to transfer the install files. You can try
[6] if the machine already has windows on it. However, it was not the deal with me.

After going about this for more than half a day to figure out how to get Linux onto
a system that has neither a CDROM nor a Floppy and I don't have access to either one
of those devices, I finally stumbled into success.

It seems that this is how it is to be done.
Now, we're only going to get to the point where we can successfully boot into the
bootloader or something of that sort. No actual installation of linux. (YET)

A few requirements are needed. (I've tried this on FreeBSD and Fedora Core 2 and I'll
list them each separately but only some items needs to be changed for it to work)

1. DHCP-SERVER
2. TFTP-SERVER
3. FreeBSD's ISO/cdrom/Internet Access
4. Syslinux [http://syslinux.zytor.com/pxe.php]
5. Fedora Core's ISO/cdrom/Internet Access
6. PC that can do network boot (otherwise, try looking at [4] or [5] )

The DHCP/TFTP Server are all on a FC2 Notebook.
The PC to be installed with Linux is connected via crossover cable
to my laptop.

Setting up DHCP.
----------------
Well.. in my case, it's already set-up. Should not be a problem.
(Also remember which interface the DHCP server is supposed to listen to.
In my case, it listens on eth0, and this is reflected in :

user # cat /etc/sysconfig/dhcpd
# Command line options here
DHCPDARGS=eth0


We go on with the installation of the /etc/dhcpd.conf file

Here's mine

############### dhcpd.conf ##########################################
ddns-update-style interim;
ignore client-updates;
allow bootp;
allow booting;

subnet 192.168.0.0 netmask 255.255.255.0 {

    range 192.168.0.10 192.168.0.20;
    option routers 192.168.0.1;
    option subnet-mask 255.255.255.0;
    option domain-name "home.net";
    option domain-name-servers [insert domain name servers here];
    next-server 192.168.0.1;
    default-lease-time 21600;
    max-lease-time 43200;
    option root-path "/tftpboot/";
    filename "/pxelinux.0"; # This is for TFTP Boot

######################## END dhcpd.conf #############################


Setting up PXE Boot
-------------------

Go ahead and download the latest revision of the syslinux package from the link above.

user # wget http://www.kernel.org/pub/linux/utils/boot/syslinux/syslinux-2.10.tar.gz
user # tar -xvzf syslinux-2.10.tar.gz -C /usr/local/src

Create the tftpd root directory
root # mkdir /tftpboot

Now, we need to copy 2 files from here to our newly created tftpboot directory
(Note that for FreeBSD, I'm using the memdisk option instead of using the pxeboot
as some as mentioned - Refer to URLs [1])

root # cp pxelinux.0 /tftpboot
root # cp memdisk/memdisk /tftpboot

Setting up TFPTD-server
-----------------------

Install the TFTPD-server software. Under FC2, it's installed by default for some
reason. Just locate it and install it if you don't have it already.

Once that is done, look at the file :

cat /etc/xinetd.d/tftp
# default: off
# description: The tftp server serves files using the trivial file transfer
# protocol. The tftp protocol is often used to boot diskless
# workstations, download configuration files to network-aware printers,
# and to start the installation process for some operating systems.
service tftp
{
    disable = no <---------------TAKE NOTE
    socket_type = dgram
    protocol = udp
    wait = yes
    user = root
    server = /usr/sbin/in.tftpd
    server_args = -s /tftpboot
    per_source = 11
    cps = 100 2
    flags = IPv4
}


the "disable = no" needs to be there. You can either edit the tftp file using
a text editor and change it to "no" or you can do

root# chkconfig tftp on

That should work flawlessly


------------- BEGIN Instructions for FreeBSD ------------------------------

Copying the FreeBSD's Boot floopy image
----------------------------------------

Here I am assuming that you have the FreeBSD cdrom/ISO
Mount the cdrom
root # mount /dev/hdc /mnt/cdrom

or
Mount the iso image

root # mount -o loop /path/to/FreeBSD.ISO.Image /mnt/cdrom
root # cp /mnt/cdrom/floppies/boot.flp /tftpboot


Create the grub-like bootloader

root # mkdir pxelinux.cfg/

This creates a default FOR ALL clients
root # cat >> pxelinux.cfg/default

This will select install-freebsd as the default and users
need not type anything in. If you get dropped to a CLI prompt
type in install-freebsd and you're all set

default install-freebsd
LABEL install-freebsd
   KERNEL memdisk
   APPEND initrd=boot.flp

------------------ END FreeBSD Section ----------------------------

------------------ BEGIN Fedora Core 2 Section --------------------

For Fedora Core 2, the instructions are even simpler.
If you look under your FC2 cdrom, or if you did it like me, you browsed
to

http://mirror.linux.duke.edu/pub/fedora/linux/core/2/i386/os/images/pxeboot/

and got these 2 files

user # wget http://mirror.linux.duke.edu/pub/fedora/linux/core/2/i386/os/images/pxeboot/initrd.img
user # wget http://mirror.linux.duke.edu/pub/fedora/linux/core/2/i386/os/images/pxeboot/vmlinuz

Now, copy these 2 files into the /tftpboot directory, look at how I named them. (This is just for
my ease of use)

root # cp initrd.img /tftpboot/fc2-initrd.img
root # cp vmlinuz /tftpboot/fc2-vmlinuz

After you're done, the directory structure should look like this

user # ls -l /tftpboot
-r--r--r-- 1 nobody nobody 2949120 Jul 30 14:49 boot.flp
drwxr-xr-x 2 nobody nobody 240 Jul 30 14:17 BSD
-rw-r--r-- 1 nobody nobody 6291456 May 13 02:24 fc2-diskboot.img
-rw-r--r-- 1 nobody nobody 2443013 May 13 02:24 fc2-initrd.img
-rw-r--r-- 1 nobody nobody 1209805 May 13 02:24 fc2-vmlinuz
-rw-r--r-- 1 nobody nobody 23540 Jul 30 15:04 memdisk
-rw-r--r-- 1 nobody nobody 11816 Jul 30 15:11 pxelinux.0
drwxr-xr-x 2 nobody nobody 136 Jul 30 23:05 pxelinux.cfg


Now, we proceed to set up the grub-like bootloader

root # mkdir pxelinux.cfg/

This creates a default FOR ALL clients
root # cat >> pxelinux.cfg/default


This will select fc2 as the default and users
need not type anything in. If you get dropped to a CLI prompt
type in fc2 and you're all set

LABEL fc2
KERNEL fc2-vmlinuz
APPEND initrd=fc2-initrd.img


----------------- END Fedora Core 2 Section -----------------------


Finishing up
------------

Since the TFTP server is a bit unsecure, take note to chown the tftpboot directory to UID:GID
nobody:nobody

root # chown -R nobody.nobody /tftpboot

Restart the dhcpd server. Under Fedora/redhat this is called this way

root # service dhcpd restart (or start)

Then Boot the Network client.

Everything should work and you'll be greeted by the install routine.
Might take a while for the install if you're installing over FTP/HTTP.

but hey.. It works

Comments

Excellent howto. I did an FC3 install yesterday using this. Pesky motherboard refused to recognize any CD-ROM drives, but I have piles of PXE-capable NICs around.

Thank you for posting this.

Welcomed

You are most certainly welcomed.

I just tried doing that again last week, but it bombed out during NFS Decompression(?) or something.

Oh well..

Glad that it works for you..

April 2009

S M T W T F S
   1234
567891011
12131415161718
19202122232425
2627282930  
Powered by LiveJournal.com