LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General > LinuxQuestions.org Member Success Stories
User Name
Password
LinuxQuestions.org Member Success Stories Just spent four hours configuring your favorite program? Just figured out a Linux problem that has been stumping you for months?
Post your Linux Success Stories here.

Notices


Reply
  Search this Thread
Old 11-27-2004, 05:35 PM   #1
Bluesuperman
Member
 
Registered: Nov 2002
Distribution: Slackware
Posts: 155

Rep: Reputation: 30
Talking General PXE install server


Hello,

Below is a out line of what I did you get a PXE boot / install server up and running. With this server
you should be able to load any Linux distro that loads via a ramdisk or create your own. Plus you should be able to install almost any OS that can be installed via a image or install script.

Sources for information and software:

http://syslinux.zytor.com/ - provides SYSLinux and PXELinux software puts lots of documentation.

http://www.kegel.com/linux/pxe.html - provides lots of links and documentation.

Under Kernel source ../Documentation/initrd.txt
- Provides a GREAT deal of documentation with regards to the initrd.img process, ramdisk.

Steps ...

1. Install distro of choice on PC, with HDD space for images and serveral distro's install packages / sources.

Required packages:
DHCP Server - used to provide dynamic or static IP's to server along with PXE boot file location
SYSLinux (should contain PXELinux software as well) - provides pxelinux.0 (zero) file
NFS Server - used to provide access to images / sources (HTTP,FTP could be used instead)
TFTP Server - used to provide boot file for PXE booting
INET Server - used to start TFTP server, I didn't want a TFTP server running all the time.

FTP server (Not required)- I used this to upload new images and sources which could be copied over via NFS or download from the distro's site as well.

CVS server (Not required) - I want to be able to save a lot of config scripts and modifications in CVS, that's all.

2. Create a user to limit required root access

I created a group called cvspxe and then a used called slammer. Under slammers home directory I created the following directories:
~/tftpboot #Used to chroot tftp server to plus it holds any required boot up files
~/tftpboot/pxelinux.cfg #Used to hold the linux config file, not sure what you would called it. It is a copy of the isolinux.cfg file.
~/tftpboot/kernels #Used to hold kernels to load

~/sources/images #Where I store drive images (W2k images, compress slackware images)
~/sources/distro #Where I store all my Linux distro's plus there source for install. (Example slackware-10 directory)

~/configs #Where I store a global config file and a per server / server type config file. This would contain hostnames, IP's plus any other information. (Required packages ....)

~/scripts #Scripts need to perform installs or any other taks

~/ramdisk #Files and initrd.img files for my customer initrd ramdisk
~/ramdisk/initrd #Mount point for ramdisk so I can make changes.

The directory structure is flexible but you will see what I created it soon enough.

3. Setup a DHCP server ... this can be an easy and difficult task, for me this was the first time I setup a DHCP server so I found it a little tricky.

Here is a copy of my DHCP config file:
--snip--
ddns-update-style interim;
ignore client-updates;

subnet 192.168.0.0 netmask 255.255.255.0 {

range 192.168.0.201 192.168.0.220;
default-lease-time 86400;
max-lease-time 86400;

option routers 192.168.0.1;
option ip-forwarding off;
option broadcast-address 192.168.1.255;
option subnet-mask 255.255.255.0;
option domain-name-servers 192.168.0.2;

next-server 192.168.0.15;
filename "/pxelinux.0"; ## Must provide full path relative to tftp server root if NOT Chrooting TFTP server
}

--snip--

The above server will work ... except for one small issue ... every machine on the network that boots up via the PXE option will get a install image. This may not be what is desired, you can move the next-server and filename option under it's own group if you like and add PC's to the group by their MAC address.

4. Once you have install the SYSLinux package there should be a file called pxelinux.0 on your system. Mine was in /usr/share/syslinux/pxelinux.0. Copy this file the tftpboot directory (mine is /home/slammer/tftpboot/). This is the file that the PXE client will download and run.

5. INET Server ... install and configure a INET to run the tftp server - consult your distro's documentation on how to do this.

6. Uncomment the tftp config line in your inetd.conf and add in the following:
tftp dgram udp wait root /usr/sbin/in.tftpd in.tftpd -s /home/slammer/tftpboot -r blksize

The -s path is used to set a chroot directory.

7. NFS server - I am using a NFS share to export the images,sources,configs and scripts directorys to all the clients. File system privileges set to read-only and export privileges set to read-only, you could use a http or ftp server but NFS is the easest.

At his point we are almost done now we need to populate the tftpboot directory with the required files.

#Output from cd /home/slammer/tftpboot ; find .

./kernels
./kernels/bare.i
./kernels/bare.i/bzImage #Standard slackware bare.i bzImage kernel image
./kernels/bare.i/System.map.gz
./kernels/bare.i/config #Bare.i kernel config file
./message.txt # Message to display at startup
./pxelinux.0
./initrd.img #Ramdisk image (tested using slackware's standard initrd.img file from CD)
./pxelinux.cfg
./pxelinux.cfg/default #config file used to load / pick kernel

Example of default
--snip--
default linux
prompt 1
timeout 1200
display message.txt
label linux
kernel kernels/bare.i/bzImage
append initrd=initrd.img load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=102400 rw root=/dev/ram
--snip--


That is about it ... now once you have got to this point you can start customizing things.

Customizations:

1. RAMDISK .. you will notice that in my default file I specify a ramdisk size of 102400, this is 100MB. This is because I created a custom initrd.img file to run a full file system.

To create one simple:
dd if=/dev/zero of=initrdfile bs=1024 count=100 # This should create 100MB file
losetup /dev/loop0 initrdfile #Sets up / attaches initrdfile to loop back device
mkfs.ext2 /dev/loop0 # Creates file system on /dev/loop0 (initrdfile). Use EXT2 -- This is only a ramdisk so journaling is not needed.

mount -t ext2 -o loop /dev/loop0 initrd

Now simple install any Linux distro onto this initrd directory. I choose to install a fully functional slackware file system. Using installpkg -root /home/slammer/ramdisk/initrd /path/to/packages/packname.tgz I installed all the required packages to have a fully bootable and workable system plus some extra's.

I used about 79 MB's.

umount initrd.
gzip -c -9 initrd > initrd.img #This compresses the 100BM file system image to about a 25-30MB file. Do a `man gzip` to find out what -c and -9 do.

On the file system you create ... you NEED TO HAVE A linuxrc file. This is explained in the kernelsource/Documentation/initrd.txt file. In sort .. the kernel loads using the initrd.img file ... then takes the initrd.img file and mounts it as the file system. But it needs to use the commands and devices from the initrd.img file before hand ... it is tricky ... read the initrd.txt file.

Mine looks like this:
--snip--
#!/bin/sh

mkdir /newroot ## Create new root mount point
mount /dev/ram /newroot #mount the initrd image file system

cd /newroot
mkdir initrd #Make directory for initrd file system to go to
pivot_root . initrd ## I believe this moves the current root file system to the local directory and puts the old one under the newly created initrd directory.

exec chroot . /sbin/init <dev/console >dev/console 2>&1
# Start init (process 1) under the new root mount point

umount initrd
blockdev --flushbufs /dev/ram
# Umount of the old root, since it is no longer needed and free of the memory
--snip--

Now you see you can create any kind of initrd image you want and load it or any one by simple adding enteries to the default file. You could have a debian option, a slackware option .. even redhat.

2. PXE customization ... you can also pick which file each machine loads ... under the tftpboot/pxelinux.cfg directory is a file called default. But if you place other files, with the names of the MAC addresses of system then that file would be used. More information is available at (http://syslinux.zytor.com/pxe.php#config)

As you can see from above ... once the initrd.img (ramdisk file system) of choice is loaded you can install any distro you want. For example you could install slackware packages onto the mount hard drive, or redhat rpms and you can ever create window 2000 boxes by using dd commands.

Michael
 
Old 10-12-2005, 09:53 PM   #2
Beatfox
LQ Newbie
 
Registered: Oct 2005
Location: Seattle, WA
Distribution: Slackware
Posts: 2

Rep: Reputation: 0
Re: General PXE install server

Quote:
Originally posted by Bluesuperman
dd if=/dev/zero of=initrdfile bs=1024 count=100 # This should create 100MB file
There is actually an error there, you must append K to the end of bs=1024, otherwise it just makes a 100K file since it defaults to bytes.

Should look like this:
dd if=/dev/zero of=initrdfile bs=1024K count=100


This was a great post and it is lots of help, just wanted to point that out. =)
 
Old 10-13-2005, 02:58 PM   #3
XavierP
Moderator
 
Registered: Nov 2002
Location: Kent, England
Distribution: Debian Testing
Posts: 19,192
Blog Entries: 4

Rep: Reputation: 475Reputation: 475Reputation: 475Reputation: 475Reputation: 475
This may well fit better in our Tutorial section. Would you consider posting it there?
 
Old 11-08-2005, 01:00 PM   #4
coldfusion76
LQ Newbie
 
Registered: Nov 2005
Posts: 1

Rep: Reputation: 0
So I'm currently trying to setup a PXE server at work and am having nothing but problems. I've set up the tftp server correctly and placed the pxelinux.0 file in the root folder, and created the pxelinux.cfg with the default file inside. I've setup my DHCP server with the following snippet:

group {
next-server 10.10.60.11;
filename "/tftpboot/pxelinux.0";

host test {
hardware ethernet 00:11:85:80:A1:96;
fixed-address 10.10.60.60;
}
}

When my client boots up, it gets the IP address that I've assigned it, but ALWAYS comes back with the error: ProxyDHCP service did not reply to request on port 4011. I'm confused because I thought that the pxe server listened on port 4011 and I thought that you didn't necessarily need a pxe server? You should really only need a dhcp and tftp server right? So why does my pxe client keep looking for info on 4011? What am I doing wrong? Thanks so much for your help!
 
Old 07-25-2007, 05:51 PM   #5
namit
Member
 
Registered: Aug 2005
Distribution: Debian
Posts: 355

Rep: Reputation: 30
any examples how i load a windowsxp image using dd?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Pxe Server Stopped Working! cstovall Linux - Networking 1 10-13-2005 01:52 PM
arch linux install over pxe paha Arch 1 12-14-2004 11:23 AM
trying linux install over pxe paha Linux - General 0 12-14-2004 07:09 AM
PXE install a box w/ an unsupported HD Toshi3 Linux - Hardware 0 09-13-2004 11:33 PM
PXE Server t420 Linux - Software 0 03-19-2003 01:42 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General > LinuxQuestions.org Member Success Stories

All times are GMT -5. The time now is 09:54 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration