Posted: October 29, 2014 at 8:57 PM
Recently Neel Natu committed work to enable bhyve to run on AMD processors. My main development machine is an AMD A10-5700, so the commit enables me to use bhyve for testing.
EDIT: Anish Gupta did the work that Neel Natu committed. Thanks Anish!
I had previously built images using
mkimg for a CF card for
use in another machine, so being able to build images to use with bhyve
First, you need to make sure that you have a complete source check out along with a completed buildworld and buildkernel. Then follow these steps:
- Install world and distribution into a temporary directory using the
This preps everything with the defaults as necessary.
make installworld DESTDIR=<tmpdir> -DDB_FROM_SRC -DNO_ROOT make distribution DESTDIR=<tmpdir> -DDB_FROM_SRC -DNO_ROOT
- Install a kernel either into a different directory (I do this) or into the same directory above:
make installkernel DESTDIR=<tmpkerndir> -DNO_ROOT KERNCONF=<conf>
- Make a directory with your custom configuration files. The basics
/etc/fstaband you might want
/firstbooton there too. You will also need a
METALOGfile which contains the permissions for the files. This is just a standard
mtreefile, so you could use
mtreeto generate this instead of creating it by hand. The file contents are below.
- Build the ufs image using the
makeroot.shscript in the src tree at
/usr/src/tools/tools/makeroot/makeroot.sh -e <custdir>/METALOG -e <tmpkerndir>/METALOG -p <tmpdir>/etc/master.passwd -s 2g ufs.img root
- Build the disc image:
mkimg -s gpt -b <tmpdir>/boot/pmbr -p freebsd-boot:=<tmpdir>/boot/gptboot -p freebsd-swap::1G -p freebsd-ufs:=ufs.img -o disc.img
- Run the image:
sh /usr/share/examples/bhyve/vmrun.sh -d disc.img vm0
There you have it. Besides running the image, all the other steps can be done as a normal user w/o root access.
EDIT: You also might want to include an
/entropy file (populated with 4k
/dev/random) in your custom directory so that the image has a good
seed for entropy at first boot for things such as sshd key generation.
/dev/vtbd0p3 / ufs rw 1 1
#mtree 2.0 ./etc/rc.conf type=file uname=root gname=wheel mode=0644 ./etc/fstab type=file uname=root gname=wheel mode=0644 ./firstboot type=file uname=root gname=wheel mode=0644