📜 ⬆️ ⬇️

Installing FreeBSD over the network (PXE) from a linux server (dnsmasq + nfs)

There was a need to install FreeBSD on a laptop. Since the laptop is ancient, it does not support booting from a flash drive by usb. There were no blanks at hand either, it was decided to test the installation via PXE (Preboot eXecution Environment). Googling, I found several articles on this topic, but they describe installing linux from a linux server, or FreeBSD from a FreeBSD server. I do not pretend to create any particular method, just posting my instructions for quickly deploying FreeBSD 10.1 over the network.

The theoretical part of the PXE boot is well described in the article: http://xgu.ru/wiki/PXE

So let's get started. We will need: dhcp, tftp, nfs.

A server with Debian 7 installed will act as a server. I have already installed dnsmasq on it, which is both a dhcp and dns server. This is very convenient for a small home network, so as not to lift dhcp and bind separately. In addition, dnsmasq has its own tftp server, so it is ideally suited for our task, as they say - “all in one bottle”. It remains to install the nfs server and configure the whole thing. The PXE bootloader is available in the FreeBSD distribution image.
')
Install the necessary packages:

apt-get install dnsmasq nfs-kernel-server 

We download FreeBSD iso-image from the official site freebsd.org. I used the minimum bootonly image:

 wget ftp://ftp.freebsd.org/pub/FreeBSD/releases/i386/i386/ISO-IMAGES/10.1/FreeBSD-10.1-RELEASE-i386-bootonly.iso 

Mount it:

 mount -o loop FreeBSD-10.1-RELEASE-i386-bootonly.iso /mnt 

Copy all image files to the directory that will be accessible via nfs:

 cp -a /mnt /srv/nfs/freebsd 

Add nfs-ball to / etc / exports

 /srv/nfs/freebsd 192.168.0.0/24(rw,sync,no_subtree_check) 

Restart nfs:

 service nfs-kernel-server restart 


Now it is necessary to correct something:

Let's comment or delete the line in / srv / nfs / freebsd / etc / fstab so that the system does not try to mount the disk (the image is intended for writing to the disc) when booting, and mounted our nfs-ball as the root file system:

 # /dev/iso9660/10_1_RELEASE_I386_BO / cd9660 ro 0 0 

Remove the symbolic link /srv/nfs/freebsd/etc/resolv.conf, which refers to a nonexistent file /srv/nfs/freebsd/tmp/bsdinstall_etc/resolv.conf. In theory, the address of the dns server should have been obtained via dhcp and written to this file by the FreeBSD installer at startup. However, this does not happen: the installer creates an empty file, and if a file has already been created, overwrites it. Therefore, instead of a symlink, we create a new file /srv/nfs/freebsd/etc/resolv.conf and write the address of our dns server into it:

 nameserver 192.168.0.101 

We edit the /etc/dnsmasq.conf file, cite only those options that are required to solve our problem, i.e. dhcp + tftp without dns:

 interface=eth0 #,    dhcp- dhcp-range=192.168.0.200,192.168.0.250,12h #  ip-    dhcp-option=17,/srv/nfs/freebsd/ #   nfs dhcp-boot=/srv/nfs/freebsd/boot/pxeboot #   PXE- enable-tftp #  tftp- tftp-root=/srv/nfs/freebsd/ #  tftp 

Restart dnsmasq:

 service dnsmasq restart 

That's all. Go to the BIOS, select the boot order from the LAN (PXE). The network card loads pxe-loader, then the kernel is copied and started via tftp, the root file system is mounted via nfs, the FreeBSD installer is started, and then the standard FreeBSD installation. Do not forget only to complete the installation to change the boot order in the BIOS to the previous one.

Source: https://habr.com/ru/post/249707/


All Articles