Solved True headless install via ssh - how to autostart live os + sshd?

tl;dr: How do you modify the usb installer image so that it automatically boots the live version and executes a script to setup sshd?

I have an embedded powerpc device that came with a debian based custom os. Since sadly debian has dropped powerpc support I am turning elsewhere and determined freeBSD to be the most fitting successor. Now I have never used BSD before, but this seems a good point to start - but since this is nothing like a regular install I have been hitting some walls and like to get some advice.

Problems:
- there is no way that device will support monitor or keyboard
- it does not have a serial port, I think using local wired network is the only option, this probably means some sshd, but I am open to hacky suggestions like a temporary telnet etc. setup
- since the architecture is non-standard, since it features some hardware (AFAIK nothing I could not live without, probably just some custom status LED lights) and since I am new to BSD: I require to test freeBSD if it will support my core use cases (if it boots up at all it probably will)
- architecture is powerpc (not really sure what, not apple; Bubba 2), I do not have another machine with a comparable architecture

How I was going to tackle it:
- set up a live usb stick that opens an sshd at startup - which seems to be surprisingly hard from what I have read so far - looked at mfsbsd a bit, but unsure if this is a trusted source and the way to go, seems to focus on amd64 only
- then I can test hardware and software support without destroying the current system which I am still actively using
- I have tested the usb installer images on a different machine and it seems to me I only need these changes:
- boot automatically in live mode
- run dhclient
- setup sshd
- ... which brings me back to the summarizing question: how to modify the installer image to do this? Others seem to install a system on the stick, not sure if this works across architectures.
- mount the powerpc image on another maching (i386, using a regular dvd live system)
- modify the startup scripts there
- test in vm
- ...

Concrete questions:
1) Is this doable, is there a show stopper I am not seeing? General advice?
2) Which files on the iso do I have to edit?
 
You can definitely install FreeBSD over SSH by modifying the installer image, so this might get you part of what you need. From my notes:
  • Burn the installer IMG to two USB drives. You'll boot from one of them, then mount the other drive and modify the second image. When I did this, I actually booted the installer ISO into a VM, then mounted and modified a USB stick containing the installer IMG.
  • Boot on a machine with a keyboard and monitor.
  • When you reach the blue installer screen, press Esc and login as root.
  • Insert the second USB that contains the installer IMG.
  • Use dmesg to get the drive info (da0 in my case)
  • The USB image will have 4 partitions on it, so try mounting each one until you find the root partition. When I did this, it was p3:
root@:~ # mount /dev/da0p3 /mnt
root@:~ # ls /mnt

  • Find a currently-unused IP address for your network, which you will hard-code into the installer.
  • Use the console to modify the installer image and shutdown:
root@:~ # cd /mnt/etc
root@:/mnt/etc # rm rc.local
root@:/mnt/etc # sed -e 's/ro/rw/' -i "" fstab
root@:/mnt/etc # echo ifconfig_DEFAULT=\"inet 192.168.0.254/24\" >> rc.conf
root@:/mnt/etc # echo sshd_enable=\"YES\" >> rc.conf
root@:/mnt/etc # cd ssh
root@:/mnt/etc/ssh # echo "UseDNS no" >> sshd_config
root@:/mnt/etc/ssh # echo "UsePAM no" >> sshd_config
root@:/mnt/etc/ssh # echo "PasswordAuthentication yes" >> sshd_config
root@:/mnt/etc/ssh # echo "PermitEmptyPasswords yes" >> sshd_config
root@:/mnt/etc/ssh # echo "PermitRootLogin yes" >> sshd_config
root@:/mnt/etc/ssh # cd
root@:~ # umount /mnt
root@:~ # shutdown -p now

  • Insert the modified USB into the target machine, boot, wait for a minute or so, and you should be able to SSH into it as root.
  • Run bsdinstall to install FreeBSD on the target machine.
root@:~ # bsdinstall
  • During installation, you must enable SSHD and create a regular user.
  • Reboot, check the router to get the new IP address, and SSH as the regular user.
 
Thanks, but I need to be sure it really boots before I can even think about installing it - this is why I was hesitant to use mfsBSD in the first place - that and I am too insecure how to cross-build the final installation myself. I will follow Neuberts suggestion (I stumbled across that now dead link before), I just could not get around doing it just yet.
 
I succesfully tested this method with i386 machines, sshd is started and bsdinstall can be called remotely. However, I fail to mount the installation medium for powerpc on a i386 freeBSD - there is just no da0-subentry available for that image after usb stick insertion. I will however create a new thread for this.
 
Back
Top