{"id":697,"date":"2013-09-15T09:00:58","date_gmt":"2013-09-15T16:00:58","guid":{"rendered":"http:\/\/www.smallersystems.com\/blog\/?p=697"},"modified":"2013-09-15T09:00:58","modified_gmt":"2013-09-15T16:00:58","slug":"create-a-freebsd-9-0-machine-image-under-linux","status":"publish","type":"post","link":"https:\/\/michaelrichmond.net\/blog\/2013\/09\/15\/create-a-freebsd-9-0-machine-image-under-linux\/","title":{"rendered":"Create a FreeBSD 9.0 machine image under Linux"},"content":{"rendered":"<p>This is a guide to building a virtual machine image for KVM that runs FreeBSD with virtio drivers installed.<\/p>\n<h3><strong>Requirements:<\/strong><\/h3>\n<ul>\n<li>Download FreeBSD 9.0 install disk.<\/li>\n<li>Download virtio drivers for FreeBSD 9.0 from <a href=\"http:\/\/people.freebsd.org\/~kuriyama\/virtio\/\">http:\/\/people.freebsd.org\/~kuriyama\/virtio\/<\/a><\/li>\n<\/ul>\n<h3><strong>Notes:<\/strong><\/h3>\n<p>Commands and to be performed under Linux are shown in <span style=\"color: #339966;\">green<\/span>.<br \/>\nCommands and file edits to be performed under the FreeBSD guest OS are shown in <span style=\"color: #800080;\">purple<\/span>.<\/p>\n<h3><b>Create empty disk image (10GB):<\/b><\/h3>\n<ul>\n<li>\u00a0On your Linux host, run the command:<\/li>\n<\/ul>\n<blockquote>\n<pre><span style=\"color: #339966;\">dd if=\/dev\/null of=freebsd-9_0.raw bs=1024 seek=10485760<\/span><\/pre>\n<\/blockquote>\n<h3><b>Boot FreeBSD installer and install:<\/b><\/h3>\n<ul>\n<li>On your Linux host, run the command:<\/li>\n<\/ul>\n<blockquote>\n<pre><span style=\"color: #339966;\">sudo kvm -vnc 0.0.0.0:54 -drive file=freebsd-9_0.raw,if=ide -net nic -net user -cdrom FreeBSD-9.0-RELEASE-amd64-disc1.iso<\/span><\/pre>\n<\/blockquote>\n<ul>\n<li>Connect to the guest OS using a VNC client pointed to port 5954. (5900 + 54 from command above.)<\/li>\n<li>Step through the FreeBSD installer:\n<ul>\n<li>allocate the whole virtual drive to FreeBSD.<\/li>\n<li>Configure networking to use IPv4 and DHCP.<\/li>\n<\/ul>\n<li>Reboot the FreeBSD guest.<\/li>\n<\/ul>\n<p><b>Install Virt IO drivers:<\/b><\/p>\n<ul>\n<li>Download the binary package from <a href=\"http:\/\/people.freebsd.org\/~kuriyama\/virtio\/\">http:\/\/people.freebsd.org\/~kuriyama\/virtio\/<\/a><\/li>\n<li>Install the package by running the command &#8220;<span style=\"color: #800080; font-family: monospace;\">pkg_add virtio-kmod-9-0.239473.tbz<\/span>&#8221; in the guest OS.<\/li>\n<li>Edit <span style=\"color: #800080; font-family: monospace;\">\/boot\/loader.conf<\/span> to add the following lines:<\/li>\n<\/ul>\n<blockquote>\n<pre><span style=\"color: #339966;\">virtio_load=\"YES\"\nvirtio_pci_load=\"YES\"\nvirtio_blk_load=\"YES\"\nif_vtnet_load=\"YES\"<\/span><\/pre>\n<\/blockquote>\n<ul>\n<li>Edit <span style=\"color: #800080; font-family: monospace;\">\/etc\/fstab<\/span> in the guest OS to change the device identifiers to &#8220;<span style=\"color: #800080; font-family: monospace;\">\/dev\/vtbd*<\/span>&#8220;. (The following example shows the original device entries commented out followed by the virtio entries.)<\/li>\n<\/ul>\n<blockquote>\n<pre><span style=\"color: #800080;\"># Device Mountpoint FStype Options Dump Pass#\n<\/span><span style=\"color: #800080;\">#\/dev\/ada0p2 \/ ufs rw 1 1\n<\/span><span style=\"color: #800080;\">#\/dev\/ada0p3 none swap sw 0 0\n<\/span><span style=\"color: #800080;\"> \/dev\/vtbd0p2 \/ ufs rw 1 1\n<\/span><span style=\"color: #800080;\"> \/dev\/vtbd0p3 none swap sw 0 0<\/span><\/pre>\n<\/blockquote>\n<ul>\n<li>Edit <span style=\"color: #800080; font-family: monospace;\">\/etc\/rc.conf<\/span> in the guest OS to add the line shown in bold. (This line configures FreeBSD to use DHCP when bringing up the &#8220;vtnet0&#8221; network interface.):<\/li>\n<\/ul>\n<blockquote>\n<pre><span style=\"color: #800080;\">hostname=\"freebsd-90\"\n<\/span><span style=\"color: #800080;\">ifconfig_re0=\"DHCP\"\n<\/span><span style=\"color: #800080;\"> ifconfig_vtnet0=\"DHCP\"\n<\/span><span style=\"color: #800080;\">sshd_enable=\"YES\"\n<\/span><span style=\"color: #800080;\"># Set dumpdev to \"AUTO\" to enable crash dumps, \"NO\" to disable\n<\/span><span style=\"color: #800080;\">dumpdev=\"NO\"<\/span><\/pre>\n<\/blockquote>\n<ul>\n<li>Power off the guest.<\/li>\n<li>Relaunch using virtio for the virtual hard drive and virtual network adapter using the following KVM command:<\/li>\n<\/ul>\n<blockquote>\n<pre><span style=\"color: #339966;\">sudo kvm -vnc 0.0.0.0:54 -drive file=freebsd-9_0.raw,if=virtio -net nic,model=virtio -net user<\/span><\/pre>\n<\/blockquote>\n<ul>\n<li>Verify correct hard drive and network operation in the guest OS.<\/li>\n<li>If the hard drive and network appear to be working correctly then power off the FreeBSD guest.<\/li>\n<\/ul>\n<h3><b>VirtIO in FreeBSD setup resources:<\/b><\/h3>\n<ul>\n<li><a href=\"http:\/\/people.freebsd.org\/~kuriyama\/virtio\/\">http:\/\/people.freebsd.org\/~kuriyama\/virtio\/<\/a><\/li>\n<li><a href=\"http:\/\/www.area536.com\/projects\/freebsd-as-a-kvm-guest-using-virtio\/\">http:\/\/www.area536.com\/projects\/freebsd-as-a-kvm-guest-using-virtio\/<\/a><\/li>\n<li><a href=\"http:\/\/kdl.nobugware.com\/post\/2011\/10\/14\/freebsd-90-guest-virtio-support-in-KVM\/\">http:\/\/kdl.nobugware.com\/post\/2011\/10\/14\/freebsd-90-guest-virtio-support-in-KVM\/<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>This is a guide to building a virtual machine image for KVM that runs FreeBSD with virtio drivers installed. Requirements: Download FreeBSD 9.0 install disk. Download virtio drivers for FreeBSD 9.0 from http:\/\/people.freebsd.org\/~kuriyama\/virtio\/ Notes: Commands and to be performed under &hellip; <a href=\"https:\/\/michaelrichmond.net\/blog\/2013\/09\/15\/create-a-freebsd-9-0-machine-image-under-linux\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[30,46],"tags":[],"class_list":["post-697","post","type-post","status-publish","format-standard","hentry","category-operating-systems","category-virtualization"],"_links":{"self":[{"href":"https:\/\/michaelrichmond.net\/blog\/wp-json\/wp\/v2\/posts\/697","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/michaelrichmond.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/michaelrichmond.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/michaelrichmond.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/michaelrichmond.net\/blog\/wp-json\/wp\/v2\/comments?post=697"}],"version-history":[{"count":0,"href":"https:\/\/michaelrichmond.net\/blog\/wp-json\/wp\/v2\/posts\/697\/revisions"}],"wp:attachment":[{"href":"https:\/\/michaelrichmond.net\/blog\/wp-json\/wp\/v2\/media?parent=697"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/michaelrichmond.net\/blog\/wp-json\/wp\/v2\/categories?post=697"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/michaelrichmond.net\/blog\/wp-json\/wp\/v2\/tags?post=697"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}