Virtualbox in Windows

来自Ubuntu中文
Oneleaf留言 | 贡献2010年6月25日 (五) 09:46的版本 (以内容'Virtualbox (by Sun) has some advantages and disadvantages. There is a free proprietary edition as well as a subscription-based enterprise edition. The free edition only all…'创建新页面)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳到导航跳到搜索

Virtualbox (by Sun) has some advantages and disadvantages. There is a free proprietary edition as well as a subscription-based enterprise edition. The free edition only allows usage of a 32-bit operating system (as the guest OS) whereas the subscription edition allows a 64-bit guest OS. (Both require registration.) There is also has a free open source edition, but this is not easy to install in Windows (unlike in Linux). Virtualbox is available for all operating system platforms, and therefore a virtual machine created in one operating system (Windows, Apple, Linux) can be used in another. Furthermore, it is possible to convert virtual machines created in Virtualbox to VMWare and vice versa.

I find both the installation process and the interface for Virtualbox quite user friendly (as I do VMWare). So far I have had few difficulties with Virtualbox and recommend it.

Install Virtualbox in Windows

  • Obtain and download a copy of the Virtualbox (binary) installer for your (Windows) operating system here.
  • Install the program, following the prompts.
  • Start Virtualbox
Start menu -> Programs -> Sun Virtualbox -> Virtualbox

(Optional: Of course, if you would like Virtualbox to start every time you run Windows, you can copy the Virtualbox shortcut into the Start menu -> Programs -> Startup folder.)

  • Create a new virtual machine:
Virtualbox -> New -> Next ->
Name: UbuntuVirtualServer
Operating System: Linux
Version: Ubuntu
-> Next -> Memory: Base memory size: 1024 Mb
Note: Use the amount of RAM for the virtual machine that you can afford. Linux requires less memory to run than does Windows, but the amount of RAM that you dedicate to the virtual machine in this step will not be available to the Windows host. On my laptop, I have 3 Gb RAM, so I dedicate 1024 Mb (1 Gb) to the virtual machine in this step and leave 2 Gb for Windows. You should always leave at least 1 Gb RAM for Windows (or it will run painfully slowly). Linux is able to run with only 512 Mb in server mode or 1 Gb in desktop mode (perhaps even less).
-> Next -> Virtual Hard Disk ->
Boot Hard Disk (Primary Master): (ticked)
Create new hard disk: (ticked)
-> Next -> Next -> Hard disk storage type:Dynamically expanding storage: (ticked)
-> Next -> Virtual Disk Location and Size:
Location: UbuntuVirtualServer
Size: 8.00 GB

Note: Use whatever size you can afford in Windows. This will take space from your hard drive (so make sure it is available to begin with). A Linux server can easily run in 8 GB, but if you plan to run a GUI desktop in addition (the Ubuntu desktop or Kubuntu desktop, for example), you should consider making this between 10 -20 GB. However, because you have chosen the dynamically expanding storage in the preceding step, the virtual machine will automatically expand storage later if you guess wrong here. (I usually just accept 8 GB.)

-> Finish.

Now you will have a new virtual machine. You can create multiple virtual machines, in this fashion. If you desire, you can run each new virtual machine simultaneously (if you have enough RAM and hard drive resources).

Install Ubuntu edition for virtual machines

There is a version of the Ubuntu server that is optimised for usage within a virtual machine. It is provided on the Ubuntu Server edition LiveCD. The LiveCD image (.iso) found here can be downloaded onto your hard drive. It can then be installed directly into your virtual machine from the hard drive. Alternatively, you can also burn the .iso image onto a CD and install Ubuntu Server into the virtual machine from the CD. Both methods work identically during the Ubuntu Server installation process.

The free version of Virtualbox only allows the use of a 32-bit operating system as a guest OS, so you should download the 32-bit Ubuntu server (.iso) image.

  • Start the virtual machine you created in the previous step.
Virtualbox -> Ubuntu Virtual Server (highlighted) -> Start
The "First Run Wizard" will prompt for the location of the installation disk -> Next ->
CD/DVD-ROM device (ticked) ->
Media Source:
  • select the CD-ROM drive (if you burned the LiveCD (.iso) image onto a physical CD), or
  • browse for the folder where you stored the (.iso) image onto your hard drive (if you did not burn it to a physical CD)
-> Next ->
  • Install Ubuntu server virtual machine edition:

The First Run Wizard will automatically start the LiveCD from the location you indicated, and you will see the Ubuntu Server LiveCD screen.

  • Choose language: English ->
  • Important: note this step carefully! Select the minimal virtual machine installation mode:
* Click the F4 (modes) key -> Install a minimal virtual machine ->
  • Install Ubuntu Server
  • Select your installation options. When asked about partitioning, use the guided partitioning method and use the entire disk. This uses the entire virtual machine disk (which is 8 GB or whatever size you created when creating the virtual machine), not the entire physical hard drive disk.
  • Finish the remainder of the Ubuntu server installation. At the conclusion the Ubuntu system will automatically reboot within the virtual machine. When it restarts, you will then have a fully function Ubuntu Server within the virtual machine. Immediately update the operating system:
sudo apt-get update
sudo apt-get upgrade

Install a desktop

This is a decision that is difficult to make. Having an Ubuntu or Kubuntu GUI desktop is nice, but it also slows down the virtual machine server considerably and takes a large chunk of the 8.00 GB virtual disk (which may need to be dynamically expanded and thereby occupy more space on your hard-drive).

If you intend to use many of the features of Ubuntu or Kubuntu, this is worthwhile. Install a desktop:

sudo apt-get install ubuntu-desktop
or
sudo apt-get install kubuntu-desktop
  • After all the packages are installed, restart the OS within the virtual machine and you should now boot into the GUI desktop.

Install Linux Guest Additions

If you have installed a (K)ubuntu desktop, you will definitely need this for functionality. There are quirks. A general introduction is found at the VirtualBox Manual. The Guest Additions are contained within the VBoxGuestAdditions.iso CD image file contained within the VirtualBox installation folder (on my Windows system it is in the C:\Program Files\Sun\VirtualBox folder). (If there are errors using this file, it must be copied to a neutral location (such the Documents folder) and used from there.)

  • Mount the VBoxGuestAdditions.iso as a virtual CD-ROM device (for the virtual machine you have created in the preceding steps). (The virtual machine must be stopped while doing this).
VirtualBox -> Machine -> Settings -> Storage
-> Add CD/DVD Device (CD icon with green + sign) -> Atrributes -> CD/DVD Device: VBoxGuestAdditions.iso
  • Start the virtual machine.
  • From a command-line terminal (Terminal in Ubuntu or Konsole in Kubuntu), change to the CD-ROM/DVD directory:
cd /media/cdrom0
  • Install prerequisites:
sudo apt-get install dkms
  • Run the Guest Additions binary:
sudo ./VBoxGuesatAdditions-Linux-x86.run

(If you are using a 64-bit edition of Ubuntu as a guest OS, see the VirtualBox Manual for additional instructions. Because this is not an option with free versions of VirtualBox, I will not discuss it here).

  • Once the installation is complete, you can unmount the VBoxGuestAdditions.iso as a virtual CD. (The virtual machine must be stopped while doing this).
VirtualBox -> Machine -> Settings -> Storage -> Storage Tree
-> VBoxGuestAdditions.iso -> Removes the attachment highlighted in the Storage Tree (CD icon with green - sign) -> Remove

Creating shared folders

This is a folder on your Windows host that will be shared with the Ubuntu virtual machine. An extremely nice feature. The GuestAdditions must be installed to use this feature. See the VirtualBox manual on Shared folders for more information.

  • With the virtual machine stopped, designate a shared folder. In my example I use a folder in Windows that is already commonly shared (C:\Users\Public\Documents).
VirtualBox -> Machine -> Settings -> General -> Shared Folders
-> Add Shared Folders (Ins) (Folder icon with a + symbol)
-> Folder Path: Other -> C:\Users\Public\Documents
-> Folder Name: PublicDocuments
  • Start the virtual machine.
  • Create a folder that will be associated with the shared Windows folder:
sudo mkdir /media/windows-shared
  • Test that the Windows shared folder can be mounted:
sudo mount -t vboxsf PublicDocuments /media/windows-shared
  • If there are no errors, then ensure the shared folder is mounted at every bootup of the virtual machine. Edit the /etc/fstab file:
sudo nano /etc/fstab

(you can used gedit in Ubuntu or kate in Kubuntu instead of nano, if you'd like).

  • Add the line:
PublicDocuments /media/windows-shared vboxsf defaults 0 0
  • Reboot the virtual machine (sudo reboot).
  • Access /media/windows-shared just like any other folder (from Nautilus or Dolphin, for example) within the virtual machine.
  • Access C:\Users\Public\Documents just like any other folder in the Windows host.