A day with FreeBSD (via qemu, that is)

In process of testing Fuse perl bindings before new release (which will support threading and hopefully FreeBSD) I need FreeBSD machine for testing. I opted to install it using qemu, without any graphic output (so that I can run it using ssh on remote machine).

It's a easy task, once you know how to do it. I used FreeBSD 6.0-RELEASE and installed it to disk image (using normal qemu with graphics). Then, I modified /boot/loader.conf to include:

This will redirect output from console to serial port. Nice, we don't need graphic any more!
Well, not so fast. We also need to install ssh server (so that we can actually login after boot).

Now, let's start qemu without graphic support and with redirect from localhost:4222 to ssh on our new FreeBSD machine:

qemu -hda hda -m 128 -net user -net nic -redir tcp:4222: -nographic -serial stdio -monitor stdio
You will get console output in terminal from which you started qemu (as well as boot messages) and after boot you can ssh -p 4222 localhost to login.

Quick edit of .ssh/config resulted in:

Host freebsd
	Hostname localhost
	HostKeyAlias freebsd.lan
	port 4222
Now, if you use ssh-copy-id logging in becomes simple ssh freebsd.

If you want to have semi-functional serial console, you can also change /etc/ttys line for serial terminal to:

ttyd0   "/usr/libexec/getty std.9600"   dialup  on secure
In line above dialup is terminal type. I tried cons25 and xterm but I still couldn't get vi to work well, so I prefer using ssh to connect to FreeBSD in qemu.