VMware Guest

From Gentoo Linux Wiki

Jump to: navigation, search

Virtualization TOC


Virtual pc.png

VMware is a software that allows running a virtual operating system as an application in another operating system. It provides a full set of virtual hardware that maps to the physical hardware of the host computer. As an example, VMware allows running Linux Ubuntu as an application in Gentoo Linux. This guide provides a method for creating a new VMware virtual machine running Gentoo.

Contents

[edit] General information

[edit] VMWare Virtual Appliance

Installing Gentoo can be complicated, perhaps even intimidating, to someone who is new to Linux. To get familiar with what Gentoo has to offer, VMware (and other virtualization software) provides a safe and easy environment for experimenting, as you are free to try any new Operating System without interfering with your current setup.

VMware appliances are OS distributions that are already installed and ready to go. You just have to download them and start them with VMware player or workstation. You can search for appliances at http://www.vmware.com/appliances/ .

There is one of Gentoo available for free at http://bagside.com/bagvapp/

Gentoo 2008.0 (Barebones) VMWare Appliance. This is a relatively bare bones install of gentoo. Kernel: 2.6.24-gentoo-r8 Desktop WM: Xfce 4.4.2 Filesystem: ext3 Release date: July 6th 2008 Virtual Disk: 12GB Used Space: 5.7 GB Networking: NAT

Note: This appliance was created on an 64 bit AMD machine.

Warning: VMware does not recommend using a Guest that was created on an Intel processor host later on an AMD processor host

Another Gentoo appliance is now available as a torrent on thepiratebay.org
http://thepiratebay.org/torrent/4817588/VMware_Gentoo_Server_Appliance_2008.0_kernel_2.6.27-r8
OS: Linux Gentoo 2008.0 (Updated March 31 2009) Kernel: 2.6.27-gentoo-r8 Profile: Default Window Manager: Xfce4 Compiled on: Intel Core 2 duo Based on: VMware workstation 6.5.1 build-126130 installed on Linux Gentoo Timezone: Canada/Eastern Character set: en, en_US vmware tools: 7.8.4-126130

Another Gentoo minimal install VM, with growable LVM2 is available at http://www.gentoo-vm.net (Updated: April 14 2009)

[edit] Alternate Guides

For advanced users, if you plan to play with the same Gentoo installation inside a vmware and in native mode, you can have a look at http://communities.vmware.com/thread/44675 . That way, you could be able to choose booting Linux or Windows, and then start the other one within VMware. To do that, you will need to access you disk partitions in raw mode. Really, this is still only for advanced users.

[edit] Installation Procedure

[edit] Reading this How to

This Howto documents installation of Gentoo 2008.0 from the LiveCD on VMware workstation 6.5.1 . By the way, you do not need a license of VMware workstation to do this. VMware workstation come with basic functionnality without a licence and creating a new OS is one of them. It is assumed that you already have VMware worstation up and running. If not, have a look at VMware

[edit] Getting the Live CD image

First you need to get the Live CD ISO image of gentoo. You can get the latest version from

http://bouncer.gentoo.org/fetch/gentoo-2008.0-livecd/x86/

[edit] Preparing Virtual Machine

Now what you have to do is to create a new virtual machine. VMware makes this an easy process. You only have to follow the steps in New Virtual Machine Wizard (Home tab|Create a New Virtual Machine). Here is a summary of the options used to create the virtual machine for this guide. For any options not shown here, their default values were used.

  • Virtual machine configuration: Custom
  • Hardware compatibility (Worksation 6.5 to get the USB hotplug support)
  • Install OS from ISO (Select you gentoo live disk ISO image file)
  • Guest operating system: Linux; Version: Other Linux 2.6.x kernel
  • Virtual machine name: Gentoo Linux; Location: (your choice)
  • Number of pocessors: Select what you want.
  • Memory: Your choice for performance (current Gentoo minimum is 64 megabytes for minimal CD, 128 megabytes for live) I set 512 MB just to be safe
  • Network connection:
    • Use NAT networking if you do not need your virtual machine to act as a server on your network.
    • Use Bridged networking if you'd like your virtual machine to have a distinct IP address on your network. You will need to enable DHCP on your network (though not necessarily at your host).
  • I/O adapter types / SCSI Adapters: LSI Logic
  • Disk: Create a new virtual disk
  • Virtual Disk Type: SCSI
  • Disk capacity / Disk size (GB):
    • Your choice (current Gentoo minimum is 1.5 gigabytes plus 256 megabytes swap space). I set it to 40 GB, and I dont allocate the disk space.
    • Check to Allocate all disk space now if you want all the disk space to be pre-allocated. This can enhance performance.
    • Check Split virtual disks if you plan to move you virtual machine around.
  • Give the file a name. I suggest removing white spaces, it will make you life easier later.

[edit] Installing Gentoo Linux

Now you need to power on you virtual machine. If you have a VMware workstation licence, it will have started automatically. If you dont, browse to you .vmx file and start it with VMware player. If you are using the player, you will get a message saying that you cannot take ownership of the virtual machine. Go in the virtual machine folder and delete the .lck subfolder. Then restart the virtual machine.

Now, you just follow the instructions in the Gentoo Handbook the same way you would install Gentoo normally. Here we outlined the parts, to which you need to pay special attention. Please note that, since VMWare uses SCSI-emulation for the hard drive, the name of your hard drive will be /dev/sr0 rather than /dev/hda.

Since there is no partition on the virtual disk yet, your virtual machine should automatically boot from the CD-ROM drive. Once the boot screen shows up prompting for kernel and boot options, press enter for default boot.

If you are running in bridged mode with and you need to set a static IP on the host computer you will need to run

net-setup eth0

at the command line in order to get networking functionality.

[edit] The build environment

File: /etc/make.conf
# VMware emulates an Intel Core 2 Duo
CFLAGS=”-O2 -march=prescott -pipe”
CXXFLAGS="-O2 -march=prescott -pipe"
CHOST=”i686-pc-linux-gnu”

# For a dual core, set to -j3
MAKEOPTS="-j2"

ALSA_CARDS="ens1371"

VIDEO_CARDS="vmware vesa vga"

INPUT_DEVICES="evdev keyboard mouse vmmouse"

LINGUAS="en en_US"

PORTDIR_OVERLAY="/usr/local/portage"

USE="acpi alsa dbus hal X xfce -ipv6"

[edit] Kernel options

If you want to be very sure about exactly what drives you need the best way is to use some built-in utilities. While in the Gentoo setup chroot press Alt-F2 to switch to VC2 and type lspci. That command will tell you the particular devices VMWare is using. Type lsmod to be very sure because it will tell you what modules the liveCD used to boot up. The kernel settings lower were found with this method.

You can also refer to this Gentoo guest kernel configuration file for VMware Fusion as a good starting point. It has been tested as a desktop on Fusion 2.0.5 using 64-bit Gentoo Linux. Most of the unnecessary options have been removed to keep the kernel lean.

You need loadable modules to load VMware modules

BEWARE: A few of the suggestions made here make no sense, at least with VMware WS 7. Suggestion: Do "lspci" in a separate virtual terminal to make it easy to switch back and forth. For a few of the listed categories it will be easy to find corresponding drivers for the listed hardware in "menuconfig." You should carefully consider at least enabling the drivers corresponding to the output of "lspci" in addition to the suggestions below.

Linux Kernel Configuration: VMware tools configuration
Loadable module support  --->
  [*] Enable loadable module support --->
  [*]   Module unloading


Linux Kernel Configuration: Intel PCI/ISA Bridge
Bus options (PCI etc.) --->
  [*] PCI Support
  [*] ISA Support
  [*]   EISA support
  <*> Support for PCI Hotplug
      Support for PCI Hotplug --->
          <*> SHPC PCI Hotplug driver


Linux Kernel Configuration: IEEE 1394
Device Drivers --->
  IEEE 1394 (Firewire) support --->
      <*> Stable Firewire stack
      <*>   OHCI-1394 controllers
      <*>   Storage devices (SBP-2 protocol)


Linux Kernel Configuration: Parallel port
Device Drivers --->
   <*> Parallel port support  --->
       <*> PC-style hardware


Linux Kernel Configuration: Parallel ATA
Device Drivers --->
   <*> Serial ATA (prod) and Parallel ATA (experimental) drivers  ---> 
   <*>   PCMCIA PATA support


Linux Kernel Configuration: I2C
Device Drivers --->
   <*> I2C Support --->
   I2C Hardware Bus support --->
   <*>   Intel PIIX4 and compatible (ATI/Serverworks/Broadcom/SMSC)


Linux Kernel Configuration: Backplane
Device Drivers --->
   Sonics Silicon Backplane  --->
   <*>   Sonics Silicon Backplane support


Linux Kernel Configuration: LSI Logic SCSI adapter
Device Drivers  --->
   [*]  Fusion MPT device support  --->
         <*> Fusion MPT ScsiHost drivers for SPI
         <*> Fusion MPT ScsiHost drivers for FC 
         <*> Fusion MPT ScsiHost drivers for SAS
   SCSI device support  --->
         <*> SCSI device support
         <*> SCSI disk support
         SCSI low-level drivers  --->
             <*> SYM53C8XX Version 2 SCSI support


Linux Kernel Configuration: BusLogic
Device Drivers  --->
   SCSI device support  --->
         <*> SCSI device support
         <*>   SCSI disk support
         SCSI low-level drivers  --->
             <*> BusLogic SCSI support


Linux Kernel Configuration: HID support
Device Drivers --->
   [*] HID Devices  --->
         <*>   USB Human Interface Device (full HID) support
   [*] USB support  --->
         <*>   Support for Host-side USB
         <*>     SL811HS HCD support


Linux Kernel Configuration: CDROM
Device Drivers  --->
   <*> ATA/ATAPI/MFM/RLL support  --->
         <*> Enhanced IDE/MFM/RLL disk/cdrom/tape/floppy support
         <*>   Include IDE/ATAPI CDROM support
         [*]   PCI IDE chipset support
         <*>     Intel PIIXn chipsets support

File systems  --->
   CD-ROM/DVD Filesystems  --->
   <*> ISO 9660 CDROM file system support
   [*]   Microsoft Joliet CDROM extensions

We have to disable IPV6, VMware does not support it yet.

Linux Kernel Configuration: Network
Networking   --->
   [*] Networking support
         Networking options  --->
             <*> Packet socket
             <*> Unix domain sockets
             [*] TCP/IP networking
             < >    The IPv6 protocol --->
        <*> 802.1d Ethernet Bridging
        

You need to build the network drivers as modules to be able to unload them later and load vmware optimized modules.
Device Drivers  --->
   Network Device support  --->
        [*] Network device support
             Ethernet (10 or 100Mbit)  --->
                [*] Ethernet (10 or 100Mbit)
                [*] EISA, VLB, PCI and on board controllers
                <M>   AMD PCnet32 PCI support
             Ethernet (1000Mbit)  --->
                [M] Intel(R) PRO/1000 Gigabit Ethernet support

VMware virtual machine emulates a Creative Labs Sound Blaster® AudioPCI device. If you like to have sound in your virtual Gentoo Linux, you will need to add support for it. See the following section.

Linux Kernel Configuration: Audio
Device Drivers  --->
   Sound  --->
      <M> Sound card support
      --- Advanced Linux Sound Architecture 
         <M>   Sequencer support                                
         < >     Sequencer dummy client                                 
         <M>   OSS Mixer API                                             
         <M>   OSS PCM (digital audio) API                               
         [*]     OSS PCM (digital audio) API - Include plugin system       
         [*]   OSS Sequencer API                              
         [*]   Dynamic device file minor numbers
         [*]   Support old ALSA API        
         [*]   Verbose procfs contents
         [*]   Generic sound devices  --->    
         [*]   PCI sound devices  --->                   
         [*]   USB sound devices  --->                             
         [*]   PCMCIA sound devices  --->    
            <M> (Creative) Ensoniq AudioPCI 1371/1373


Linux Kernel Configuration: Gameport
Device Drivers  --->
   Input device support --->
        Hardware I/O ports --->
        <*> Gameport support


Linux Kernel Configuration: Graphics
Device Drivers --->
   Graphics support --->
        <*> /dev/agpgart (AGP Support)  --->
             <*>   Intel 440LX/BX/GX, I8xx and E7x05 chipset support


Linux Kernel Configuration: Device mapper support
Device Drivers --->
   [*] Multiple devices driver support (RAID and LVM)  ---> 
        <*>   Device mapper support
        <*>     Snapshot target
        <*>     Bad Block Relocation Device Target (EXPERIMENTAL)

These other things might be useful for udev. Note: If your kernel has problems mounting udev, you may need to emerge sys-apps/portage, sys-fs/baselayout, and sys-fs/udev to their most current stable versions.

Linux Kernel Configuration: udev support
File Systems  --->
    Pseudo filesystems  --->
        -*- /proc file system support
        < >   /proc/kcore support
        <*> Virtual memory file system support (former shm fs)

[edit] Installing ALSA Sound

We first install alsa-utils

emerge -atv alsa-utils

Recent versions of udev (>=udev-103) provide some degree of kernel-level autoconfiguration of your sound card. If possible, try to rely on just letting your kernel automatically setup your sound card for you. Otherwise, use alsaconf to configure your card, as shown below.

alsaconf

After that, you need to update the modules to activate the changes

update-modules

Add the ALSA init script to default runlevel

rc-update add alsasound boot

The last thing is to add your users to the audio group

gpasswd -a <username> audio

As much as I hate to write that, but I did not find the proper services to restart... Reboot for all changes to take effect.

[edit] Installing VMware Tools

Installing VMware tools is needed to take advantage of many VMware features like drag and drop, mounting the host file system and also loading appropriate drivers for the virtual hardware. There are two set of VMware tools available. VMware native tools and the open source tools.

[edit] Installing VMware Native tools

First, we mount the iso image of the tools. Within vmware player of workstation, connect the CDROM to the iso file. It is located at
/opt/vmware/workstation/lib/vmware/isoimages/linux.iso.

Now we have to mount the image file

mount /dev/cdrom /mnt/cdrom

Then untar the image file

cd /mnt/cdrom tar -zxf VMwareTools-*.tar.gz -C /opt

Here you need to create the /etc/rc{0..6}.d directories because the installation script wants to create symlinks to /etc/init.d/vmware-tools.

mkdir /etc/rc{0..6}.d

Now we run the install script

cd /opt/vmware-tools-distrib ./vmware-install.pl

Respond to the configuration questions on the screen. Press Enter to accept the default value. Once you answer the last question, the installation will start. It will take quite some time... have a cup of tea.

Once the installation is finished, we have to add vmware-tools to the default runlevel

rc-update add vmware-tools default

Now you can start vmware-tools manually by the following command or you can reboot

/etc/init.d/vmware-tools start


Note: You will have to manually run the install script every time that you change your kernel

If you use a desktop environment like Gnome, KDE or XFCE, then you should add an autostart entry for vmware-user, which is part of the open-vm-tools package but separate from vmware-tools service that you added with rc-update. The vmware-user service will allow GUI features such as drag-and-drop (DnD), file and text copy/paste, dynamic display resizing, and Unity (source).

In KDE create a new application link (as root) to vmware-user on /usr/share/autostart. Then you add /usr/bin/vmware-user

In Xfce4, start the autostart editor
xfce4-autostart-editor
Fix me: Please add the same as above for Gnome
[edit] Installing VMware open source tools
emerge -av app-emulation/open-vm-tools rc-update add vmware-tools default

app-emulation/open-vm-tools might be masked, just add it to your /etc/portage/package.keywords file :

echo "app-emulation/open-vm-tools ~x86" >> /etc/portage/package.keywords

Since new versions require the package open-vm-tools-kmod you may add it too.

echo "app-emulation/open-vm-tools-kmod ~x86" >> /etc/portage/package.keywords

[edit] VMware guest OS features

[edit] Configuring VMware network module

Change the module specification for the network interface. Edit the alias file adding the following line

File: /etc/modules.d/aliases
alias eth0     vmxnet

As of now [20100321], aliases are located in /etc/modprobe.d/aliases.conf...

Now update the module files

update-modules

[edit] Mount shared folder

After VMWare Tools installed, your vm can mount host's shared folder.

  1. Add a shared folder in vm settings.
  2. Load kernel module for hgfs:
    modprobe vmhgfs
  3. Add following line into
    File: /etc/fstab
    .host:/ 		/mnt/hgfs	vmhgfs		defaults,ttl=5 	0 0
  4. Mount the shared folder (make sure you already mkdir /mnt/hgfs):
    mount -a

[edit] Cloning Your Virtual Machine

When you make a copy of your virtual machine, either through the interface or simply by copying the files, VMWare will detect this change and ask you if you'd like to assign a new Unique ID to the new copy. If you choose 'not' to keep the existing ID, but create a new one, VMWare will assign new unique IDs to hardware such as the virtual network card's MAC address. If you have software that relies on these IDs, you must be careful to update them as well.

In particular, udev is confused by changing the MAC address on the card, and won't be able to find the network interface (eth0) even though the driver loads properly. See the udev documentation on how to update the files, or to modify the udev scripts to handle this case.

Taken from here: http://yoopergeek.blogspot.com/2007/07/vmware-loosing-eth0-after-youve-copied.html.

The actual MAC address as provided VMWare can be found using
dmesg
. In Gentoo do one of the following: (Do #1, it's the easiest.) Instead of rebooting, you can reload udev using
udevadm trigger
.
  1. Delete /etc/udev/rules.d/70-persistent-net.rules and reboot. Your eth0 should be back. 2007/09/13 Update: This almost-always works for me. But, for some reason, sometimes it seems to confuse udev even more; after rebooting, I'll have an eth2 or eth3. When this happens, I end up following #2, making sure the udev config file has 'eth0' listed, and not eth1, eth2, or eth3.
  2. Edit /etc/udev/rules.d/70-persistent-net.rules (or whatever it's named) to match your new MAC address and reboot. Your eth0 should be back.

You may also want to generate new ssh host keys. To do so, delete the existing keys and restart SSH. Code: regenerate SSH keys

rm /etc/ssh/ssh_host_key* /etc/ssh/ssh_host_dsa_key* /etc/ssh/ssh_host_rsa_key* /etc/init.d/sshd restart

If your VM uses DHCP, you will want to get a new DUID and lease. If you are using net-misc/dhcpcd, you can do this by deleting existing DUID and lease and restart dhcpcd. Code: get a new DUID and DHCP lease

rm /var/lib/dhcpcd/dhcpcd-eth0.info /var/lib/dhcpcd/dhcpcd.duid /etc/init.d/net.eth0 restart


[edit] Using VMXNET3 NIC and ParaVirtual SCSI Controller on ESXi

ESXi 4+ has some nice hardware options that should give the VM Guest some performance benefits, such as VMXNET3 and ParaVirtual SCSI Controller (pvscsi).

The drives for these hardware options are now included in the Kernel, making it much easier to use and no need to use additional SCSI Device Controllers for the root and boot partitions.

[edit] (Kernel >= 2.6.33)

As stated above, the drives are now included in the kernel >= 2.6.33. At the time of writing this version was masked, so check what the current kernel verions is, if it is masked you will need to add this to /etc/portage/packages.keywords:

File: /etc/portage/packages.keywords
>=sys-kernel/gentoo-sources-2.6.33

Or if you prefer:

{{{1}}}

Then emerge the new version, I decided to update world, but you could just do gentoo-sources.

emerge -uav world

Once you have the latest version of the kernel you need to select it:

eselect kernel list

Available kernel symlink targets:

 [1]   linux-2.6.31-gentoo-r10
 [2]   linux-2.6.32-gentoo-r7 *
 [3]   linux-2.6.33-gentoo-r1 

eselect kernel set 3

eselect kernel list Available kernel symlink targets:

 [1]   linux-2.6.31-gentoo-r10
 [2]   linux-2.6.32-gentoo-r7 
[3] linux-2.6.33-gentoo-r1 *

Note, your list might differ from the above, you need to select the new kernel that you wish to use.

cd /usr/src/linux

make oldconfig ... Run though the options, I found the defaults to be fine.

make menuconfig

You will then need to select the drivers.

Linux Kernel Configuration: VMXNET3 Device Support
Device Drivers --->
   [*] Network device support  --->
       <*>   VMware VMXNET3 ethernet driver
Linux Kernel Configuration: PVSCSI Support
Device Drivers --->    
   SCSI device support  --->
      [*] SCSI low-level drivers  --->
        <*>   VMware PVSCSI driver support
make && make install modules

Copy the bzimage to the boot partition and mod grub.conf.

I removed all of the old modules that were referenced, the VMXNET3 and I had e1000 and PCNET32.

Also removed the reference from the /etc/modprobe.d/aliases.conf.

Remember, if you are upgrading from the older version and you have excluded the module for the other SCSI control you will need to Edit the VM to use the ParaVirtual SCSI controller.

You should be able to reboot and everything work.

[edit] Kernel <= 2.6.32)

Assuming you have followed the steps above to install the VMWare tools it's really easy to make use of these new types of hardware. You should see that the drivers are installed and loaded if you look at the VMs console via the vSphere Client.

[edit] VMXNET3 NIC

To use the VMXNET3 NIC, simply add/replace a new NIC select "VMXNET3" as the type, and then modify the alias in /etc/modprobe.d/aliases.conf to use vmxnet3.

File: /etc/modprobe.d/aliases.conf
alias eth0     vmxnet3

Remember, the MAC will have changed so you will need to alter/delete the udev "70-persistent-net.rules" files once the machine has started, and then reboot.

For more details on the available NICs and the capabilities of their different types see: http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1001805

[edit] ParaVirtual SCSI Controller (pvscsi)

My personal experiences of using the pvscsi controller have shown a significant read / write performance gain, at least twice as fast as the other SCSI Controllers.

Officially, only Red Hat Enterprise Linux and maybe CentOS supports this Controller, so don't expect any help from VMWare or the community using it with Gentoo, and be sure to test your setup thoroughly once you have it installed.

There doesn't appear to be any support for the pvscsi in the kernel, this means that the "boot" and "root" partitions need to be on one of the other SCSI controller types. As RHEL appears to be able boot from a device on one of the pvscsi controllers, it might be possible to compile a kernel with pvscsi support built-it. Feel free to have a go.

To Add the additional SCSI Controller, first you must add another SCSI disk. Be sure, when you are adding the disk, to select a device node for a SCSI control that doesn't exist. It will automatically add a Controller. AFAIK, there's no other way to add an additional SCSI Controller.

For example, if you only 1 other SCSI Controller when you add the new hard disk, this existing controller will relate to SCSI(0:*). So change the Device Node for the new hard disk to any of the nodes : SCSI(1:*).

Once you have added the hard disk, you will see a new SCSI Controller has also appeared in the list of hardware. Now you can select the Controller and Change it's type to ParaVirtual.

That's it. Once you have started the machine you can use fdisk to add partition(s), format them and you're good togo.


[edit] Troubleshooting

[edit] Interface eth0 does not exist

If you have copied / downloaded / moved a gentoo vmware, and you no longer have eth0 it will most likely have moved to eth1 if you do a ifconfig -a. This is because of udev and your mac address changing.

Please see here: http://yoopergeek.blogspot.com/2007/07/vmware-loosing-eth0-after-youve-copied.html

Option 1: Remove '70-persistent-net.rules'

rm /etc/udev/rules.d/70-persistent-net.rules reboot

Option 2: Update '70-persistent-net.rules' with the correct mac address (or delete and reboot).

nano /etc/udev/rules.d/70-persistent-net.rules reboot

Newer versions of VMWare default to use vmxnet for the default virtual device, but this interface type is not supported by the installation CD. If you are seeing that eth0 does not exist, simply change your vmx file's ethernet config line to

ethernet0.virtualDev = "e1000"

Restart the VM image and the installer should autodetect eth0

  • Edited by: pvenne - 2009-03-30
Personal tools