View Full Version : Virtualbox
Spearball
07-05-2008, 12:52 AM
I've just installed 3 virtual machines on virtualbox on a fedora install that will be running on a pretty powerful pc. Quad core, 4gb of ram.
Basically the pc has three nics and i want to know how to point each virtual machine out to a different nic each. BY default when you start them all up they all point to one nic with NAT.
saphalline
07-05-2008, 05:33 PM
Ooh! Another virt'er is born! :cool:
Yes, I have found NAT to be extremely limiting when virt'ing, suitable only for rudimentary testing purposes or VM's that are used for home internet use only (which is kind of overkill if you ask me! :p). Bridging or product-specific VM networks are almost always better in the long run, especially for production-level implementations where security rears its ugly head.
Assuming you're using the latest VirtualBox 1.6.2... ;)
The manual will be included with the software, or you can download it from the site (http://www.virtualbox.org/wiki/Downloads) directly. You'll want to use VirtualBox's Host Interface Networking, described in detail in chapter 6, p73. 6.7 overviews the use of HIF on Linux hosts by creating TAP's to the physical ethernet devices. (Read up on network bridging if necessary.) Pay special attention to ownership and perms on /dev/net/tun. 6.7.1, p75, overviews the concept of permanent bridge creation for use with HIF in VirtualBox. Basically, you need to create bridges to your ethernet PHY's internally on the host OS, which is easier to do than it sounds. ;) The manual even provides instructions for Fedora! 6.7.1.3, p79, gives detailed instructions for how to do this on Fedora/RH.
You'll need the bridge-utils package if you don't have that already. Then you'll need to create the bridge creation scripts in /etc/sysconfig/network-scripts and name them accordingly (they suggest ifcfg-brx where 'x' is a number starting with zero). The script should generally look like this (do not immediately assign a static IP until you are certain DHCP works, and all the implications that go along with that):
DEVICE=br0
TYPE=Bridge
BOOTPROTO=dhcp
ONBOOT=yes
Then attach to the bridge to an ethernet device by adding a line to the /etc/sysconfig/network-scripts/ifcfg-eth[0..n] script:
BRIDGE=br0
Some advice at this point - avoid bridging your VM network interfaces to eth0 if possible. I've found this to be problematic on full-virt'ed systems running off a *NIX host, especially as VM density increases or the host is intended for home/desktop use. As in, Ubuntu on a PC doesn't like to share eth0, but RHEL is OK with it on a server-class PCI-X GbE NIC. If you're just getting into virt right now and have more than one ethernet PHY, start your VM's on eth1.
Once the bridge creation script is in place and ethx is patched to it (double-check the ownership/perms on those, btw) you can restart the network service and have it available immediately. Obviously, don't do this in the middle of a download or anything! :p
sudo /sbin/service network restart
Now you can add the functioning bridge to a host interface usable by VirtualBox, vboxx (vbox0 for the first one):
sudo VBoxAddIF vbox0 <user> br0
The user will be your main non-root user name on your host OS, or whichever user will be running VirtualBox. Just don't use root here because it is both inadvisable and unnecessary.
From here, you can go back to the VirtualBox GUI and map a VM's network interface to vbox0. Settings -> Network -> Attached to -> "Interface name" field -> select vbox0. (Just make sure your VM's are completely shut down before changing their settings.) Note that each "vbox" interface can only be assigned to a single VM. But you can create multiples for each VM. So if you needed one of your VM's to have two virtual NIC's, just create and assign vbox0 and vbox1 to it, and give vbox2 to your next VM, etc. You can also assign a single bridge to more than one ethernet device, but that's a bit more complicated. You should be safe to assign more than one bridge to a single ethernet device, however, as long as you don't pump a GB/min to each VM at once! ;)
As far as the number of VM's, you should be able to run more than one OS per core without any speed issues, as long as the VM's aren't hammering away at CPU-intensive tasks. Modern x86-based CPU's have hardware virt built-in and plenty of cache, and modern x86-based virt products are designed to use these new features. Even without that, I've successfully run two test VM's plus a host OS on a single-core machine (! :eek: !) without a problem! You just gotta have enough RAM! :p Haha!
Anyway, enjoy your VM's!! They're so frickin' cool!! :D
Spearball
07-06-2008, 02:39 PM
Wow thanks so much.:) By the way, long time no see. You were gone for a while.
Saph was never 'gone'...just in semi-retirement. He's now hardware guru emeritus, who deigns to grace us mere mortals with his presence on occasion. ;)
Spearball
07-07-2008, 10:13 PM
Well, just to ask since i wanted to know this, is it possible to run a VM software on a BSD machine? Seems a lot are only compatible with windows, linux like virtualbox for example.
Yeah, but I can't remember which ones...that is one of the problems with BSD, while being a Unix offshoot, it isn't all that popular, so often times things don't get ported to it.
Spearball
07-08-2008, 12:43 PM
I heard virtualbox is one of the best VM's even compared to vmware in some situations. Runs vista really well in linux as well as a lot of linux distros. Just that it can't run 64 bit guests.
Anyway, before we close this off, once i had my vms set up, i noticed my cpu was always running at full speed instead of down clocking itself with cpuspeed even when my vms were all idle. The VM process kept on using a lot of cpu resources. Is there any way i can fix this?
saphalline
07-08-2008, 07:57 PM
Have you installed the Guest Additions within each VM? It's equivalent to VMWare Tools in VMWare.
Spearball
07-08-2008, 09:33 PM
Actually no i haven't yet. Doing that now brought my cpu to a lower usage actually yes it did go down, but i guess it wont go lower than 30% -35% for some reason.
saphalline
07-09-2008, 01:57 AM
If all your VM's are rendering to the screen (which they do on X/X.Org unless you minimize them) then yes you'll get an abnormally large amount of CPU usage relative to the load on your VM's. For the purposes of rendering a virtual desktop inside a host's GUI, each VM can be considered a "movie" or a "game". They're constantly updated and refreshed, even if your VM is a CLI-only slackware box! Remember that a picture of a prompt on a black screen is still a picture. ;)
Spearball
07-09-2008, 03:02 PM
Alright thanks guys!
vBulletin v3.6.1, Copyright ©2000-2012, Jelsoft Enterprises Ltd.