The blog.
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 
 

74 satır
2.9 KiB

  1. ---
  2. title: Building bhyve Images using makefs and mkimg
  3. description: >
  4. this is a test blog post and a sample for things
  5. created: !!timestamp '2014-10-29'
  6. tags:
  7. - bhyve
  8. - FreeBSD
  9. ---
  10. Recently Neel Natu [committed](https://svnweb.freebsd.org/changeset/base/r273375)
  11. work to enable bhyve to run on AMD processors. My main development
  12. machine is an AMD A10-5700, so the commit enables me to use bhyve for
  13. testing.
  14. EDIT: Anish Gupta did the work that Neel Natu commited. Thanks Anish!
  15. I had previously built images using makefs and mkimg for a CF card for
  16. use in another machine, so being able to build images to use with bhyve
  17. makes sense.
  18. First, you need to make sure that you have a complete source check out
  19. along with a completed buildworld and buildkernel. Then follow these steps:
  20. 1. Install world and distribution into a temporary directory using the `NO_ROOT` option:
  21. <pre>```
  22. make installworld DESTDIR=<tmpdir> -DDB_FROM_SRC -DNO_ROOT
  23. make distribution DESTDIR=<tmpdir> -DDB_FROM_SRC -DNO_ROOT
  24. ```</pre>
  25. This preps everything with the defaults as necessary.
  26. 2. Install a kernel either into a different directory (I do this) or into the same directory above:
  27. <pre>```
  28. make installkernel DESTDIR=<tmpkerndir> -DNO_ROOT KERNCONF=<conf>
  29. ```</pre>
  30. 3. Make a directory with your custom configuration files. The basics
  31. are `/etc/rc.conf` and `/etc/fstab` and you might want `/firstboot` on
  32. there too. You will also need a METALOG file which contains the
  33. permissions for the files. This is just a standard mtree file, so
  34. you could use mtree to generate this instead of creating it by hand.
  35. The file contents are below.
  36. 4. Build the ufs image using the `makeroot.sh` script in the src tree at `tools/tools/makeroot/makeroot.sh`:
  37. <pre>```
  38. /usr/src/tools/tools/makeroot/makeroot.sh -e <custdir>/METALOG -e <tmpkerndir>/METALOG -p <tmpdir>/etc/master.passwd -s 2g ufs.img root
  39. ```</pre>
  40. 5. Build the disc image:
  41. <pre>```
  42. 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
  43. ```</pre>
  44. 6. Run the image:
  45. <pre>```
  46. sh /usr/share/examples/bhyve/vmrun.sh -d disc.img vm0
  47. ```</pre>
  48. There you have it. Besides running the image, all the other steps can
  49. be done as a normal user w/o root access.
  50. EDIT: You also might want to include an `/entropy` file (populated with 4k
  51. from `/dev/random`) in your custom directory so that the image has a good
  52. seed for entropy at first boot for things such as sshd key generation.
  53. File contents:
  54. * `/etc/fstab`:
  55. <pre>```
  56. /dev/vtbd0p3 / ufs rw 1 1
  57. ```</pre>
  58. * Custom `METALOG`:
  59. <pre>```
  60. #mtree 2.0
  61. ./etc/rc.conf type=file uname=root gname=wheel mode=0644
  62. ./etc/fstab type=file uname=root gname=wheel mode=0644
  63. ./firstboot type=file uname=root gname=wheel mode=0644
  64. ```</pre>