A few days ago, I have a brilliant idea to build pfsense on a hard drive from within virtualbox and it worked surprisingly easy once I worked out how to get the network interfaces to work with my config.
The setup was something like this; a WD 250GB HDD attached to a SATA to USB bridge with a VMDK placeholder file pointing to the block device. VirtualBox didn’t care, all it had was the VMDK file attached. I don’t know the science behind how it works, just that it does. The VBox machine file needed 5 nics setup because my physical computer it is meant for has that many; a quad nic and the integrated one.
VBoxManage internalcommands createrawvmdk -filename physical_pfsense.vmdk -rawdisk /dev/sdd
Because of the way my router pc arranged it’s numbering of the nics, I have to work in reverse with em4(nic5) being the wan port.
vboxmanage modifyvm "pfsense" --nic5 nat --nictype5 82543GC. For some reason, it’s just how the quad nic numerates it’s ports. The integrated port first, then number from the outside port to the inside. My modem is connected to the inside one followed by the lan. (Could have used a single nic and use the integrated one for lan or wan but I was thinking I’d have isolated physical lans at some point.)
Now the VBox machine got 2GB of RAM and 2 cores to keep things happy (just in case). The first 4 nics were pointed to independent internal networks to avoid any ip collisions set about from my config.
I installed pfsense from the iso, as you do, while paying attention to the partitioning; I didn’t want it to take the whole disk just yet so it got 8GB for now. The flash drive it’s on right now is 8GB but the partition is slightly smaller. I wanted to just copy the partition from the flash drive to the disk with DD but I didn’t think that’d work out too well so I exported the existing config and manually installed it with pfsense’s file editor in the webui then rebooted the vm. I found that the restore function wouldn’t accept my config as a whole so manual it was. I did create a separate package config to install the packages I use and wouldn’t you know it, the shotgun package installer button also didn’t work. smh. It took me a while to work out how to get that to work including manually copying the package files from a backup image of the existing install to the external disk from within a freebsd vmdk install from the freebsd website. (that didn’t work, maybe I missed something. idk)
In the end and from the package manager on the webui, I installed the first package I knew I had and the others just magically appeared in the list for me to reinstall one by one. Kinda annoyed at that but whatever. I got it done.
Because my pfsense box is running on a flash drive, I worry about that drive quitting on me so I needed a more reliable solution. It started with a Sandisk SSD but I guess from me trying out squid and other heavy disk apps, it just couldn’t take it. Then I installed a flash drive that also failed so it’s on it’s second flash drive because I didn’t have a suitable replacement solution at the time. The two failures was just the drives going to read-only mode so at least I was able to save my config. The flash drive just needed a simple disk copy to another one and it was good to go. I couldn’t figure out how to recover from the SSD so I reinstalled and copy the config. Partition size differences and me being new to BSD. Now with cloud backups, restoring should be easier. I need to test that in a VM at some point to get some ideas.
Hopefully this $20 hard drive from Amazon will hold up for a few years or more. I went with solid state thinking it’d be more reliable but apparently the ones I chose just wasn’t suitable for it. If I could justify the cost of Samsung SSDs in a router, I’d probably use them but it’s hard to find one smaller than 250GB nowadays. Pfsense doesn’t need much on it’s own unless I use squid. Oh well, spinning rust it is. It’s even hard to find new small hard drives at decent prices too. Weird. shrug
If this made any sense, great. If not, well, I don’t know what to tell ya. Cheers.
TL;DR: I installed pfsense from within a VM to a physical disk for deployment on bare metal.
UPDATE 8/12: Hard Drive was installed and booted with no problems as if nothing changed. On the plus side, I now have plenty of space to try things without worrying about exceeding writes on flash media and the webui loads and changes faster. :)