Difference between revisions of "Pxe"
imported>ThorstenStaerk |
imported>ThorstenStaerk |
||
(9 intermediate revisions by the same user not shown) | |||
Line 12: | Line 12: | ||
== DHCP == | == DHCP == | ||
− | To allow your computers to boot from the network, they first need an IP address. So, [[set up a dhcp-server]]. | + | To allow your computers to boot from the network, they first need an IP address. So, [[set up a dhcp-server]]. Adapt /etc/dhcpd.conf, here is an example: |
− | + | ||
− | + | ddns-update-style interim; | |
authoritative; # I am the one and only here | authoritative; # I am the one and only here | ||
− | + | default-lease-time 600; | |
− | next-server | + | max-lease-time 3600; |
− | filename "pxelinux.0"; | + | option broadcast-address <abbr title="replace this by your broadcast address">192.168.178.255</abbr>; |
+ | option routers <abbr title="replace this by your router">192.168.178.1</abbr>; | ||
+ | option domain-name-servers <abbr title="replace this by your DNS">192.168.178.1</abbr>; | ||
+ | option domain-name <abbr title="replace this by your domain">"mydomain.net"</abbr>; | ||
+ | |||
+ | subnet <abbr title="replace this by your subnet">192.168.178.0</abbr> netmask 255.255.255.0 | ||
+ | { | ||
+ | range <abbr title="replace this by your range">192.168.178.10 192.168.178.100</abbr>; | ||
+ | ''' next-server <abbr title="replace this by your subnet">192.168.178.3</abbr>;''' | ||
+ | ''' filename "pxelinux.0";''' | ||
+ | } | ||
+ | |||
Make sure you have restarted your dhcpd: | Make sure you have restarted your dhcpd: | ||
/etc/init.d/dhcpd restart | /etc/init.d/dhcpd restart | ||
Line 42: | Line 53: | ||
== pxelinux.cfg/default == | == pxelinux.cfg/default == | ||
+ | Create a directory /srv/tftpboot/pxelinux.cfg: | ||
+ | mkdir /srv/tftpboot/pxelinux.cfg | ||
Create a /srv/tftpboot/pxelinux.cfg/default like this: | Create a /srv/tftpboot/pxelinux.cfg/default like this: | ||
default linux | default linux | ||
Line 54: | Line 67: | ||
* Now you must supply kernel (vmlinuz) and initrd into the tftp folder: | * Now you must supply kernel (vmlinuz) and initrd into the tftp folder: | ||
cp /boot/vmlinuz /srv/tftpboot | cp /boot/vmlinuz /srv/tftpboot | ||
− | cp /boot/initrd /srv/ | + | cp /boot/initrd /srv/tftpboot |
== Change initial ramdisk == | == Change initial ramdisk == | ||
Line 81: | Line 94: | ||
cd /srv | cd /srv | ||
wget http://www.tux.org/pub/people/kent-robotti/looplinux/rip/RIPLinuX-13.7.PXE.zip | wget http://www.tux.org/pub/people/kent-robotti/looplinux/rip/RIPLinuX-13.7.PXE.zip | ||
− | unzip | + | unzip RIPLinuX-13.7.PXE.zip |
== Ubuntu 10.04 == | == Ubuntu 10.04 == | ||
+ | {{stub}} | ||
+ | This works only partly. Keep it here for development. | ||
The links are valid as of 2012-12-14. | The links are valid as of 2012-12-14. | ||
sudo su - | sudo su - | ||
Line 113: | Line 128: | ||
EOF | EOF | ||
/etc/init.d/dhcp3-server start | /etc/init.d/dhcp3-server start | ||
+ | cat >/etc/exports<<EOF | ||
+ | /public/ *(rw,no_root_squash,sync) | ||
+ | EOF | ||
= See also = | = See also = | ||
+ | * [[NFS]] | ||
* [http://en.wikipedia.org/wiki/Preboot_Execution_Environment Wikipedia on PXE] | * [http://en.wikipedia.org/wiki/Preboot_Execution_Environment Wikipedia on PXE] | ||
+ | * http://people.redhat.com/jblume/pxe.html | ||
* http://www.digitalpeer.com/id/linuxnfs | * http://www.digitalpeer.com/id/linuxnfs | ||
* http://www.jukie.net/bart/blog/nfsroot-on-debian | * http://www.jukie.net/bart/blog/nfsroot-on-debian |
Latest revision as of 13:22, 3 November 2015
PXE stands for Preboot Execution Environment. It is used to boot a computer using booting information from over the network.
Contents
Overview
The typical PXE boot looks like this:
- Computer A starts. Its BIOS is set to do a PXE boot, so booting from the network.
- Computer A acquires an IP address from dhcp server B.
- Computer A downloads its booting files (initrd and kernel) via tftp from B.
- Computer A executes the kernel just as if it had from its local hard disk.
How to start
In this example we use SUSE Linux 12.1.
DHCP
To allow your computers to boot from the network, they first need an IP address. So, set up a dhcp-server. Adapt /etc/dhcpd.conf, here is an example:
ddns-update-style interim; authoritative; # I am the one and only here default-lease-time 600; max-lease-time 3600; option broadcast-address 192.168.178.255; option routers 192.168.178.1; option domain-name-servers 192.168.178.1; option domain-name "mydomain.net"; subnet 192.168.178.0 netmask 255.255.255.0 { range 192.168.178.10 192.168.178.100; next-server 192.168.178.3; filename "pxelinux.0"; }
Make sure you have restarted your dhcpd:
/etc/init.d/dhcpd restart
TFTP
After your computers have received their IP address, they start asking for their booting file from the TFTP-server, in this case 192.168.0.5. So, make sure they can get it.
- Install tftp and syslinux:
# yast -i tftp syslinux
- copy syslinux' pxelinux.0 to /srv/tftpboot/:
# rpm -ql syslinux | grep pxelinux.0 /usr/share/syslinux/gpxelinux.0 /usr/share/syslinux/pxelinux.0 # cp /usr/share/syslinux/pxelinux.0 /srv/tftpboot/
- Activate the tftp server. To do this, change /etc/xinetd.d/tftp. Replace
disable = yes
with
disable = no
Then restart xinetd which hosts tftpd:
/etc/init.d/xinetd restart
- Test it:
tftp 192.168.0.5 -c get pxelinux.0
Test your configuration now by booting a connected computer from PXE. You should get an error message saying that the configuration file pxelinux.cfg/default has not been found.
pxelinux.cfg/default
Create a directory /srv/tftpboot/pxelinux.cfg:
mkdir /srv/tftpboot/pxelinux.cfg
Create a /srv/tftpboot/pxelinux.cfg/default like this:
default linux timeout 0 prompt 1 display display.msg label linux kernel vmlinuz append initrd=initrd
- Now you must supply kernel (vmlinuz) and initrd into the tftp folder:
cp /boot/vmlinuz /srv/tftpboot cp /boot/initrd /srv/tftpboot
Change initial ramdisk
If you now want to change the initrd to actually do something, you can do it like this:
cd /srv/tftpboot mkdir tmp cd tmp cp ../initrd ./initrd.gz gunzip initrd.gz mkdir tmp2 cd tmp2 cpio -id < ../initrd
Do the needed changes now in this folder. Then pack the initrd again:
find . | cpio --create --format='newc' > ../newinitrd cd .. gzip newinitrd
Your new initrd is now called newinitrd.gz.
Basic setup
The goal here is to be able to boot a Linux shell from PXE.
For this I took the initrd and kernel from the SUSE 12.1 install DVD and modified the initrd. I replaced /init on the initrd by /bin/bash. Then I copied busybox to /bin. Then I booted from PXE. Then I mounted /proc:
mount -t proc proc /proc
RIP
cd /srv wget http://www.tux.org/pub/people/kent-robotti/looplinux/rip/RIPLinuX-13.7.PXE.zip unzip RIPLinuX-13.7.PXE.zip
Ubuntu 10.04
This article is a stub and needs improvement. You can help here :)
This works only partly. Keep it here for development. The links are valid as of 2012-12-14.
sudo su - apt-get install tftpd-hpa wget http://ftp.debian.org/debian/dists/wheezy/main/installer-i386/current/images/netboot/netboot.tar.gz tar xvzf netboot.tar.gz sed -i 's/BOOT=local/BOOT=nfs/' /etc/initramfs-tools/initramfs.conf mkinitramfs -o /boot/initrd-netboot.img cp /boot/vmlinuz-2.6.32-33-generic /var/lib/tftpboot/ cp /boot/initrd-netboot.img /var/lib/tftpboot/ apt-get install dhcp3-server cat >dhcpd.conf <<EOF option domain-name "mydomain.org"; option domain-name-servers 8.8.8.8; option routers 192.168.178.1; allow booting; allow bootp; authoritative; # I am the one and only here ddns-update-style none; default-lease-time 14400; subnet 192.168.178.0 netmask 255.255.255.0 { range 192.168.178.10 192.168.178.20; default-lease-time 14400; max-lease-time 172800; next-server 192.168.178.11; filename "pxelinux.0"; } EOF /etc/init.d/dhcp3-server start cat >/etc/exports<<EOF /public/ *(rw,no_root_squash,sync) EOF