beta-tester / RPi-PXE-Server

setup a Raspberry Pi as an PXE-Server
307 stars 63 forks source link

Store img files on the USB? #5

Closed HarvsG closed 6 years ago

HarvsG commented 6 years ago

I dont have an SD card big enough to store all the img files, can I store them on the USB instead, if so how?

beta-tester commented 6 years ago

yes, to store all IMG/ISO/... files to an external USB memory Stick or HDD, the best is to format the stick with an ext4 file-system (the entire stick or only a partition). give the file-system the label "PXE-Server" then it should get mounted by the install script automatically. then create a folder to the usb stick and change the install script to use that folder for all the stuff...

e.g. (expecting that you have a virgine Raspbian-Stretch image on your SD card and an empty USB memory stick/HDD on your RPi):

  1. sudo mkfs.ext4 -L PXE-Server /dev/sdX to format the entire sdX with ext4 and giving it the label "PXE-Server" (where sdX the USB drive/partition is).
  2. bash install-pxe-server_pass1.sh will create an /etc/fstab entry for automount the filesystem with label "PXE-Server".
  3. sudo mkdir /media/server/srv to create a folder as destination, where all the download stuff will be stored and populated for PXE boot later on.
  4. in the script "install-pxe-server_pass2.sh" change DST_ROOT=/srv to DST_ROOT=/media/server/srv
  5. bash install-pxe-server_pass2.sh

this should do the job.

if the label of the USB file-system is a different one than "PXE-Server", then you have to add an additional /etc/fstab entry or adjust the existing to mount the file-system automatically at each boot. and you also may have to adjust the DST_ROOT=/srv to where ever your mountpoint is and what ever name your folder there has.

HarvsG commented 6 years ago

Thank you! I did this and had some success! However the 28gb USB filled quite quickly. On further inspection I noticed some img/iso/... Were in both media/sever/backup and media/sever/srv is this why it's filled quickly, and is there a good reason for the duplication, and can I remove it?

I am having issues with UEFI over IPv4 booting. The DHCP etc seems to be working fine but then I get an error immediately.

On an unrelated topic I thought I'd mention a few things

  1. I did this install on a raspberry pi that is also running OpenVPN, PiHole and DNS over HTTPS (I had to manage a few DNSmasq conflicts)
  2. I am running a DNSmasq proxy DHCP server instead, which allows my home router to run the DHCP service with no pxe/tfttp/option 66 configuration (it can't).
beta-tester commented 6 years ago

sorry, i forgot to tell you.

yes, then the data are now stored twice. once to the srv folder and then as backup to the backup folder.

i have that backup option, because of my poor internet speed. so, i only have to download changed images when i start from scratch, and the images i already downloaded before i take from the backup.

you can try to delete the whole backup folder. as soon there is no backup folder available, the script should not backup the images anymore.

UEFI isn't tested, because i still have BIOS only hardware available to test.

PS.: maybe you better open a new issue for UEFI what error message did you got? is the error message from the dhcp/dnsmasq or is it from the kernel you try to boot? and i guess the pxelinux or syslinux arn't Secure Boot compatible.

did you removed the '#' in front of the efi32 and efi64 stuff i comment out? i only left bios stuff uncommented. in the script search for handle_pxe_menu $DST_PXE_EFI32 and handle_pxe_menu $DST_PXE_EFI64, then you see what i mean.

maybe take a look to PXELINUX wiki

what you also can try is to offer the UEFI computer the UEFI compatible boot-manager-file directly (in dnsmasq) instead of offering the pxe-menu file. but then you don't have the choice anymore to select different OS'es for UEFI computers.

HarvsG commented 6 years ago

Moved the (U)EFI discussion to #6

beta-tester commented 6 years ago

is it working from USB stick now, can i close this issue?

HarvsG commented 6 years ago

Yes. I will close the issue. I just deleted the backup file