VirtualBox
Turning one computer into many
Jonathan Marsden
jmarsden@fastmail.fm
09 January 2010
(page 1)
0. Contents
1. What is Virtualization?
2. Uses for Virtualization
3. Virtualbox Overview
4. Virtualbox Hardware Requirements
5. Installing Virtualbox on Ubuntu
6. Creating a virtual machine
7. Running the virtual machine
8. Networking
9. Virtual Disks
10. Snapshots
11. Guest Additions
12. Guest Additions - Shared Folders
13. Limitations of Virtualbox OSE
14. Further Ideas and Resources
15. Summary and Questions
(page 2)
1. What is Virtualization?
- Very generally, virtualization is turning a real physical thing into a software-only digital version of that thing
- Virtualization:
- "the abstraction of computing resources"
- Virtual Machine (VM):
- a software implementation of a machine (computer) that executes programs like a real machine
- In the PC and Ubuntu Linux context, generally we are creating one or more "virtual" computers that run on one real computer
(page 3)
2. Uses for Virtualization
- Separate applications (or users) onto different VMs
- For security or to meet application needs
- Consolidate physical servers onto one powerful one
- Save power and cooling and rack space costs
- Software testing and development
- Run many different OSes at once
- Try out things that might "break" your PC
- Even try out Linux on a Windows PC!
- Rapid deployment
- Creating new (virtual) machines almost instantly
- Run an OS intended for one CPU on a machine with a different CPU
- cross-platform virtualization - not part of this talk
(page 4)
3. Virtualbox Overview
- "PC" virtualization software from Sun (now Oracle)
- Two editions, one free software, one not
- Use the free one, virtualbox-ose (Open Source Edition)
- Runs on Linux or Windows (or Mac OS X, or even OpenSolaris) host OSes
- Friendly GUI interface to get you started easily
- "Serious server" virtualization is not the primary goal
- Such uses may do better using KVM instead
(page 5)
4. Virtualbox Hardware Requirements
- No special CPU requirements for 32bit use (unlike KVM)
- VT-x support is needed for 64bit virtualization
- egrep '(vmx|svm)' /proc/cpuinfo
- The more CPU cores the better
- (At least) 1 core per simultaneous VM is wise
- The more RAM the better
- Add the RAM use of host + each VM
- Disk I/O will become a bottleneck if you push things hard
(page 6)
5. Installing Virtualbox on Ubuntu
sudo apt-get install virtualbox-ose -y
- Installation on Windows or other Linux distros is similarly easy
(page 7)
6. Creating a virtual machine
- Applications -> Accessories -> Virtualbox OSE
- New (follow the wizard, make a new virtual disk)
- Plenty of options for the techies to tweak
- Defaults work well for newcomers
- They work for techies too, mostly
(page 8)
7. Running the virtual machine
- Follow the First Run Wizard (first time only)
- Use it. Reboot it, shut it down when done.
- Mounting and unmounting CDs/ISO images
- Command line interface exists: VBoxManage, VBoxHeadless, ...
vboxmanage --help # Use this for help
(page 9)
8. Networking Virtual Machines
- NAT by default
- Fine for outbound, no use at all inbound
- Bridged host interface
- Works way better that NAT, once set up (can SSH in, etc.)
- Setup is automatic in newer versions of Virtualbox
- Internal network
- Just network between VMs on one physical machine
- https://help.ubuntu.com/community/VirtualBox/Networking
(page 10)
9. Virtual Disks
- Normally just (big) files on a real hard disk
- Can be created in two ways:
- Full size -- higher performance
- Dynamically expanded as needed - more convenient
- 8 GBytes is a workable size for most "normal" uses
- In practice as low as 2.5 GBytes to 5 GBytes is often fine
- Disk file formats:
- VDI (VirtualBox), VMDK (VMware), VHD (MS), HDD (Parallels)
- OVF (proposed new standard, via conversion tools)
- Raw disk or raw partition access can be used
- Get it wrong, and you will trash your system
- Get it right, and your VM will have faster disk access
(page 11)
10. Snapshots
- Allows "undo everything since I made a snapshot"
- Creates a secondary disk file containing only changes
- In Virtualbox 3.1.x you can have many snapshots:
- Trees of snapshots
- This can be useful, or it can become confusing...
- Handy for quick "experimental" changes to VMs
- Can let you duplicate someone else's setup
- Great for doing remote tech support
- And then revert to your own setup in that VM later
(page 12)
11. Guest Additions
- If you can modify the guest OS you can have better integration with the host OS
- Better video integration
- Screen resolution changes
- Full screen use
- Mouse integration
- Copy and paste between VMs and host machine
- Time synchronization
- Shared folders
- Seamless windows
- Automated Windows guest logons
- Needs locally built kernel modules in each guest
- In Ubuntu, DKMS does this automatically
- Devices -> Install Guest Additions
sh /media/cdrom0/VBoxLinuxAdditions-amd64.run
(page 13)
12. Guest Additions - Shared Folders
- Useful for moving files to and from VMs
- Can be permanent or transient
- To mount a shared folder with your user's UID, do:
sudo mount -t vboxsf FOLDERNAME /PATH/TO/MOUNT-POINT/ -o uid=`id -u`
(page 14)
13. Limitations of Virtualbox OSE
- No built in RDP or VNC access to VMs
- Non-free edition provides RDP
- No access to USB devices
- Non-free edition provides USB pass-through
- Full Graphical UI at all resolutions
- Needs (free) Guest Additions
- Even then, does not always work 100%
- Will not coexist with KVM virtualization
sudo service kvm stop # Fixes this on Ubuntu
(page 15)
14. Further Ideas and Resources
(page 16)
15. Summary and Questions
- Summary: virtualbox-ose is an
- open source
- free and
- (relatively) easy
way to create and use virtual machines under Linux (or even Windows).
- Useful for:
- all manner of testing, and
- using multiple (virtual) machines at once without needing to buy extra hardware
(page 17)