K
K
Konstantin2014-10-09 11:56:37
linux
Konstantin, 2014-10-09 11:56:37

How to set up a Linux PXE installation from scratch?

All the best!
There is a lot of information about setting up a pxe installation of Linux images, but I want to collect a full-fledged mana for myself and fill in some knowledge holes. Actually, it would be nice if you share information about setting up pxe for installing Linux's.:
How to set up a pxe installer under Linux?
How to make an automatic installation of the selected linux image?
And can it all be combined with networked windows pxe installers?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
S
Sergey Petrikov, 2014-10-09
@fallen8rwtf

Nothing complicated, just a long description, I'll try to be brief with examples.
In the DHCP config add a setting like:

#PXE boot for Server
subnet XXX.XXX.6.0 netmask 255.255.255.XXX {
     range XXX.XXX.6.20 XXX.XXX.6.254;
     option routers XXX.XXX.6.1;
     option subnet-mask 255.255.255.XXX;
     option domain-name-servers  8.8.8.8;
        next-server XXX.XXX.6.10;  # TFTP server address
        filename "pxelinux.0";   # PXE boot loader filename
}

The key is the line with the IP transfer for the TFTP server and the name of the bootloader file.
Making a catalog for future images
mkdir -p /usr/tftpboot/images
mkdir /usr/tftpboot/pxelinux.cfg

Install tftp-hpa (easy to find for any system) Set
flags in the config:
Download fresh syslinux (for example https://www.kernel.org/pub/linux/utils/boot/syslin...
Fresh versions can always be found here www .syslinux.org/wiki/index.php/The_Syslinux_Project Unzip and
copy
the following files to /usr/tftpboot/:
chain.c32
ldlinux.c32
libcom32.c32
libutil.c32
memdisk
menu.c32
poweroff.c32
pxelinux.0
pxelinux.cfg
reboot.c32
vesamenu.c32

Also, if we plan to use Cyrillic in the menu, we will download fonts, for example, these
ftp://ftp.itrc.hp.com/applications/experteventadmi...
The menu encoding should be in CP866 aka Russian (DOS)
convert from koi8-r (standard Cyrillic for fries) can be a team.
iconv -f koi8-r -t CP866 defaultKoi8 -o default
create a folder with images
mkdir images
It contains subfolders with the necessary systems, in each subfolder we throw the files needed to boot the systems, here are a couple of examples:
Installing FreeBSD
Download
x32 images
fetch mfsbsd.vx. sk/files/images/i386/9/mfsbsd-9.1-RELEAS...
x64
fetch mfsbsd.vx.sk/files/images/amd64/9/mfsbsd-9.1-RELEAS...
Installing Debian 7
x32
fetch ftp://ftp.debian.org/debian/dists/Debian7.0.0/main...
fetch ftp://ftp.debian.org/debian/dists/Debian7.0.0/main...
x64
fetch ftp://ftp.debian.org/debian/dists/Debian7.0.0/main...
fetch ftp://ftp.debian.org/debian/dists/Debian7.0.0/main...
Installing CentOS
x32
fetch mirror.mirohost.net/centos/6.4/os/i386/images/pxeb...
fetch mirror.mirohost.net/centos/6.4/os/i386/images/pxeb...
x64
fetch mirror.mirohost.net/ centos/6.4/os/x86_64/images/px...
fetch mirror.mirohost.net/centos/6.4/os/x86_64/images/px...
Installing Kali
x32
fetch repo.kali.org/kali/dists/kali/main/installer-i386/...
fetch repo.kali.org/kali/dists/kali/main/installer-i386/...
x64
fetch repo.kali .org/kali/dists/kali/main / installer-amd64...
fetch repo.kali.org/kali/dists/kali/main/installer-amd64
...
/usr/tftpboot/pxelinux.cfg/defaultspecific servers, then not default)
Here is an example, the ways to edit on your own:
ui vesamenu.c32
PROMPT 0
MENU WIDTH 77
MENU MARGIN 10
MENU PASSWORDMARGIN 3
MENU ROWS 12
MENU TABMSGROW 18
MENU CMDLINEROW 18
MENU ENDROW 24
MENU PASSWORDROW 11
MENU TIMEOUTROW 60
MENU AUTOBOOT Starting Local System in # seconds

MENU PASSPROMPT Enter Password

NOESCAPE 0
ALLOWOPTIONS 0

MENU COLOR SCREEN 44;30 #00FFFFFF #00000000
MENU COLOR BORDER 44;30 #FFFFFFFF #FF000000
MENU COLOR TITLE 1;44;30 #FFFFFFFF #FF000000

MENU COLOR SCROLLBAR 44;30

MENU COLOR HOTKEY 44;30 #FFFFFF00 #FF000000
MENU COLOR UNSEL 44;30 #FFFFFFFF #FF000000
MENU COLOR HOTSEL 1;30 #FFFFFFFF #FF333333
MENU COLOR SEL 7;44;30 #FFFFFF00 #FF333333

MENU COLOR CMDMARK 44;30
MENU COLOR CMDLINE 44;30
MENU COLOR TABMSG 44;30
MENU COLOR DISABLED 44;30
MENU COLOR HELP 44;30

MENU COLOR PWDBORDER 44;30 #FF187CCA #FFFFFFFF
MENU COLOR PWDHEADER 1;44;30 #FF187CCA #FFFFFFFF
MENU COLOR PWDENTRY 5;44;30 #FF187CCA #FFFFFFFF

menu background background.jpg
FONT pxelinux.cfg/Cyr_a8x16.psf
menu title RealWeb PXE boot menu (c)Rico-X

LABEL bootlocal
   menu label ^Загрузка с локального диска
   kernel chain.c32
   append hd0 0
   timeout 150
 TEXT HELP
Загрузка с первого локального жесткого диска,
произойдет автоматически по ситечении таймера.
 ENDTEXT

menu begin
menu title FreeBSD 9.1

label FreeBSD91p2x64
  menu label Установить FreeBSD-9.1 x64
  kernel memdisk
  initrd images/mfsbsd/mfsbsd-9.1-RELEASE-p2-amd64.img raw
 TEXT HELP
После запуска параметры входа:
имя root пароль mfsroot
Для начала установки FreeBSD введите bsdinstall
 ENDTEXT

label FreeBSD91p2x32
  menu label Установить FreeBSD-9.1 x32
  kernel memdisk
  initrd images/mfsbsd/mfsbsd-9.1-RELEASE-p2-i386.img raw
 TEXT HELP
После запуска параметры входа:
имя root пароль mfsroot
Для начала установки FreeBSD введите bsdinstall
 ENDTEXT

label < Назад
 menu exit

menu end

menu begin
menu title Debian

label Debian_7x64
  menu label ^Debian 7 wheezy x86_64 install
  kernel images/debian/linux7_64
  append priority=low vga=788 initrd=images/debian/initrd7_64.gz --
  TEXT HELP
Устанавливает Debian 7 64 в ручном режиме.
  ENDTEXT

label Debian_7x32
  menu label ^Debian 7 wheezy i386 install
  kernel images/debian/linux7_386
  append priority=low vga=788 initrd=images/debian/initrd7_386.gz --
  TEXT HELP
Устанавливает Debian 7 32 в ручном режиме.
  ENDTEXT

label < Назад
 menu exit

menu end

menu begin
menu title CentOS

label CentOS_6.4_x86_64
  menu label ^CentOS 6.4 x86_64 install
  kernel images/centos/amd64/vmlinuz
 APPEND initrd=images/centos/amd64/initrd.img method=http://mirror.mirohost.net/centos/6/os/x86_64/ devfs=nomount ksdevice=link ramdisk_size=100000
  TEXT HELP
Устанавливает CentOS 6.4 x64 в ручном режиме.
Для установки уиспользуется http://mirror.mirohost.net/centos/6/os/x86_64/
  ENDTEXT

label CentOS_6.4_i386
  menu label ^CentOS 6.4 i386 install
  kernel images/centos/i386/vmlinuz
  APPEND initrd=images/centos/i386/initrd.img method=http://mirror.mirohost.net/centos/6/os/i386/ devfs=nomount ksdevice=link ramdisk_size=100000
  TEXT HELP
Устанавливает CentOS 6.4 i386 в ручном режиме.
Для установки уиспользуется http://mirror.mirohost.net/centos/6/os/i386/
  ENDTEXT

label < Назад
 menu exit

menu end

#label Centos6_64
#MENU LABEL CentOS 6 amd64
# KERNEL /memdisk
# APPEND iso
# INITRD images/centos/CentOS-6.4-x86_64-netinstall.iso

LABEL ProxMox
MENU LABEL ProxMox3 install
    KERNEL images/proxmox/linux26
#    APPEND ramdisk_size=102400 vga=791 video=vesafb:ywrap,mtrr splash=verbose url=http://195.114.6.10/images/proxmox/initrd.iso.img
    APPEND ramdisk_size=524288 vga=791 video=vesafb:ywrap,mtrr splash=verbose
    INITRD images/proxmox/initrd.iso.img

menu begin
menu title ^Kali ^Linux

label KaliLinux_x64
  menu label ^Kali Linux x86_64
  kernel images/kalilinux/amd64/linux
  append priority=low vga=788 initrd=images/kalilinux/amd64/initrd.gz --
  TEXT HELP
Дистрибьютив для пинтестирования,
cодержит различные инструменты для проведения тестов.
Русская документация http://ru.docs.kali.org/
  ENDTEXT

label KaliLinux_x32
  menu label ^Kali Linux i386
  kernel images/kalilinux/i386/linux
  append priority=low vga=788 initrd=images/kalilinux/i386/initrd.gz --
  TEXT HELP
Дистрибьютив для пинтестирования,
cодержит различные инструменты для проведения тестов.
Pусская документация http://ru.docs.kali.org/
  ENDTEXT

label < Назад
 menu exit

menu end

LABEL Pmagic
LINUX images/pmagic/bzImage
append noapic initrd=images/pmagic/initrd.img root=/dev/ram0 init=/linuxrc ramdisk_size=100000
  TEXT HELP
LiveCD дистрибьютив для восстановления и проверки систем.
  ENDTEXT

label reboot
  menu label Reboot
  kernel reboot.c32
  TEXT HELP
Перезагрузить компьютер
  ENDTEXT

LABEL poweroff
 MENU LABEL Power off
 KERNEL poweroff.c32
  TEXT HELP
Выключить компьютер
  ENDTEXT

To boot windows, you need to use a specially assembled WinPE image, which will mount the necessary images from network shares, but the description of assembling a sane image will take another 5 pages and I'm too lazy to print.

N
Nicholas Secret, 2015-09-25
@Ncla

Perfectly! Thank you! There is one more question, all these distributions will be installed through mirrors on the Internet, but how can I install from the server?

I
ioannsys, 2016-06-06
@ioannsys

What if there is already a DHCP server on the network?

K
Karpion, 2020-01-21
@Karpion

The DHCP server can issue different programs_to_download to different machines - focusing on the MAC address. Not the most convenient system.
Further, program_for_loading - can also decide what to do (run the desired installer immediately or ask the user). What signs to focus on - this is how the programmer's fantasy will tell.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question