Skoro trafiłeś na ten wpis zakładam, że wiesz czym jest Cygwin, jeśli jednak jesteś tu przypadkowo zapraszam do zapoznania się najpierw z moim wcześniejszym artykułem Instalacja środowiska Cygwin. Jeśli ten artykuł skłonił Cię do instalacji PXE / gPXE nie bezpośrednio na Windowsie lecz na Cygwinie, zapraszam do dalszej lektury. Na Cygwinie zainstalujemy komponenty takie jak: serwer TFTP, serwer NFS oraz niezbędne pliki z pakietu Syslinux. Wszystkie te komponenty utworzą nam pełne środowisko PXE / gPXE.
TFTP Server
Niezbędnym elementem środowiska PXE / gPXE jest serwer TFTP. Na Cygwinie zainstalujemy go wybierając w instalatorze następujące pakiety:
- Admin -> cygrunsrv,
- Net -> xinetd,
- Net -> tftp-server.
Możemy to zrobić także przy pomocy, opisanej we wspomnianym na wstępie artykule, komendy apt-cyg
w prosty i szybki sposób:
1 |
apt-cyg install cygrunsrv xinetd tftp-server |
Następnie uruchamiamy uruchamiamy Cygwina z prawami administratora i przechodzimy do konfiguracji xinetd (extended Internet daemon):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
$ xinetd-config *** Info: Note that the inetd service and the xinetd service must not *** Info: both be active at the same time. The easiest way to ensure *** Info: this is to only install one or the other as a service. *** Query: Do you want to install the xinetd super-server as a service? (yes/no) yes *** Query: Enter the value of CYGWIN for the daemon: [] *** Info: On Windows Server 2003, Windows Vista, and above, the *** Info: SYSTEM account cannot setuid to other users -- a capability *** Info: xinetd requires. You need to have or to create a privileged *** Info: account. This script will help you do so. *** Info: You appear to be running Windows XP 64bit, Windows 2003 Server, *** Info: or later. On these systems, it's not possible to use the LocalSystem *** Info: account for services that can change the user id without an *** Info: explicit password (such as passwordless logins [e.g. public key *** Info: authentication] via sshd). *** Info: If you want to enable that functionality, it's required to create *** Info: a new account with special privileges (unless a similar account *** Info: already exists). This account is then used to run these special *** Info: servers. *** Info: Note that creating a new user requires that the current account *** Info: have Administrator privileges itself. *** Info: No privileged account could be found. *** Info: This script plans to use 'cyg_server'. *** Info: 'cyg_server' will only be used by registered services. *** Query: Do you want to use a different name? (yes/no) no *** Query: Create new privileged user account 'cyg_server'? (yes/no) yes *** Info: Please enter a password for new user cyg_server. Please be sure *** Info: that this password matches the password rules given on your system. *** Info: Entering no password will exit the configuration. *** Query: Please enter the password: *** Query: Reenter: *** Info: User 'cyg_server' has been created with password 'g0hA2000'. *** Info: If you change the password, please remember also to change the *** Info: password for the installed services which use (or will soon use) *** Info: the 'cyg_server' account. *** Info: Also keep in mind that the user 'cyg_server' needs read permissions *** Info: on all users' relevant files for the services running as 'cyg_server'. *** Info: In particular, for the sshd server all users' .ssh/authorized_keys *** Info: files must have appropriate permissions to allow public key *** Info: authentication. (Re-)running ssh-user-config for each user will set *** Info: these permissions correctly. [Similar restrictions apply, for *** Info: instance, for .rhosts files if the rshd server is running, etc]. *** Info: The xinetd service has been installed under the 'cyg_server' *** Info: account. To start the service now, call `net start xinetd' or *** Info: `cygrunsrv -S xinetd'. Otherwise, it will start automatically *** Info: after the next reboot. *** Info: Check /etc/xinetd.conf, /etc/xinetd.d/, and *** Info: /usr/share/doc/Cygwin/xinetd.README before starting the service! Configuration finished. Have fun! |
Przechodzimy do edycji pliku /etc/xinetd.d/tftp
, jeśli mamy zainstalowany edytor nano
możemy to zrobić komendą:
1 |
nano /etc/xinetd.d/tftp |
w pliku tym zmieniamy linię z opcją disable
na no
:
14 |
disable = no |
Jako administrator startujemy usługę:
1 |
cygrunsrv -S xinetd |
No i ostatecznie odblokowujemy porty na firewallu, co również należy zrobić z uprawnieniami administratora:
1 |
netsh advfirewall firewall add rule name=TFTPD description="TFTP daemon" action=allow dir=in protocol=UDP localport=69 |
Syslinux
Ze strony domowej projektu Syslinux ściągamy wersję 4.06. Co prawda w chwili pisania tego artykułu najnowsza dostępna wersja to 5.01, ale zarówno 5.01 jak i 5.00 sprawiały u mnie problemy, np. nie były w stanie wczytać antywirusa Windows Defender Offline. Rozpakowujemy archiwum i do głównego katalogu naszego serwera TFTP, którym domyślnie w Cygwinie jest /var/lib/tftpboot
kopiujemy 4 pliki, dla ułatwienia podaję poniżej ich lokalizację w archiwum:
gpxe/gpxelinux.0
com32/menu/vesamenu.c32
memdisk/memdisk
com32/chain/chain.c32
Jeśli skopiowaliśmy te pliki z systemu plików Windowsa musimy zadbać o prawidłowe prawa dostępu do plików i katalogów w /var/lib/tftpboot
:
1 2 3 |
cd /var/lib/tftpboot find . -type f -exec chmod 0644 {} \; find . -type d -exec chmod 0755 {} \; |
NFS Server
Teraz zainstalujemy serwer NFS, w instalatorze wybieramy pakiet:
- Net -> nfs-server.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
$ nfs-server-config This script sets up a default configuration for running an NFS server under Cygwin. As part of this setup, the script will do the following: 1) Create a user account to run the services under. [OPTIONAL] 2) Install portmap, mountd, and nfsd as Windows services. 3) Create a sample exports file. 4) Create a sample uid/gid mapping file. After installing, please read the nfs-server README for Cygwin: /usr/share/doc/Cygwin/nfs-server-2.3-*.README This document contains notes on installation and documents known problems and workarounds with the NFS server; ex: - ISSUE : Recommend using ntsec - ISSUE : Daemons are single-threaded - ISSUE : Daemons require 'impersonate logged on user' right. - ISSUE : Daemons cannot re-export mapped network drives - ISSUE : Daemons expect 'nobody' or 'Guest' as anonymous user - ISSUE : Portmap service fails to start - ISSUE : Cannot export Windows directories not under Cygwin root - ISSUE : Considerations when mapping UIDs/GIDs Do you want to continue? (yes/no) yes Checking for other Unix environments on this system ... Good! There doesn't seem to be any other Unix environments installed. You can choose to install the services so that they run under the local system account, or under a separate user account. Which option you should choose depends on which version of Windows you are running: Windows 2000 : You may run nfsd under either a local system account or a separate user account. You _probably_ want to run under the local system account. Windows XP : You _must_ run nfsd under a separate user account. If you choose to run nfsd under a separate user account, you will be prompted for a user name and password. If the user name you supply does not exist, it will be created. Do you want to run nfsd under a separate user account? (yes/no) yes User name : cyg_server Password : ********** User cyg_server already exists Assigning required privileges to user cyg_server ... Adding user cyg_server to /etc/passwd ... Ensuring user cyg_server has write persmissions in /var/log ... Installing portmap service ... Installing mountd service ... Installing nfsd service ... Creating sample /etc/exports file ... Creating sample /etc/nfs/server.map file ... Could not find user 'Guest' in /etc/passwd In order for mountd and nfsd to function properly, you should add the user 'Guest' to your /etc/passwd, for example: mkpasswd.exe -l -u Guest >> /etc/passwd mount(1) command did not return SYSTEM mount(s). It looks like you have installed Cygwin for a single user. Cygwin mount points will not be available to programs installed as Windows services. This will keep portmap, mountd, and nfsd from running as Windows services. In order for portmap, mountd and nfsd to function properly, you should establish global mount points using the /bin/mount utility. You can change user-specific Cygwin mount points to global mount points using the following command: eval `mount -m | sed -e 's/ -u / -s /g' -e 's/$/;/'` You current mount -m listing is: none /cygdrive cygdrive binary,posix=0,user 0 0 |
Edytujemy plik /etc/hosts.allow
:
1 |
nano /etc/hosts.allow |
ustalając mu następującą zawartość:
1 2 |
portmap: ALL mountd: 192.168.1.0/255.255.255.0 |
następnie edytujemy plik /etc/exports
:
1 |
nano /etc/exports |
No i jako administrator startujemy usługi:
1 2 3 |
cygrunsrv -S portmap cygrunsrv -S nfsd cygrunsrv -S mountd |
No i ostatecznie odblokowujemy porty na firewallu, co również należy zrobić z uprawnieniami administratora:
1 2 3 4 |
netsh advfirewall firewall add rule name=NFSD-TCP description="NFS server daemon TCP" action=allow dir=in protocol=TCP localport=2049 netsh advfirewall firewall add rule name=NFSD-UDP description="NFS server daemon UDP" action=allow dir=in protocol=UDP localport=2049 netsh advfirewall firewall add rule name=SunRPC-TCP description="SUN Remote Procedure Call TCP" action=allow dir=in protocol=TCP localport=111 netsh advfirewall firewall add rule name=SunRPC-UDP description="SUN Remote Procedure Call UDP" action=allow dir=in protocol=UDP localport=111 |
Spis treści artykułów o PXE / gPXE
Tematykę bootowania z sieci lokalnej opisuję w serii 5 artykułów, zapraszam do zapoznania się z pozostałymi częściami: