[INFO] PXE (Small General Overview)

Post tutorials, HOWTO's and other useful resources here.
User avatar
82issa
DOC Team
DOC Team
Posts: 127
Joined: 13 Apr 2011, 17:24
Location: USA, NC

[INFO] PXE (Small General Overview)

Post#1 by 82issa » 16 Jun 2011, 05:19

PXE is short for Preboot Execution Envionment.

Short and simple definition this PXE allows us to boot the computer over the network not requiring
harddrive nor cdrom. You can do this with as few as 2 computers (1 server, 1 client), or as many as
can get your hands on.

Reasons for PXE booting:
$43.99 8 gb ssd
$14.99 40 gb ultra ata
$17.94 39 gb sata
$4 to $20 cdrom device
These prices are from pricewatch night of June 11, 2011.
So if we are setting up a network with 101 computers(1 server, 100 clients) we could potentially save
(100 X (cost of harddrive)) + (100 X (cost of cdrom)). And those were the cheapest data storage devices
I could find. Also for fun and to learn are some more, are good reasons to mess arround with this. One last
great advantage of this is you can have all configuration stored on one machine. Less running arround to resolve
software issuse.

Server Side:
Your server will need to do a couple of things. Typically it hosts DHCP (dynamic host configuration protocol).
If you said "I already have dhcp provided by my router!". This will not work. As you most likely cant configure
path for the network bootstrap program. Also there is a tftp which needs to be set up. This tftp hosts the kernel
whatever else you decide to put there. The PXE firmware usually asks for this network bootstrap program. Porteus
has all of this taken care of for us. When you select the pxeboot at the bootmenu. The boot option will configure
all of this for you.

Client side:
You needed a simple "pxe boot disk" in the past to do the PXE-boot a computer. Now most motherboards with integrated
network adapters allow for you to boot using the network adapter. You can find out how to enable network booting in
the motherboard manual, that usually comes with the computer. If not just scan around in the bios settings. You will
be looking for two things one says "Enable Network Boot:" with a enable/disable switch. It might be a little different
on the wordage. This needs to be enabled. Then you go to the boot options. Now that network boot is enabled you can
see it in the list with cdrom, floppy, and harddrive. Now we put it as the #1 boot option,(save and exit) then restart
your computer. You could also get a network adapter that, has this feature. If so you will need to set all the boot options
in the bios to pass or disable all of them. So the bios will pass the boot to the rest of the hardware in your computer.
Sometimes the network bootable Ethernet adapter can be seen by the bios and will give you the option to select it in the
boot options. Once you have it selected for booting from the network device. Make sure it is pluged into the network
then start it up. If your computer doesn't have the network boot option, check out http://etherboot.org . This is a
wonderful resource on non proprietary pxe roms.

Note:
I wrote this as a small general overview, as I am very buisy. If you have a specific question regarding this topic feel free to ask
here. I will answer to the best of my ability. Also the first time I ever put together a pxe server I was running an open-mosix
cluster. All my clients were just motherboard, cpu, ram, and power supply. After the bios's on those clients were configured I
did not have any need for a monitor keyboard or any other device attached. My pxe server was also running an open-mosix
kernel and I was able to use the cpu's and ram of all clients as if they existed within the server.
Sorry guys... I got to go. My girlfriend just casted "get your dirty ass into the shower" on me.
Oh and here is some naked grandpa pictures too.

User avatar
Ahau
King of Docs
King of Docs
Posts: 1331
Joined: 28 Dec 2010, 15:18
Distribution: LXDE & Xfce 32/64-bit
Location: USA

Re: [INFO] PXE (Small General Overview)

Post#2 by Ahau » 16 Jun 2011, 14:31

Great! Thank you, 82Issa!

So, a question on the mechanics of running this --

Once you have your server set up and your client's hardware set to boot over the network, what's the process to get the client running? Do you power up your server with PXE boot enabled, and then just flip the power switch on the client and it will automatically boot the OS from the server? Or, can you use the server to remotely start up the client?

Thanks, and please forgive my lack of knowledge here :)
Please take a look at our online documentation, here. Suggestions are welcome!

User avatar
82issa
DOC Team
DOC Team
Posts: 127
Joined: 13 Apr 2011, 17:24
Location: USA, NC

Re: [INFO] PXE (Small General Overview)

Post#3 by 82issa » 17 Jun 2011, 01:57

I haven't used porteus for doing this yet as I don't have the time to set up a small network with two computers. But yes the computer that you want to be the server needs to start using pxe boot option in porteus. If you didn't select this at boot on your server you can manually start the scripts to configure all this for you. But typically (on the clients), when configured properly and power up you have a bootmenu where you select the kernel+cheatcodes. This is usually done over an ethernet connection. They clients have to be manually started. I suppose if you had the proper hardware you could use the POE (Power Over Ethernet) and use the WOL (Wake On Lan) feature within your bios. Then have the server fully started, just flip the switch for your POE compliant, hub/switch, then all clients connected to it will come up all at once, only needing to flip just one switch for all the clients.
Need to have server fully up before powering up any clients.
Power up client.
Client says "who am I?" basic pxe boot process
Server DHCP services respond with IP address.
Client says "What am I starting"
Server DHCP tells the client "The network bootstrap program is located on the tftp service"
Client gets the network bootstrap program from the server witch is hosting the tftp.
TFTP Stands for trivial file transfer protocol It has a lot less tcp/ip overhead comparatively to regular ftp (file transfer protocol)
In Porteus config DHCP and TFTP are both hosted on the same computer aka the server.

Posted after 8 minutes 51 second:
There is a lot of configuration that needs to take place before you just flip a couple of switches and have everything up and running smoothly.
Have the Server setup and configured properly.
Have all the clients configured properly.
Having the ethernet plugged up properly.
These are key to getting this to work.

Other cool stuff. Which is similar to pxe boot is http://boot.kernel.org Where you can boot your computer over the internet vs. the ethernet. Very slow due to bandwidth issues but fun to mess arround with. I am not aware of any way remotely forcing a computer to power up from the server.
Sorry guys... I got to go. My girlfriend just casted "get your dirty ass into the shower" on me.
Oh and here is some naked grandpa pictures too.

User avatar
Ahau
King of Docs
King of Docs
Posts: 1331
Joined: 28 Dec 2010, 15:18
Distribution: LXDE & Xfce 32/64-bit
Location: USA

Re: [INFO] PXE (Small General Overview)

Post#4 by Ahau » 17 Jun 2011, 05:57

Great, thanks!!
Please take a look at our online documentation, here. Suggestions are welcome!

User avatar
fanthom
Moderator Team
Moderator Team
Posts: 5666
Joined: 28 Dec 2010, 02:42
Distribution: Porteus Kiosk
Location: Poland
Contact:

Re: [INFO] PXE (Small General Overview)

Post#5 by fanthom » 17 Jun 2011, 09:05

i'm not a PXE expert but this is how i see it:
1) on the server side Porteus must be started with 'PXE server' syslinux boot menu option (or with any other mode: in this case 'pxe-boot' script must be started manually)
2) 'pxe-boot' script launches http server ('Monkey' in 32bit and 'webfsd' in 64bit) and dhcp + tftp (done by dnsmasq utility). once http server is started you can monitor all files served by it by typing your IP in firefox browser. you should see /porteus folder over there.
3) at this stage client can be started with 'boot over network' option (BIOS settings)
4) after powering on, client searches for IP address from the server and pxelinux.0 firmware (/boot/pxelinux.0 on the server side). firmware is unpacked and starts downloading vmlinuz + initrd.xz from the server (not sure about firmware role at this stage - just guessing)
5) after unpacking of kernel and initrd, linuxrc checks /proc/cmdline for IP address assigned by dnsmasq and if found then launches 'httpfs' utility which mounts /porteus/base (with all modules) from http server inside the ram disk.
6) now booting continues as in normal CD/USB scenario

Corrections are welcome :)
Please add [Solved] to your thread title if the solution was found.

User avatar
82issa
DOC Team
DOC Team
Posts: 127
Joined: 13 Apr 2011, 17:24
Location: USA, NC

Re: [INFO] PXE (Small General Overview)

Post#6 by 82issa » 17 Jun 2011, 11:01

The pxelinux.0 is the network bootstrap program. It is based off of the syslinux boot manager. I don't believe the pxelinux.0 is compressed(under step 4 you have firmware being unpacked), So the firmware acts like grub/lilo/syslinux, it hosts your boot options. pxelinux.0 calls your kernel+initrd with all your cheatcodes.
@fanthom You do have a pretty good grasp on what is going on here.
Sorry guys... I got to go. My girlfriend just casted "get your dirty ass into the shower" on me.
Oh and here is some naked grandpa pictures too.

User avatar
Ahau
King of Docs
King of Docs
Posts: 1331
Joined: 28 Dec 2010, 15:18
Distribution: LXDE & Xfce 32/64-bit
Location: USA

Re: [INFO] PXE (Small General Overview)

Post#7 by Ahau » 23 Jun 2011, 16:01

I've just posted a draft of this doc on the website, here:

http://porteus.org/info/docs/48-pxe/134 ... oting.html

I've done a bit of editing to incorporate the information from all of the above posts into the doc. Please review for accuracy and let me know what further edits/corrections should be made (you can list them here or send them to me via PM).

In particular, I need an answer to this question, which I've sloppily left is inside the doc:

((Question - if you boot with the standard '/boot/pxelinux.cfg/default' included in the ISO, the prompt is set to 0, does this mean you will not have an opportunity to enter cheatcodes or select your boot mode? If that is the case, then I can include instructions from this doc to add 1 to prompt, allowing clients to pick which boot option to select))


Thanks!
Please take a look at our online documentation, here. Suggestions are welcome!

User avatar
fanthom
Moderator Team
Moderator Team
Posts: 5666
Joined: 28 Dec 2010, 02:42
Distribution: Porteus Kiosk
Location: Poland
Contact:

Re: [INFO] PXE (Small General Overview)

Post#8 by fanthom » 23 Jun 2011, 20:50

"((Question - if you boot with the standard '/boot/pxelinux.cfg/default' included in the ISO, the prompt is set to 0, does this mean you will not have an opportunity to enter cheatcodes or select your boot mode? If that is the case, then I can include instructions from this doc to add 1 to prompt, allowing clients to pick which boot option to select))"

i had a plan to include 'text menu' for pxe-boot (similar to lilo) but never found a time to check how it works.
could be added to 1.1 i guess.
Please add [Solved] to your thread title if the solution was found.

User avatar
bshogeman
White ninja
White ninja
Posts: 27
Joined: 10 May 2013, 13:12
Distribution: Porteus 2.0 x64
Location: Lisse, the Netherlands
Contact:

Re: [INFO] PXE (Small General Overview)

Post#9 by bshogeman » 10 May 2013, 13:49

I want to use porteus with an alternative (M$) DHCP, TFTP and HTTP server.
The DHCP and TFTP part is no problem. With iPXE I can load the kernel and initrd. But then.. the modules and everything else in the porteus folder.
How do I define where to search.. yes something with changes=/porteus or extramod I think but then define every module somehow?
And can the autoexec cheatcode be used to load freerdp for instance? Yes I know I must replace spaces with ~.
Do you have an example commandline for me with kernel parameters?
Else I try and compile everything in a new ISO and change the /etc/xdg/openbox/autostart (If I use the kiosk version, must look what file I must have for the x64 version which uses xorg instead) in 003-settings.xzm to boot directly in freerdp.
And then boot the ISO over PXE. But if it can load directly then that would be perfect. iPXE has support for a multiboot kernel (http://ipxe.org/cmd/kernel). But If I understand right you also already used something like this as well.In the description httpfs is called so I think there is a better solution for this. But how do I use this in a Microsoft environment?

User avatar
fanthom
Moderator Team
Moderator Team
Posts: 5666
Joined: 28 Dec 2010, 02:42
Distribution: Porteus Kiosk
Location: Poland
Contact:

Re: [INFO] PXE (Small General Overview)

Post#10 by fanthom » 10 May 2013, 14:33

hi bshogeman,

need to clarify some things:
a) you wont be able to boot Kiosk Edition through PXE as initrd from Kiosk does not support this
b) httpfs client from standard edition is compatible with only some http servers: monkeyd (version 0.9.x), webfs, nginx, apache (not sure if all versions) so there is a chance it wont work for you
c) Porteus is moving to NFS for PXE boot in next release (will be saving changes over network) so i wouldn't invest much time in httpfs as is being obsolete already.

to answer some of your questions:
How do I define where to search..
httpfs checks IP delivered by pxe server and tries to bind port 80 locally. all what you need to do is to:
- start http servert on the same IP as other services (tftp, dhcpcd)
- make sure that port 80 of the server points to a location where porteus ISO was unpacked
again - this may not work depending on http server being used (httpfs client is able to read responses only from few servers)
can the autoexec cheatcode be used to load freerdp for instance?
autoexec operates in text mode and i think you will have to start it while in GUI. please use /opt/porteus-scripts/xorg/paths script to start apps in GUI or autostart directory in your home folder (path depends on the desktop being used)

btw: you should be able to transfer whole ISO through tftp and then mount it locally but it would require modifications in linuxrc.
Please add [Solved] to your thread title if the solution was found.

User avatar
bshogeman
White ninja
White ninja
Posts: 27
Joined: 10 May 2013, 13:12
Distribution: Porteus 2.0 x64
Location: Lisse, the Netherlands
Contact:

Re: [INFO] PXE (Small General Overview)

Post#11 by bshogeman » 10 May 2013, 18:04

I was afraid that would be your answer. Then I have the same problem as LTSP which first used NFS but now moved to NBD. NBD (better than NFS because it uses compressed images and still loads only the necessary files out of it) is not a real problem because there are good NBD servers for windows. But the problem was defining where it boots from. The DHCP and TFTP are different servers. The TFTP is running on the M$ SCCM server and already serves more than one boot image.
Only the diskless clients are still a problem.
But as I read in your answer.. defining an other server is impossible. It only can run perfectly if you really use the complete solution. :(
Or use the complete ISO. That is not so fast as real PXE boot because it must first transfer the complete image before booting, also the files that aren't used. But that is the only solution and what I am planning to use instead. And what am I complaining about.. It still is fast as porteus is small and boots real fast!
I ain't going to use TFTP to transfer the ISO but HTTP which is a lot faster. I use TFTP only for the first bootstrap then with a sanboot command load the ISO over HTTP (http://ipxe.org/cmd/sanboot).
I think that this must work fine with a unmodified linuxrc. But what type of changes are you thinking about? Am I missing something?

User avatar
fanthom
Moderator Team
Moderator Team
Posts: 5666
Joined: 28 Dec 2010, 02:42
Distribution: Porteus Kiosk
Location: Poland
Contact:

Re: [INFO] PXE (Small General Overview)

Post#12 by fanthom » 11 May 2013, 07:00

NBD (better than NFS because it uses compressed images and still loads only the necessary files out of it)
not sure how NBD works but i guess our NFS implementation is not much different as squashed images are still mounted with the help of NFS and only necessary files are transferred over the network (although copy2ram option is also there).
But as I read in your answer.. defining an other server is impossible.
well.. in fact it is possible. you can use 'IP=' cheatcode which is not documented anywhere as i thought it would never be useful to anybody.
you can specify http server with IP different than tftp/dhcpcd like here:

Code: Select all

IP=x:http_server_ip
example: IP=x:192.168.1.5
(colon is crucial that why i used 'x' but could be any letter/number)
I use TFTP only for the first bootstrap then with a sanboot command load the ISO over HTTP
does the 'sanboot' utility let you mount the ISO somewhere? if yes then you could modify linuxrc to mount the iso in /mnt/pxe and that would work out of the box.
if sanboot uses other technique then maybe you could use httpfs2 to mount the ISO in /mnt/pxe. httpfs2 seems to be compatible with all servers.

another idea is to ship the ISO inside initrd and modify linuxrc to mount provided ISO in /mnt/isoloop. as you know TFTP is much slower that http so i would go with httpfs2 as compatible with everything.
(the reason we are not using 'httpfs2' by default is that it let's you mount ISO/xzm modules only while 'httpfs' let's you bind whole directories)

EDIT:\\
forgotten to mention that 'IP=' cheatcode will work only when you remove 'IPAPPEND' from /boot/syslinux/pxelinux.cfg/default (we need to avoid double entries in the kernel command line)
Please add [Solved] to your thread title if the solution was found.

User avatar
bshogeman
White ninja
White ninja
Posts: 27
Joined: 10 May 2013, 13:12
Distribution: Porteus 2.0 x64
Location: Lisse, the Netherlands
Contact:

Re: [INFO] PXE (Small General Overview)

Post#13 by bshogeman » 16 May 2013, 15:43

It seems like with the IP option all files must be in the root of the http server as porteus own http server also does.
So I first tried other ways..

Code: Select all

sanboot http://somewebserver/folder/theporteus.iso
sanboot the image failed. Most linux distro's understand where to find the files, silaz, ubuntu, debian, CentOS..
All boot well from web. But porteus fail to do so. The bootloader is shown instantly. You can choice what you want to boot, kernel loads..
And it hangs on:

Code: Select all

Starting init script (http://www.porteus.org/)
^ searching for porteus-v2.0-x86_64.sgn file
^ device not readu yet? delaying 1 seconds

Porteus data not found.
You are maybe using an unsupported boot device (eg. SCSI or old PCMCIA).
Workaround: Copy the directory /porteus from your boot device to an IDE/SATA disk, eg. to ......
the memdisk solution:

Code: Select all

initrd http://somewebserver/folder/theporteus.iso
chain http://somewebserver/folder/memdisk iso raw
This loads a little slower because the whole image must first be completely loaded to ram before the boot process begins.
I had good hope for it but same result as above.

Some kind of HTTP block device driver is included in porteus, you use httpfs2.
But I can't understand why it fail to boot out-of-the-box or better why other distro's don't fail.
(I almost sad other linux distro's, but that would be wrong, windows and BSD like OS's also boot correctly).

Still searching for a good solution.. It must be possible with porteus.

Otherwise I must as you suggested look for the linuxrc and make some modifications.
Or take an other look at the kernel parameters and see try if IP= may be a hostname and I can change the folder where to look to porteus (same structure as the cd, hd or usb) instead of the root.

Suggestions are always welcome.

User avatar
fanthom
Moderator Team
Moderator Team
Posts: 5666
Joined: 28 Dec 2010, 02:42
Distribution: Porteus Kiosk
Location: Poland
Contact:

Re: [INFO] PXE (Small General Overview)

Post#14 by fanthom » 16 May 2013, 17:03

It seems like with the IP option all files must be in the root of the http server as porteus own http server also does.
yes - must be exac copy of porteus http server settings.
Porteus data not found.
at this stage you can press any key (except for space/enter) to break into debugging mode. please do so and try to find if ISO image was mounted somewhere. please run 'cat /proc/mounts' and let me know if its the case so i could add this path to linuxrc in next porteus release.
again - i'm not familiar with sanboot so only guessing here.
try if IP= may be a hostname
must be IP as names are not resolved by default
can change the folder where to look to porteus
this can be done with 'from=' cheatcode but ISO must be mounted under /mnt/some_folder first.
Please add [Solved] to your thread title if the solution was found.

User avatar
bshogeman
White ninja
White ninja
Posts: 27
Joined: 10 May 2013, 13:12
Distribution: Porteus 2.0 x64
Location: Lisse, the Netherlands
Contact:

Re: [INFO] PXE (Small General Overview)

Post#15 by bshogeman » 19 May 2013, 19:31

I thought using the initrd methode would be the simplest.
I edited the initrd file to include all files. The default initrd had a empty porteus folder.

Code: Select all

#!ipxe
set 210:string http://192.168.123.1/Porteus/
kernel ${210:string}boot/syslinux/vmlinuz  xfce from=/
initrd ${210:string}boot/syslinux/initrd.xz
initrd ${210:string}boot/syslinux/pxelinux.cfg/initrdpxe.xz
boot
As you can see all required files where loaded. Even the initrdpxe that is not really needed. And the from cheatcode is defined.
Loading time is reasonable. Comparable with memdisk. When using both with http instead of tftp of course.
But the result is that it still can't find the files as you can see. And yes it still boots ;)

Image

Defining FROM as /porteus doesn't solve the problem.

Then your question how did I edit it..
From porteus..
Unpacked the initrd.xz withL xz -d initrd.xz
Created a temp folder
unpacked the initrd with: cpio -i
added the files with corrected permissions (I let porteus install to a ext2 disk and copyed the files from there)
recompressed with the temp folder from within the folder itself: find . | cpio --quiet --dereference -o -H newc > ../initrd
Output file is a level higher so: cd ..
Compressed it back to xz format: xz initrd (no changes to the compression level because the kernel doesn't support max compression)
And replaced the file so the whole porteus installation is included in 2 files. The kernel: vmlinuz and the initrd: initrd.xz
The files are as you can see in the screenshot visible in the folder. All files have read permissions and folders also execute.

Are there changes needed in the linuxrc to include searching the files in the rootfs?

Post Reply