Changeset View
Changeset View
Standalone View
Standalone View
head/en_US.ISO8859-1/books/handbook/virtualization/chapter.xml
Show First 20 Lines • Show All 1,314 Lines • ▼ Show 20 Lines | <para>Starting with &os; 10.0-RELEASE, the | ||||
virtualization offload features of newer | virtualization offload features of newer | ||||
<acronym>CPU</acronym>s, instead of translating instructions and | <acronym>CPU</acronym>s, instead of translating instructions and | ||||
manually managing memory mappings.</para> | manually managing memory mappings.</para> | ||||
<para>Due to the design of <application>bhyve</application>, it | <para>Due to the design of <application>bhyve</application>, it | ||||
requires a computer with a newer processor that supports &intel; | requires a computer with a newer processor that supports &intel; | ||||
Extended Page Tables (<acronym>EPT</acronym>) or &amd; Rapid | Extended Page Tables (<acronym>EPT</acronym>) or &amd; Rapid | ||||
Virtualization Indexing (<acronym>RVI</acronym>), also known as | Virtualization Indexing (<acronym>RVI</acronym>), also known as | ||||
Nested Page Tables (<acronym>NPT</acronym>). Most newer | Nested Page Tables (<acronym>NPT</acronym>). In addition, to | ||||
processors, specifically the &intel; &core; i3/i5/i7 and | host &linux; guests, or &os; guests with more than one | ||||
&intel; &xeon; E3/E5/E7, support this feature. For a | <acronym>vCPU</acronym>, <acronym>VMX</acronym> unrestricted | ||||
complete list of &intel; processors that support | mode support (<acronym>UG</acronym>) is also required. Most | ||||
<acronym>EPT</acronym>, refer to <link | newer processors, specifically the &intel; &core; | ||||
xlink:href="http://ark.intel.com/search/advanced?s=t&ExtendedPageTables=true">http://ark.intel.com/search/advanced?s=t&ExtendedPageTables=true</link>. | i3/i5/i7 and &intel; &xeon; E3/E5/E7, support these | ||||
<acronym>RVI</acronym> is found on the 3rd generation and later | features. <acronym>UG</acronym> support was introduced with | ||||
of the &amd.opteron; (Barcelona) processors. The easiest way to | Intel's Westmere micro-architecture. For a complete list of | ||||
check for support of <acronym>EPT</acronym> or | &intel; processors that support <acronym>EPT</acronym>, refer | ||||
<acronym>RVI</acronym> is to look for the | to <link xlink:href="http://ark.intel.com/search/advanced?s=t&ExtendedPageTables=true"/>. | ||||
<literal>POPCNT</literal> processor feature flag on the | <acronym>RVI</acronym> is found on the third generation and | ||||
<literal>Features2</literal> line in <command>dmesg</command> or | later of the &amd.opteron; (Barcelona) processors. The easiest | ||||
<filename>/var/run/dmesg.boot</filename>.</para> | way to tell if a processor will support | ||||
<application>bhyve</application> is to run | |||||
<command>dmesg</command> or look in | |||||
<filename>/var/run/dmesg.boot</filename> for | |||||
the <literal>POPCNT</literal> processor feature flag on the | |||||
<literal>Features2</literal> line and <literal>EPT</literal> and | |||||
<literal>UG</literal> on the <literal>VT-x</literal> line.</para> | |||||
<sect2 xml:id="virtualization-bhyve-prep"> | <sect2 xml:id="virtualization-bhyve-prep"> | ||||
<title>Preparing the Host</title> | <title>Preparing the Host</title> | ||||
<para>The first step to creating a virtual machine in | <para>The first step to creating a virtual machine in | ||||
<application>bhyve</application> is configuring the host | <application>bhyve</application> is configuring the host | ||||
system. First, load the <application>bhyve</application> | system. First, load the <application>bhyve</application> | ||||
kernel module:</para> | kernel module:</para> | ||||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | FreeBSD-10.0-RELEASE-amd64-bootonly.iso 100% of 209 MB 570 kBps 06m17s</screen> | ||||
indicates which disk image to use, <option>-i</option> tells | indicates which disk image to use, <option>-i</option> tells | ||||
<application>bhyve</application> to boot from the | <application>bhyve</application> to boot from the | ||||
<acronym>CD</acronym> image instead of the disk, and | <acronym>CD</acronym> image instead of the disk, and | ||||
<option>-I</option> defines which <acronym>CD</acronym> image | <option>-I</option> defines which <acronym>CD</acronym> image | ||||
to use. The last parameter is the name of the virtual | to use. The last parameter is the name of the virtual | ||||
machine, used to track the running machines. This example | machine, used to track the running machines. This example | ||||
starts the virtual machine in installation mode:</para> | starts the virtual machine in installation mode:</para> | ||||
<screen>&prompt.root; <userinput>sh /usr/share/examples/bhyve/vmrun.sh -c <replaceable>4</replaceable> -m <replaceable>1024M</replaceable> -t tap0 -d <replaceable>guest.img</replaceable> -i -I <replaceable>FreeBSD-10.0-RELEASE-amd64-bootonly.iso</replaceable> <replaceable>guestname</replaceable></userinput></screen> | <screen>&prompt.root; <userinput>sh /usr/share/examples/bhyve/vmrun.sh -c <replaceable>4</replaceable> -m <replaceable>1024M</replaceable> -t <replaceable>tap0</replaceable> -d <replaceable>guest.img</replaceable> -i -I <replaceable>FreeBSD-10.0-RELEASE-amd64-bootonly.iso</replaceable> <replaceable>guestname</replaceable></userinput></screen> | ||||
<para>The virtual machine will boot and start the installer. | <para>The virtual machine will boot and start the installer. | ||||
After installing a system in the virtual machine, when the | After installing a system in the virtual machine, when the | ||||
system asks about dropping in to a shell at the end of the | system asks about dropping in to a shell at the end of the | ||||
installation, choose <guibutton>Yes</guibutton>. A small | installation, choose <guibutton>Yes</guibutton>. A small | ||||
change needs to be made to make the system start with a serial | change needs to be made to make the system start with a serial | ||||
console. Edit <filename>/etc/ttys</filename> and replace the | console. Edit <filename>/etc/ttys</filename> and replace the | ||||
existing <literal>ttyu0</literal> line with:</para> | existing <literal>ttyu0</literal> line with:</para> | ||||
<programlisting>ttyu0 "/usr/libexec/getty 3wire" xterm on secure</programlisting> | <programlisting>ttyu0 "/usr/libexec/getty 3wire" xterm on secure</programlisting> | ||||
<note><para>Beginning with &os; 9.3-RELEASE and | <note><para>Beginning with &os; 9.3-RELEASE and | ||||
10.1-RELEASE the console is configured | 10.1-RELEASE the console is configured | ||||
automatically.</para></note> | automatically.</para></note> | ||||
<para>Reboot the virtual machine. While rebooting the virtual | <para>Reboot the virtual machine. While rebooting the virtual | ||||
machine causes <application>bhyve</application> to exit, the | machine causes <application>bhyve</application> to exit, the | ||||
<filename>vmrun.sh</filename> script runs | <filename>vmrun.sh</filename> script runs | ||||
<command>bhyve</command> in a loop and will automatically | <command>bhyve</command> in a loop and will automatically | ||||
restart it. When this happens, choose the reboot option from | restart it. When this happens, choose the reboot option from | ||||
the boot loader menu in order to escape the loop. Now the | the boot loader menu in order to escape the loop. Now the | ||||
guest can be started from the virtual disk:</para> | guest can be started from the virtual disk:</para> | ||||
<screen>&prompt.root; <userinput>sh /usr/share/examples/bhyve/vmrun.sh -c <replaceable>4</replaceable> -m <replaceable>1024M</replaceable> -t tap0 -d <replaceable>guest.img</replaceable> <replaceable>guestname</replaceable></userinput></screen> | <screen>&prompt.root; <userinput>sh /usr/share/examples/bhyve/vmrun.sh -c <replaceable>4</replaceable> -m <replaceable>1024M</replaceable> -t <replaceable>tap0</replaceable> -d <replaceable>guest.img</replaceable> <replaceable>guestname</replaceable></userinput></screen> | ||||
</sect2> | </sect2> | ||||
<sect2 xml:id="virtualization-bhyve-linux"> | <sect2 xml:id="virtualization-bhyve-linux"> | ||||
<title>Creating a &linux; Guest</title> | <title>Creating a &linux; Guest</title> | ||||
<para>In order to boot operating systems other than &os;, the | <para>In order to boot operating systems other than &os;, the | ||||
<package>sysutils/grub2-bhyve</package> port must be first | <package>sysutils/grub2-bhyve</package> port must be first | ||||
installed.</para> | installed.</para> | ||||
Show All 34 Lines | |||||
splash.jpg TRANS.TBL vesamenu.c32 vmlinuz | splash.jpg TRANS.TBL vesamenu.c32 vmlinuz | ||||
grub> <userinput>linux (cd0)/isolinux/vmlinuz</userinput> | grub> <userinput>linux (cd0)/isolinux/vmlinuz</userinput> | ||||
grub> <userinput>initrd (cd0)/isolinux/initrd.img</userinput> | grub> <userinput>initrd (cd0)/isolinux/initrd.img</userinput> | ||||
grub> <userinput>boot</userinput></screen> | grub> <userinput>boot</userinput></screen> | ||||
<para>Now that the &linux; kernel is loaded, the guest can be | <para>Now that the &linux; kernel is loaded, the guest can be | ||||
started:</para> | started:</para> | ||||
<screen>&prompt.root; <userinput>bhyve -AI -H -P -s 0:0,hostbridge -s 1:0,lpc -s 2:0,virtio-net,tap1 -s 3:0,virtio-blk,./linux.img \ | <screen>&prompt.root; <userinput>bhyve -A -H -P -s 0:0,hostbridge -s 1:0,lpc -s 2:0,virtio-net,<replaceable>tap1</replaceable> -s 3:0,virtio-blk,<replaceable>./linux.img</replaceable> \ | ||||
-s 4:0,ahci-cd,./somelinux.iso -l com1,stdio -c <replaceable>4</replaceable> -m <replaceable>1024M</replaceable> <replaceable>linuxguest</replaceable></userinput></screen> | -s 4:0,ahci-cd,<replaceable>./somelinux.iso</replaceable> -l com1,stdio -c <replaceable>4</replaceable> -m <replaceable>1024M</replaceable> <replaceable>linuxguest</replaceable></userinput></screen> | ||||
<para>The system will boot and start the installer. After | <para>The system will boot and start the installer. After | ||||
installing a system in the virtual machine, reboot the virtual | installing a system in the virtual machine, reboot the virtual | ||||
machine. This will cause <application>bhyve</application> to | machine. This will cause <application>bhyve</application> to | ||||
exit. The instance of the virtual machine needs to be | exit. The instance of the virtual machine needs to be | ||||
destroyed before it can be started again:</para> | destroyed before it can be started again:</para> | ||||
<screen>&prompt.root; <userinput>bhyvectl --destroy --vm=<replaceable>linuxguest</replaceable></userinput></screen> | <screen>&prompt.root; <userinput>bhyvectl --destroy --vm=<replaceable>linuxguest</replaceable></userinput></screen> | ||||
Show All 10 Lines | |||||
86_64 symvers-2.6.32-431.el6.x86_64.gz vmlinuz-2.6.32-431.el6.x86_64 | 86_64 symvers-2.6.32-431.el6.x86_64.gz vmlinuz-2.6.32-431.el6.x86_64 | ||||
initramfs-2.6.32-431.el6.x86_64.img | initramfs-2.6.32-431.el6.x86_64.img | ||||
grub> <userinput>linux (hd0,msdos1)/vmlinuz-2.6.32-431.el6.x86_64 root=/dev/mapper/VolGroup-lv_root</userinput> | grub> <userinput>linux (hd0,msdos1)/vmlinuz-2.6.32-431.el6.x86_64 root=/dev/mapper/VolGroup-lv_root</userinput> | ||||
grub> <userinput>initrd (hd0,msdos1)/initramfs-2.6.32-431.el6.x86_64.img</userinput> | grub> <userinput>initrd (hd0,msdos1)/initramfs-2.6.32-431.el6.x86_64.img</userinput> | ||||
grub> <userinput>boot</userinput></screen> | grub> <userinput>boot</userinput></screen> | ||||
<para>Boot the virtual machine:</para> | <para>Boot the virtual machine:</para> | ||||
<screen>&prompt.root; <userinput>bhyve -AI -H -P -s 0:0,hostbridge -s 1:0,lpc -s 2:0,virtio-net,tap1 \ | <screen>&prompt.root; <userinput>bhyve -A -H -P -s 0:0,hostbridge -s 1:0,lpc -s 2:0,virtio-net,<replaceable>tap1</replaceable> \ | ||||
-s 3:0,virtio-blk,./linux.img -l com1,stdio -c <replaceable>4</replaceable> -m <replaceable>1024M</replaceable> <replaceable>linuxguest</replaceable></userinput></screen> | -s 3:0,virtio-blk,<replaceable>./linux.img</replaceable> -l com1,stdio -c <replaceable>4</replaceable> -m <replaceable>1024M</replaceable> <replaceable>linuxguest</replaceable></userinput></screen> | ||||
<para>&linux; will now boot in the virtual machine and | <para>&linux; will now boot in the virtual machine and | ||||
eventually present you with the login prompt. Login and use | eventually present you with the login prompt. Login and use | ||||
the virtual machine. When you are finished, reboot the | the virtual machine. When you are finished, reboot the | ||||
virtual machine to exit <application>bhyve</application>. | virtual machine to exit <application>bhyve</application>. | ||||
Destroy the virtual machine instance:</para> | Destroy the virtual machine instance:</para> | ||||
<screen>&prompt.root; <userinput>bhyvectl --destroy --vm=<replaceable>linuxguest</replaceable></userinput></screen> | <screen>&prompt.root; <userinput>bhyvectl --destroy --vm=<replaceable>linuxguest</replaceable></userinput></screen> | ||||
</sect2> | </sect2> | ||||
<sect2 xml:id="virtualization-bhyve-zfs"> | |||||
<title>Using <acronym>ZFS</acronym> with | |||||
<application>bhyve</application> Guests</title> | |||||
<para>If <acronym>ZFS</acronym> is available on the host | |||||
machine, using <acronym>ZFS</acronym> volumes | |||||
instead of disk image files can provide significant | |||||
performance benefits for the guest <acronym>VMs</acronym>. A | |||||
<acronym>ZFS</acronym> volume can be created by:</para> | |||||
<screen>&prompt.root; <userinput>zfs create -V<replaceable>16G</replaceable> -o volmode=dev <replaceable>zroot/linuxdisk0</replaceable></userinput></screen> | |||||
<para>When starting the <acronym>VM</acronym>, specify the | |||||
<acronym>ZFS</acronym> volume as the disk drive:</para> | |||||
<screen>&prompt.root; <userinput>bhyve -A -H -P -s 0:0,hostbridge -s 1:0,lpc -s 2:0,virtio-net,<replaceable>tap1</replaceable> -s3:0,virtio-blk,<replaceable>/dev/zvol/zroot/linuxdisk0</replaceable> \ | |||||
-l com1,<replaceable>stdio</replaceable> -c <replaceable>4</replaceable> -m <replaceable>1024M</replaceable> <replaceable>linuxguest</replaceable></userinput></screen> | |||||
</sect2> | |||||
<sect2 xml:id="virtualization-bhyve-nmdm"> | <sect2 xml:id="virtualization-bhyve-nmdm"> | ||||
<title>Virtual Machine Consoles</title> | <title>Virtual Machine Consoles</title> | ||||
<para>It is advantageous to wrap the | <para>It is advantageous to wrap the | ||||
<application>bhyve</application> console in a session | <application>bhyve</application> console in a session | ||||
management tool such as <package>sysutils/tmux</package> or | management tool such as <package>sysutils/tmux</package> or | ||||
<package>sysutils/screen</package> in order to detach and | <package>sysutils/screen</package> in order to detach and | ||||
reattach to the console. It is also possible to have the | reattach to the console. It is also possible to have the | ||||
console of <application>bhyve</application> be a null modem | console of <application>bhyve</application> be a null modem | ||||
device that can be accessed with <command>cu</command>. To do | device that can be accessed with <command>cu</command>. To do | ||||
this, load the <filename>nmdm</filename> kernel module and | this, load the <filename>nmdm</filename> kernel module and | ||||
replace <option>-l com1,stdio</option> with | replace <option>-l com1,stdio</option> with | ||||
<option>-l com1,/dev/nmdm0A</option>. The | <option>-l com1,/dev/nmdm0A</option>. The | ||||
<filename>/dev/nmdm</filename> devices are created | <filename>/dev/nmdm</filename> devices are created | ||||
automatically as needed, where each is a pair, corresponding | automatically as needed, where each is a pair, corresponding | ||||
to the two ends of the null modem cable | to the two ends of the null modem cable | ||||
(<filename>/dev/nmdm1A</filename> and | (<filename>/dev/nmdm1A</filename> and | ||||
<filename>/dev/nmdm1B</filename>). See &man.nmdm.4; for more | <filename>/dev/nmdm1B</filename>). See &man.nmdm.4; for more | ||||
information.</para> | information.</para> | ||||
<screen>&prompt.root; <userinput>kldload nmdm</userinput> | <screen>&prompt.root; <userinput>kldload nmdm</userinput> | ||||
&prompt.root; <userinput>bhyve -AI -H -P -s 0:0,hostbridge -s 1:0,lpc -s 2:0,virtio-net,tap1 -s 3:0,virtio-blk,./linux.img \ | &prompt.root; <userinput>bhyve -A -H -P -s 0:0,hostbridge -s 1:0,lpc -s 2:0,virtio-net,<replaceable>tap1</replaceable> -s 3:0,virtio-blk,<replaceable>./linux.img</replaceable> \ | ||||
-l com1,<replaceable>/dev/nmdm0A</replaceable> -c <replaceable>4</replaceable> -m <replaceable>1024M</replaceable> <replaceable>linuxguest</replaceable></userinput> | -l com1,<replaceable>/dev/nmdm0A</replaceable> -c <replaceable>4</replaceable> -m <replaceable>1024M</replaceable> <replaceable>linuxguest</replaceable></userinput> | ||||
&prompt.root; <userinput>cu -l /dev/nmdm0B -s 9600</userinput> | &prompt.root; <userinput>cu -l <replaceable>/dev/nmdm0B</replaceable> -s 9600</userinput> | ||||
Connected | Connected | ||||
Ubuntu 13.10 handbook ttyS0 | Ubuntu 13.10 handbook ttyS0 | ||||
handbook login:</screen> | handbook login:</screen> | ||||
</sect2> | </sect2> | ||||
<sect2 xml:id="virtualization-bhyve-managing"> | <sect2 xml:id="virtualization-bhyve-managing"> | ||||
▲ Show 20 Lines • Show All 66 Lines • Show Last 20 Lines |