Lessons learned the hard way while going virtual with VB.
Host box -- Quad Xeon cores: Ubuntu 12.04 LTS, VirtualBox 4.3.6 (91406) PUEL, phpVirtualBox management gui.
Getting error when trying to install a 64bit linux guest: “This kernel requires an x86-64 CPU, but only detected an i686 CPU….”
The host is 64 bit, chipset supports VT and Bios settings are enabled. The guest container has IO APIC, PAE/NX, VT-x/AMD-V and Nested Paging enabled. I can select 64 bit templates for Type and Version… everything should be working for 64 bit.. but doesn’t.
Solution: There’s a bug in the gui on some systems that prevents 64 bit from being properly set on the Guest. Workaround is to create the Guest container in the gui as normal, then use the CLI on the host box to manually set the Guest to 64 bit:
# VBoxManage modifyvm [vmname] --longmode on
Could not get linux Guests to connect to unused physical NICs on Host using Bridged Adapter setting in Guest.
Solution: Turns out the Guest are not able to activate (aka. turn on) the host NIC. NICs should be activated on the Host, but not configured.
Add the following for each NIC (replace “X”) that should be made available for a Guest bridge:
/etc/network/interfaces (on Host)
iface ethX inet manual
up ifconfig ethX up
Install VirtualBoxGuestAdditions_XX.iso in a VirtualBox linux guest (for VirtualBox PUEL version only, not OSE).
1) add .iso file on Host as an IDE cdrom in the Guest vbox container settings then boot guest
2) apt-get install linux-headers-[yourkernelversion] build-essential dkms
3) edit Guest /etc/fstab and add:
/dev/sr0 /media/cdrom udf,iso9660 rw,user,noauto,exec,utf8 0 0
4) sudo mount /media/cdrom && cd /media/cdrom
5) sudo ./VBoxLinuxAdditions.run -- -nox11
6) If you don’t have X11 on the guest you can ignore “Installing the Window System drivers …fail! (Could not find the X.Org or XFree86 Window System.)” error
7) “sudo lsmod” and confirm “vboxsf” and “vboxguest” modules are loaded
Adding VirtualBox Shared Folders into /etc/fstab would cause linux Guest boot failure “/sbin/mount.vboxsf: mounting failed with the error: No such device“. User then had the option to Skip or mount Manually.
The problem is that /sbin/mountall is trying to mount the vboxsf filesystems listed in /etc/fstab before the Virtualbox Guest Additions service has started and loaded the vboxsf module. From searching it sounds like they fixed this somehow in virtualbox-ose, but not in the PUEL version, and I didn’t like the “rc.local” workaround I was finding online. I tried adding the modules to /etc/modules, but it didn’t help.
Solution: What finally worked for me was to build the modules into the boot image using initramfs so they are already loaded at boot with Grub. Again, this is only for the PUEL version:
1) add the Shared Folders in the VBox gui but do not select “Auto-mount” (Auto-mount would mount them under /media/sf_[name] instead of using your fstab entry)
2) add the folders to the Guest /etc/fstab as:
name_of_share /path/to/guest-mountpoint vboxsf defaults 0 0
3) run “mount -a” to mount the shares, then run “mount” to see if they are successfully mounted. If not, then you have other issues (probably need to install Virtualbox Guest Additions on Guest vm).
4) install initramfs-tools package
5) add the following two lines in /etc/initramfs-tools/modules
6) run “update-initramfs -u” as root (or sudo)
7) reboot the Guest vm
eth0 could not be found on the new Guest VM after cloning an existing Guest.
1) Edit file on Guest VM using console: /etc/udev/rules.d/70-persistent-net.rules
2) Delete the entry with the existing eth0
3) Change the eth1 entry to eth0
4) Save file and reboot. Networking will still fail at boot.
5) Use “ifconfig -a” to confirm that new eth0 was created
6) Use Guest console (CLI) to manually setup networking in /etc/network/interfaces
7) Restart networking “/etc/init.d/networking restart” and verify new IP assignment with ifconfig
SSH server keys need to be regenerated for security after cloning a Guest VM.
1) use RDP console to login
2) “service ssh stop”
3) “rm -rf /etc/ssh/ssh_host_*”
4) “ssh-keygen -A”
5) “service ssh start”