# Install over PXE



## recus (Feb 25, 2011)

Is it possible to boot a computer with PXE and go directly to sysinstall? The documentation I find is only on diskless clients, and demands a lot of work (building own root on a NFS-mount etc).


----------



## wblock@ (Feb 26, 2011)

A boot loader will have to load a memstick or CD image into memory on the target machine.  You'll still have to have a PXE server, with at least TFTP and preferably HTTP for speed.  And of course the target machine has to have enough RAM to hold the image and leave enough free to run the installer.

Syslinux seems to have filename length problems, so I renamed FreeBSD-8.2-RELEASE-i386-bootonly.iso to bootonly.iso.  Otherwise, this just worked for me:

```
label freebsd-install
  menu label FreeBSD Install
  linux memdisk
  initrd http://192.168.1.1/images/freebsd-install/bootonly.iso
  append iso raw
```

Change that initrd line to use tftp if that's all you have.

This was just thrown into the default menu file as shown in PXE Booting Utilities With FreeBSD.


----------



## recus (Feb 28, 2011)

Can this be done without involving Syslinux? I'm able to boot using PXE and fetching the file /boot/pxeboot (as configured in dhcpd) from the server using TFTP. But from there NFS is need, or am I mistaking?


----------



## wblock@ (Feb 28, 2011)

pxeboot(8) says it needs NFS.


----------



## SirDice (Feb 28, 2011)

recus said:
			
		

> Is it possible to boot a computer with PXE and go directly to sysinstall? The documentation I find is only on diskless clients, and demands a lot of work (building own root on a NFS-mount etc).



FreeBSD Jumpstart Guide


----------



## recus (Feb 28, 2011)

SirDice said:
			
		

> FreeBSD Jumpstart Guide



Ok, I wanted to get around the whole compiling of a new kernel and the most in chapter 3 of that link. So I copied the 8.2-install CD into /usr/tftpboot. The whole idea was to just boot over PXE and get *sysinstall* working and installing over network, since the machine doesn't have a CDROM. When booting now I got: 


```
Lookup of /dev for devfs, error: 2
init: not found in path
/sbin/init:/sbin/oinit:/sbin/init.bak:/rescue/init:/stand/sysinstall
```

After some grey hairs I found that telling the loader this made it work: 


```
load /boot/kernel/kernel
load -t mfs_root /boot/mfsroot
set vfs.root.mountfrom="ufs:/dev/md0"
boot
```

But - my goal is to get all this done without having to use NFS. Do you think it's possible?


----------



## SirDice (Feb 28, 2011)

It may be possible if you use the old floppy boot but I'm not sure if that's supplied anymore. The installer itself is able to install from FTP, HTTP etc.

In theory you may be able to PXE boot those install floppies and do the rest of the installation via FTP or HTTP.


----------



## wblock@ (Feb 28, 2011)

recus said:
			
		

> But - my goal is to get all this done without having to use NFS. Do you think it's possible?



Well, yes, did it in post #2.  But if you insist on pxeboot(8), it's going to take some work.  The pxeboot man page says


> The pxeboot bootloader retrieves the kernel, modules, and other files either via NFS over UDP or by TFTP, selectable through compile-time options.



Maybe you can configure it to retrieve an mfsroot image via TFTP.


----------



## jem (Feb 28, 2011)

I've been playing around with setting up FreeBSD PXE booting today as I'm also trying to create a boot environment that runs from RAM and simply presents me with a shell with all the tools available to manually set up a FreeBSD system.  I've had a few stumbles along the way, and have worked out the following:


The PXE ROM in the network card uses tftp to fetch the pxeboot loader.
The pxeboot loader uses NFS to read /boot/loader.rc
loader.rc and its includes tell pxeboto how to load the kernel, modules, mfsroot images etc.  These will all be fetched using NFS also.
By default, the kernel will attempt to mount the same filesystem it was loaded from as its root filesystem.

pxeboot is by default only an NFS client, but you can recompile it to add tftp support instead of NFS.  This might be useful if you want to use an mfsroot, because you obviously can't mount a filesystem using tftp.  See /usr/src/sys/boot/i386/loader/Makefile.


I've managed to get a host netbooting into sysinstall using the same mfsroot filesystem that the official installation media uses, but the Fixit option that I use for manual installs doesn't work as it expects the fixit environment to be on CD/DVD, USB or floppy.

My next step is to look into creating a custom mfsroot that boots to a shell, not to sysinstall.


----------



## recus (Mar 1, 2011)

Just a thought, wouldn't it be in the interest of security to be able to boot this way without NFS?


----------



## jem (Mar 2, 2011)

While continuing to work on this today, I discovered the following document:

http://www.locolomo.org/howto/pxeboot/article.html

This comment stood out:



> The main disadvantage of using tftp to fetch a memory file system is that all clients will fetch the same files, load the same kernel and memory file system, regardless of hardware, version of FreeBSD or the purpose of the client.



This eliminates tftp as a possibility for me, as I'll want to use different kernels and mfsroot images for amd64 and i386 respectively.


On another issue, I was able to find and use an alternative mfsroot image to the standard 'sysinstall' one from the FreeBSD install media.

I used mfsBSD to generate an image suitable for 'dd'ing to a disk, then opened it up with mdconfig+mount and took the mfsroot.gz file out of it.  This one boots into a root shell environment and has all the tools available to set up a system manually.


----------



## wblock@ (Mar 2, 2011)

jem said:
			
		

> This eliminates tftp as a possibility for me, as I'll want to use different kernels and mfsroot images for amd64 and i386 respectively.



pxeboot(8) only looks at the root-path provided by the DHCP server, so yes, you only get that one filesystem.  Being able to provide an alternate path would be nice.  I think some of the Linux loaders use optional DHCP fields for that.


----------



## jem (Mar 3, 2011)

Well, dhcp can always give out a different NFS root-path for each host so no problem there.

By default, when using tftp, the pxeboot loader will only look for /boot/loader.rc, but perhaps the Fourth language in the loader is flexible enough to use logic to determine which kernel file to load after that, basing it on the MAC address of the machine for example?  That information is certainly exposed within the loader environment:


```
OK show
LINES=24
acpi_load=YES
autoboot_delay=NO
boot.netif.gateway=192.168.0.1
boot.netif.hwaddr=08:00:c0:a8:00:52
boot.netif.ip=192.168.0.82
...
kernelname=/boot/kernel/kernel
```

I can't imagine it would be too difficult to make pxeboot search for kernels to load in a similar way to pxelinux, by searching for ever less IP-address specific file names until it finds a match, e.g.


kernel.c0a80052
kernel.c0a800
kernel.c0a8


----------



## wblock@ (Mar 3, 2011)

Using MAC works fine for diskless workstations, but it doesn't give you any runtime choice as to which kernel/filesystem is used.  If pxeboot took an optional parameter, a path to a TFTP directory to boot from, it would be useful.  No idea how hard that would be to implement.


----------



## loop (Mar 4, 2011)

recus said:
			
		

> Is it possible to boot a computer with PXE and go directly to sysinstall? The documentation I find is only on diskless clients, and demands a lot of work (building own root on a NFS-mount etc).



I'm installing 8.2 right now in fact, using this guide.

Still needs NFS though.


----------



## recus (Dec 27, 2011)

Can someone explain to me why NFS is preferred for this operation and not http, ftp or tftp? Would be far more secure and easier to administer.


----------



## wblock@ (Dec 27, 2011)

Possibly because there's built-in support for using NFS, while there isn't anything for using a TFTP, FTP, or HTTP address as a filesystem.  Adding support for that to pxeboot(8) would be really useful.


----------



## recus (Jan 15, 2012)

Got some response I can't figure out while trying to install 9.0-RELEASE over PXE.

```
Trying to mount root from nfs: []... 
fxp0: link state changed to DOWN 
NFS ROOT: 192.168.1.2:/usr/local/pxeboot 
fxp0: link state changed to UP 
Interface fxp0 IP-Address 192.168.1.3 Broadcast 192.168.1.255 
Entropy harvesting: interrupts ethernet point_to_point kickstart. 
Starting file system checks: 
mount_nfs: no <host>:<dirpath> nfs-name 
Mounting root filesystem rw failed, startup aborted 
ERROR: ABORTING BOOT (sending SIGTERM to parent!) 
Jan 15 21:44:45 init: /bin/sh on /etc/rc terminated abnormally, going to singel user mode 
Enter full pathname of shell or RETURN for /bin/sh:
```

Once in the shell I can type ls and df -h and see that the mounted bootonly iso is there over NFS. But what went wrong?


----------



## wblock@ (Jan 16, 2012)

```
mount_nfs: no <host>:<dirpath> nfs-name
```
Network or NFS server problem?


----------



## recus (Jan 16, 2012)

wblock@ said:
			
		

> ```
> mount_nfs: no <host>:<dirpath> nfs-name
> ```
> Network or NFS server problem?



Seems to me to be NFS. Network up, got pxeboot from tftp on same address as NFS. Tried 8.2-RELEASE to eliminate 9.0 issues, but same output.


----------



## pbotanik (Jan 19, 2012)

Good afternoon. Faced with a multiversions Freebsd FreeBSD. Is it possible to install version 8.2 amd64 and 8.2 i386 via pxeboot server do not use NFS server? Perhaps there is another way?


----------



## jhgorse (Jul 11, 2012)

Perhaps consider using iPXE which has builtin support for http, SAN, and so on.
http://ipxe.org/

There are still some caveats regarding the "kernel memdisk" method for booting ISO files. I have only successfully been able to boot an mfsbsd and bootonly ISOs using this method. I presume this has something to do with the setup of the ISO or the lack of correct kernel/initrd/kernel flag arguments within the pxelinux.cfg menu item for the other ISOs.

Does anyone know what kernel file and flags the FreeBSD boot ISO requires (i)pxelinux to us in order to mount the ISO as root?


----------



## balanga (Mar 19, 2016)

wblock@ said:


> A boot loader will have to load a memstick or CD image into memory on the target machine.  You'll still have to have a PXE server, with at least TFTP and preferably HTTP for speed.  And of course the target machine has to have enough RAM to hold the image and leave enough free to run the installer.
> 
> Syslinux seems to have filename length problems, so I renamed FreeBSD-8.2-RELEASE-i386-bootonly.iso to bootonly.iso.  Otherwise, this just worked for me:
> 
> ...



I know this thread is five years old but is the methodology still applicable if I use FreeBSD-10.2-RELEASE-i386-bootonly.iso ?


----------



## wblock@ (Mar 19, 2016)

Probably, yes.  The bootonly images are the easiest to work with, because they download most of the data rather than have it as part of the image.


----------



## balanga (Mar 20, 2016)

It would be great to get this working because it looks fairly staraightforward... I've included the following in my pxelinux.cfg/default


```
label freebsd-install
  menu label FreeBSD Install
  linux memdisk
  initrd http://192.168.1.11/FreeBSD-9.3-RELEASE-i386-bootonly.iso
  append iso raw
```

Retrieval of the image file via http doesn't work with initrd. Don't know if I'm missing something... If I change that line to 
	
	



```
initrd FreeBSD-9.3-RELEASE-i386-bootonly.iso
```
 then it does work - upto a point. The FreeBSD loader works, I get the FreeBSD menu and it starts to boot, I get all the FreeBSD msgs up to this point:-

```
Trying to mount root from cd9660:/dev/iso9660/FREEBSD_INSTALL [ro]...
mountroot: waiting for device /dev/iso9660/FREEBSD_INSTALL ...
Mounting from cd9660:/dev/iso9660/FREEBSD_INSTALL failed with error 19.

Loader variables:
  vfs.root.mountfrom=cd9660:/dev/iso9660/FREEBSD_INSTALL
  vfs.root.mountfrom.options=ro
```

I'd really like to know what I'm doing wrong.


----------



## wblock@ (Mar 20, 2016)

Did you try renaming the image file to have an 8.3 filename?


----------



## balanga (Mar 20, 2016)

wblock@ said:


> Did you try renaming the image file to have an 8.3 filename?



Not sure why it would make a difference since in the second instance FreeBSD loads up and starts to boot but only fails when it tries to mount root. But I did rename the image to FreeBSD.iso, unfortunately without success. I also tried the bootonly image of 10.2 with the same result I would try with 8.2 but it is not available. (Actually just found it so will give it a try)

What I can't figure out is where is it attempting to mountroot from? What is /dev/iso9660/10_2_RELEASE_I386_BO?
Maybe the filename has been truncated which has resulted in the *error 19 *failure.


----------



## wblock@ (Mar 20, 2016)

That is a device label.  Yes, it is truncated, but probably due to the way the image is mounted in memory.


----------



## balanga (Mar 20, 2016)

Just to let you know 8.2 boots up OK and goes straight into Sysinstall...


----------

