diff --git a/en_US.ISO8859-1/books/handbook/virtualization/chapter.sgml b/en_US.ISO8859-1/books/handbook/virtualization/chapter.sgml index d514137a49..b504e47f9d 100644 --- a/en_US.ISO8859-1/books/handbook/virtualization/chapter.sgml +++ b/en_US.ISO8859-1/books/handbook/virtualization/chapter.sgml @@ -1,1088 +1,1088 @@ Murray Stokely Contributed by Virtualization Synopsis Virtualization software allows multiple operating systems to run simultaneously on the same computer. Such software systems for PCs often involve a host operating system which runs the virtualization software and supports any number of guest operating systems. After reading this chapter, you will know: The difference between a host operating system and a guest operating system. How to install FreeBSD on an &intel;-based &apple; &macintosh; computer. How to install FreeBSD on Linux with &xen;. How to install FreeBSD on µsoft.windows; with Virtual PC. How to tune a FreeBSD system for best performance under virtualization. Before reading this chapter, you should: Understand the basics of &unix; and FreeBSD (). Know how to install FreeBSD (). Know how to set up your network connection (). Know how to install additional third-party software (). FreeBSD as a Guest OS Parallels on MacOS Parallels Desktop for &mac; is a commercial software product available for &intel; based &apple; &mac; computers running &macos; 10.4.6 or higher. FreeBSD is a fully supported guest operating system. Once Parallels has been installed on &macos; X, the user must configure a virtual machine and then install the desired guest operating system. Installing FreeBSD on Parallels/&macos; X The first step in installing FreeBSD on &macos; X/Parallels is to create a new virtual machine for installing FreeBSD. Select FreeBSD as the Guest OS Type when prompted: And choose a reasonable amount of disk and memory depending on your plans for this virtual FreeBSD instance. 4GB of disk space and 512MB of RAM work well for most uses of FreeBSD under Parallels: Select the type of networking and a network interface: Save and finish the configuration: After your FreeBSD virtual machine has been created, you will need to install FreeBSD on it. This is best done with an official FreeBSD CDROM or with an ISO image downloaded from an official FTP site. When you have the appropriate ISO image on your local &mac; filesystem or a CDROM in your &mac;'s CD drive, click on the disc icon in the bottom right corner of your FreeBSD Parallels window. This will bring up a window that allows you to associate the CDROM drive in your virtual machine with an ISO file on disk or with your real CDROM drive. Once you have made this association with your CDROM source, reboot your FreeBSD virtual machine as normal by clicking the reboot icon. Parallels will reboot with a special BIOS that first checks if you have a CDROM just as a normal BIOS would do. In this case it will find the FreeBSD installation media and begin a normal sysinstall based installation as described in . You may install, but do not attempt to configure X11 at this time. When you have finished the installation, reboot into your newly installed FreeBSD virtual machine. Configuring FreeBSD on &macos; X/Parallels After FreeBSD has been successfully installed on &macos; X with Parallels, there are a number of configuration steps that can be taken to optimize the system for virtualized operation. Set boot loader variables The most important step is to reduce the tunable to reduce the CPU utilization of FreeBSD under the Parallels environment. This is accomplished by adding the following line to /boot/loader.conf: kern.hz=100 Without this setting, an idle FreeBSD Parallels guest OS will use roughly 15% of the CPU of a single processor &imac;. After this change the usage will be closer to a mere 5%. Create a new kernel configuration file You can remove all of the SCSI, FireWire, and USB device drivers. Parallels provides a virtual network adapter used by the &man.ed.4; driver, so all other network devices except for &man.ed.4; and &man.miibus.4; can be removed from the kernel. Setup networking The most basic networking setup involves simply using DHCP to connect your virtual machine to the same local area network as your host &mac;. This can be accomplished by adding ifconfig_ed0="DHCP" to /etc/rc.conf. More advanced networking setups are described in . Fukang Chen (Loader) Contributed by FreeBSD with &xen; on Linux The &xen; hypervisor is an open source paravirtualization product which is now supported by the commercial XenSource company. Guest operating systems are known as domU domains, and the host operating system is known as dom0. The first step in running a virtual FreeBSD instance under Linux is to install &xen; for Linux dom0. The host operating system will be a Slackware Linux distribution. Setup &xen; 3 on Linux dom0 Download &xen; 3.0 from XenSource Download xen-3.0.4_1-src.tgz from . Unpack the tarball &prompt.root; cd xen-3.0.4_1-src &prompt.root; KERNELS="linux-2.6-xen0 linux-2.6-xenU" make world &prompt.root; make install To re-compile the kernel for dom0: &prompt.root; cd xen-3.0.4_1-src/linux-2.6.16.33-xen0 &prompt.root; make menuconfig &prompt.root; make &prompt.root; make install Older version of &xen; may need to specify make ARCH=xen menuconfig Add a menu entry into Grub menu.lst Edit /boot/grub/menu.lst and add the following lines: title Xen-3.0.4 root (hd0,0) kernel /boot/xen-3.0.4-1.gz dom0_mem=262144 module /boot/vmlinuz-2.6.16.33-xen0 root=/dev/hda1 ro Reboot your computer into &xen; First, edit /etc/xen/xend-config.sxp, and add the following line: (network-script 'network-bridge netdev=eth0') Then, we can launch &xen;: &prompt.root; /etc/init.d/xend start &prompt.root; /etc/init.d/xendomains start Our dom0 is running: &prompt.root; xm list Name ID Mem VCPUs State Time(s) Domain-0 0 256 1 r----- 54452.9 FreeBSD 7-CURRENT domU Download the FreeBSD domU kernel for &xen; 3.0 and disk image from http://www.fsmware.com/ kernel-current mdroot-7.0.bz2 xmexample1.bsd Put the configuration file xmexample1.bsd into /etc/xen/ and modify the related entries about where the kernel and the disk image are stored. It should look like the following: kernel = "/opt/kernel-current" memory = 256 name = "freebsd" vif = [ '' ] disk = [ 'file:/opt/mdroot-7.0,hda1,w' ] #on_crash = 'preserve' extra = "boot_verbose" extra += ",boot_single" extra += ",kern.hz=100" extra += ",vfs.root.mountfrom=ufs:/dev/xbd769a" The mdroot-7.0.bz2 file should be uncompressed. Next, the __xen_guest section in kernel-current needs to be altered to add the VIRT_BASE that &xen; 3.0.3 requires: &prompt.root; objcopy kernel-current -R __xen_guest &prompt.root; perl -e 'print "LOADER=generic,GUEST_OS=freebsd,GUEST_VER=7.0,XEN_VER=xen-3.0,BSD_SYMTAB,VIRT_BASE=0xC0000000\x00"' > tmp &prompt.root; objcopy kernel-current --add-section __xen_guest=tmp &prompt.root; objdump -j __xen_guest -s kernel-current kernel-current: file format elf32-i386 Contents of section __xen_guest: 0000 4c4f4144 45523d67 656e6572 69632c47 LOADER=generic,G 0010 55455354 5f4f533d 66726565 6273642c UEST_OS=freebsd, 0020 47554553 545f5645 523d372e 302c5845 GUEST_VER=7.0,XE 0030 4e5f5645 523d7865 6e2d332e 302c4253 N_VER=xen-3.0,BS 0040 445f5359 4d544142 2c564952 545f4241 D_SYMTAB,VIRT_BA 0050 53453d30 78433030 30303030 3000 SE=0xC0000000. We are, now, ready to create and launch our domU: &prompt.root; xm create /etc/xen/xmexample1.bsd -c Using config file "/etc/xen/xmexample1.bsd". Started domain freebsd WARNING: loader(8) metadata is missing! Copyright (c) 1992-2006 The FreeBSD Project. Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994 The Regents of the University of California. All rights reserved. FreeBSD 7.0-CURRENT #113: Wed Jan 4 06:25:43 UTC 2006 kmacy@freebsd7.gateway.2wire.net:/usr/home/kmacy/p4/freebsd7_xen3/src/sys/i386-xen/compile/XENCONF WARNING: DIAGNOSTIC option enabled, expect reduced performance. Xen reported: 1796.927 MHz processor. Timecounter "ixen" frequency 1796927000 Hz quality 0 CPU: Intel(R) Pentium(R) 4 CPU 1.80GHz (1796.93-MHz 686-class CPU) Origin = "GenuineIntel" Id = 0xf29 Stepping = 9 Features=0xbfebfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CLFLUSH, DTS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE> Features2=0x4400<CNTX-ID,<b14>> real memory = 265244672 (252 MB) avail memory = 255963136 (244 MB) xc0: <Xen Console> on motherboard cpu0 on motherboard Timecounters tick every 10.000 msec [XEN] Initialising virtual ethernet driver. xn0: Ethernet address: 00:16:3e:6b:de:3a [XEN] Trying to mount root from ufs:/dev/xbd769a WARNING: / was not properly dismounted Loading configuration files. No suitable dump device was found. Entropy harvesting: interrupts ethernet point_to_point kickstart. Starting file system checks: /dev/xbd769a: 18859 files, 140370 used, 113473 free (10769 frags, 12838 blocks, 4.2% fragmentation) Setting hostname: demo.freebsd.org. lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384 inet6 ::1 prefixlen 128 inet6 fe80::1%lo0 prefixlen 64 scopeid 0x2 inet 127.0.0.1 netmask 0xff000000 Additional routing options:. Mounting NFS file systems:. Starting syslogd. /etc/rc: WARNING: Dump device does not exist. Savecore not run. ELF ldconfig path: /lib /usr/lib /usr/lib/compat /usr/X11R6/lib /usr/local/lib a.out ldconfig path: /usr/lib/aout /usr/lib/compat/aout /usr/X11R6/lib/aout Starting usbd. usb: Kernel module not available: No such file or directory Starting local daemons:. Updating motd. Starting sshd. Initial i386 initialization:. Additional ABI support: linux. Starting cron. Local package initialization:. Additional TCP options:. Starting background file system checks in 60 seconds. Sun Apr 1 02:11:43 UTC 2007 FreeBSD/i386 (demo.freebsd.org) (xc0) login: The domU should run the &os; 7.0-CURRENT kernel: &prompt.root; uname -a FreeBSD demo.freebsd.org 7.0-CURRENT FreeBSD 7.0-CURRENT #113: Wed Jan 4 06:25:43 UTC 2006 kmacy@freebsd7.gateway.2wire.net:/usr/home/kmacy/p4/freebsd7_xen3/src/sys/i386-xen/compile/XENCONF i386 The network can now be configured on the domU. The &os; domU will use a specific interface called xn0: &prompt.root; ifconfig xn0 10.10.10.200 netmask 255.0.0.0 &prompt.root; ifconfig xn0: flags=843<UP,BROADCAST,RUNNING,SIMPLEX> mtu 1500 inet 10.10.10.200 netmask 0xff000000 broadcast 10.255.255.255 ether 00:16:3e:6b:de:3a lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384 inet6 ::1 prefixlen 128 inet6 fe80::1%lo0 prefixlen 64 scopeid 0x2 inet 127.0.0.1 netmask 0xff000000 On dom0 Slackware, some &xen; dependant network interfaces should show up: &prompt.root; ifconfig eth0 Link encap:Ethernet HWaddr 00:07:E9:A0:02:C2 inet addr:10.10.10.130 Bcast:0.0.0.0 Mask:255.0.0.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:815 errors:0 dropped:0 overruns:0 frame:0 TX packets:1400 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:204857 (200.0 KiB) TX bytes:129915 (126.8 KiB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:99 errors:0 dropped:0 overruns:0 frame:0 TX packets:99 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:9744 (9.5 KiB) TX bytes:9744 (9.5 KiB) peth0 Link encap:Ethernet HWaddr FE:FF:FF:FF:FF:FF UP BROADCAST RUNNING NOARP MTU:1500 Metric:1 RX packets:1853349 errors:0 dropped:0 overruns:0 frame:0 TX packets:952923 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:2432115831 (2.2 GiB) TX bytes:86528526 (82.5 MiB) Base address:0xc000 Memory:ef020000-ef040000 vif0.1 Link encap:Ethernet HWaddr FE:FF:FF:FF:FF:FF UP BROADCAST RUNNING NOARP MTU:1500 Metric:1 RX packets:1400 errors:0 dropped:0 overruns:0 frame:0 TX packets:815 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:129915 (126.8 KiB) TX bytes:204857 (200.0 KiB) vif1.0 Link encap:Ethernet HWaddr FE:FF:FF:FF:FF:FF UP BROADCAST RUNNING NOARP MTU:1500 Metric:1 RX packets:3 errors:0 dropped:0 overruns:0 frame:0 TX packets:2 errors:0 dropped:157 overruns:0 carrier:0 collisions:0 txqueuelen:1 RX bytes:140 (140.0 b) TX bytes:158 (158.0 b) xenbr1 Link encap:Ethernet HWaddr FE:FF:FF:FF:FF:FF UP BROADCAST RUNNING NOARP MTU:1500 Metric:1 RX packets:4 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:112 (112.0 b) TX bytes:0 (0.0 b) &prompt.root; brctl show bridge name bridge id STP enabled interfaces xenbr1 8000.feffffffffff no vif0.1 peth0 vif1.0 Virtual PC on &windows; Virtual PC for &windows; is a µsoft; software product available for free download. See system requirements. Once Virtual PC has been installed on µsoft.windows;, the user must configure a virtual machine and then install the desired guest operating system. Installing FreeBSD on Virtual PC/µsoft.windows; The first step in installing FreeBSD on µsoft.windows; /Virtual PC is to create a new virtual machine for installing FreeBSD. Select Create a virtual machine when prompted: And select Other as the Operating system when prompted: Then, choose a reasonable amount of disk and memory depending on your plans for this virtual FreeBSD instance. 4GB of disk space and 512MB of RAM work well for most uses of FreeBSD under Virtual PC: Save and finish the configuration: Select your FreeBSD virtual machine and click Settings, then set the type of networking and a network interface: After your FreeBSD virtual machine has been created, you will need to install FreeBSD on it. This is best done with an official FreeBSD CDROM or with an ISO image downloaded from an official FTP site. When you have the appropriate ISO image on your local &windows; filesystem or a CDROM in your CD drive, double click on your FreeBSD virtual machine to boot. Then, click CD and choose Capture ISO Image... on Virtual PC window. This will bring up a window that allows you to associate the CDROM drive in your virtual machine with an ISO file on disk or with your real CDROM drive. Once you have made this association with your CDROM source, reboot your FreeBSD virtual machine as normal by clicking the Action and Reset. Virtual PC will reboot with a special BIOS that first checks if you have a CDROM just as a normal BIOS would do. In this case it will find the FreeBSD installation media and begin a normal sysinstall based installation as described in . You may install, but do not attempt to configure X11 at this time. When you have finished the installation, remember to eject CDROM or release ISO image. Finally, reboot into your newly installed FreeBSD virtual machine. Configuring FreeBSD on µsoft.windows;/Virtual PC After FreeBSD has been successfully installed on µsoft.windows; with Virtual PC, there are a number of configuration steps that can be taken to optimize the system for virtualized operation. Set boot loader variables The most important step is to reduce the tunable to reduce the CPU utilization of FreeBSD under the Virtual PC environment. This is accomplished by adding the following line to /boot/loader.conf: kern.hz=100 Without this setting, an idle FreeBSD Virtual PC guest OS will use roughly 40% of the CPU of a single processor computer. After this change the usage will be closer to a mere 3%. Create a new kernel configuration file You can remove all of the SCSI, FireWire, and USB device drivers. Virtual PC provides a virtual network adapter used by the &man.de.4; driver, so all other network devices except for &man.de.4; and &man.miibus.4; can be removed from the kernel. Setup networking The most basic networking setup involves simply using DHCP to connect your virtual machine to the same local area network as your host µsoft.windows;. This can be accomplished by adding ifconfig_de0="DHCP" to /etc/rc.conf. More advanced networking setups are described in . - VMWare on MacOS + VMware on MacOS - VMWare Fusion for &mac; is a + VMware Fusion for &mac; is a commercial software product available for &intel; based &apple; &mac; computers running &macos; 10.4.9 or higher. FreeBSD is a fully supported guest operating system. Once - VMWare Fusion has been installed on + VMware Fusion has been installed on &macos; X, the user must configure a virtual machine and then install the desired guest operating system. - Installing FreeBSD on VMWare/&macos; X + Installing FreeBSD on VMware/&macos; X - The first step is to start VMWare Fusion, the Virtual + The first step is to start VMware Fusion, the Virtual Machine Library will load. Click "New" to create the VM: This will load the New Virtual Machine Assistant to help you create the VM, click Continue to proceed: Select Other as the Operating System and FreeBSD or FreeBSD 64-bit, depending on if you want 64-bit support, as the Version when prompted: Choose the Name of the VM Image and the Directory where you would like it saved: Choose the size of the Virtual Hard Disk for the VM: Choose the method you would like to install the VM, either from an ISO image or from a CD: Once you click Finish, the VM will boot: Install &os; like you normally would, or by following the directions in : Once the install is complete you can modify the settings of the VM, such as Memory Usage: The System Hardware settings of the VM cannot be modified while the VM is running. The number of CPUs the VM will have access to: The status of the CD-Rom Device. Normally you can disconnect the CD-Rom/ISO from the VM if you will not be needing it anymore. The last thing to change is how the VM will connect to the Network. If you want to allow connections to the VM from other machines besides the Host, make sure you choose the Connect directly to the physical network (Bridged). Otherwise Share the host's internet connection (NAT) is preferred so that the VM can have access to the Internet, but the network cannot access the VM. After you have finished modifying the settings, boot the newly installed FreeBSD virtual machine. - Configuring FreeBSD on &macos; X/VMWare + Configuring FreeBSD on &macos; X/VMware After FreeBSD has been successfully installed on &macos; - X with VMWare, there are a number + X with VMware, there are a number of configuration steps that can be taken to optimize the system for virtualized operation. Set boot loader variables The most important step is to reduce the tunable to reduce the CPU utilization - of FreeBSD under the VMWare + of FreeBSD under the VMware environment. This is accomplished by adding the following line to /boot/loader.conf: kern.hz=100 Without this setting, an idle FreeBSD - VMWare guest + VMware guest OS will use roughly 15% of the CPU of a single processor &imac;. After this change the usage will be closer to a mere 5%. Create a new kernel configuration file You can remove all of the FireWire, and USB device - drivers. VMWare provides a + drivers. VMware provides a virtual network adapter used by the &man.em.4; driver, so all other network devices except for &man.em.4; can be removed from the kernel. Setup networking The most basic networking setup involves simply using DHCP to connect your virtual machine to the same local area network as your host &mac;. This can be accomplished by adding ifconfig_em0="DHCP" to /etc/rc.conf. More advanced networking setups are described in . FreeBSD as a Host OS For a number of years, &os; was not officially supported as a host OS by any of the available virtualization solutions. Some people were using older and mostly obsolete versions of VMware (like emulators/vmware3), which utilized the &linux; binary compatibility layer. Shortly after the release of &os; 7.2, the Open Source Edition (OSE) of Sun's &virtualbox; appeared in the Ports Collection as a native &os; program. &virtualbox; is an actively developed, complete virtualization package, that is available for most operating systems including &windows;, &macos;, &linux; and &os;. It is equally capable at running &windows; or &unix; like guests. It comes in two flavors, an open source and a proprietary edition. From the user's point of view, perhaps the most important limitation of the OSE is the lack of USB support. Other differences may be found in the Editions page of the &virtualbox; wiki, at . Currently, only the OSE is available for &os;. Installing &virtualbox; &virtualbox; is available as a &os; port in emulators/virtualbox, and may be installed using the following commands: &prompt.root; cd /usr/ports/emulators/virtualbox &prompt.root; make install clean One useful option in the configuration dialog is the GuestAdditions suite of programs. These provide a number of useful features in guest operating systems, like mouse pointer integration (allowing the mouse to be shared between host and guest without the need to press a special keyboard shortcut to switch) and faster video rendering, especially in &windows; guests. The guest additions are available in the Devices menu, after the installation of the guest OS is finished. A few configuration changes are needed before &virtualbox; is started for the first time. The port installs a kernel module in /boot/modules which must be loaded into the running kernel: &prompt.root; kldload vboxdrv To ensure the module always gets loaded after a reboot, add the following line to /boot/loader.conf: vboxdrv_load="YES" &virtualbox; also requires the proc file system to be mounted: &prompt.root; mount -t procfs proc /proc To allow this setting to persist reboots, the following line is needed in /etc/fstab: proc /proc procfs rw 0 0 If an error message similar to the following is observed when &virtualbox; is run from the terminal: VirtualBox: supR3HardenedExecDir: couldn't read "", errno=2 cchLink=-1 The most likely culprit will be the proc file system. Please use the mount command to check whether it is mounted properly. The vboxusers group is created during the installation of &virtualbox;. All users that need access to &virtualbox; will have to be added as members of this group. The pw command may be used to add new members: &prompt.root; pw groupmod vboxusers -m yourusername To launch &virtualbox;, either select the Sun VirtualBox item from your graphic environment's menu, or type the following in a terminal: &prompt.user; VirtualBox For more information on configuring and using &virtualbox;, please visit the official website at . As the &os; port is very recent, it is under heavy development. For the latest information and troubleshooting instructions, please visit the relevant page in the &os; wiki, at . Other Virtualization Options There is ongoing work in getting &xen; to work as a host environment on &os;.