SaltyCrane Blog — Notes on JavaScript and web development

Virtualbox with Windows guest and Ubuntu host

Virtualbox 4.1, Ubuntu 10.10 https://www.virtualbox.org/manual/UserManual.html

Contents

Install Virtualbox

https://www.virtualbox.org/wiki/Linux_Downloads

  • edit /etc/apt/sources.list.d/virtualbox.list
    deb http://download.virtualbox.org/virtualbox/debian maverick contrib non-free
  • install
    $ wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | sudo apt-key add - 
    $ sudo apt-get update 
    $ sudo apt-get install virtualbox-4.1 
    $ sudo apt-get install dkms 
    

Run Virtualbox

$ VirtualBox & 

Create a VM

https://www.virtualbox.org/manual/ch01.html#gui-createvm My machine has 4GB ram and 225GB hdd. I chose 1GB ram and 30GB hdd for the guest to run MS SQL Server Management Studio. Windows 7 Professional 32-bit took 7.3GB after installing.

  • click "New"
  • follow the wizard

Run VM and install Windows

Need windows disc. Need to download driver? http://support.lenovo.com/en_US/research/hints-or-tips/detail.page?&DocID;=HT063291

  • Put Windows disc in the drive
  • click "Start"

Install Guest Additions

Info: https://www.virtualbox.org/manual/ch04.html Install instructions: https://www.virtualbox.org/manual/ch04.html#additions-windows Install Guest Addtions to allow sharing between guest/host, better screen resolution

  • Run the Windows VM
  • click "Devices" -> "Install Guest Additions..."
  • click "Run VBoxWindowsAdditions.exe", click on stuff to install the stuff

Add another virtual hard disk

  • create virtual hard disk file
    • Shut down the guest VM
    • In the Oracle VM VirtualBox Manager, click "Settings"
    • Storage -> SATA Controller -> Add Hard Disk
  • add the hard disk in windows http://windows.microsoft.com/en-us/windows7/install-or-remove-a-hard-disk-drive
    • Open Computer Management by clicking the Start button Picture of the Start button, clicking Control Panel, clicking System and Security, clicking Administrative Tools, and then double-clicking Computer Management.‌ Administrator permission required If you're prompted for an administrator password or confirmation, type the password or provide confirmation.
    • Right click on the new disk (e.g. Disk 1) and click "New Simple Volume..", run the wizard

Resize the VM disk image file

  1. resize the disk image file https://www.virtualbox.org/manual/ch08.html#vboxmanage-modifyvdi From the docs This command "currently works only for VDI and VHD formats, and only for the dynamically allocated variants, and can only be used to expand (not shrink) the capacity"
    $ cd ~/VirtualBox VMs/Windows_7_1GB 
    $ VBoxManage modifyhd Windows_7_1GB.vdi --resize 20480 
    
  2. resize partition in Windows
    • Open Computer Management by clicking the Start button Picture of the Start button, clicking Control Panel, clicking System and Security, clicking Administrative Tools, and then double-clicking Computer Management.‌ Administrator permission required If you're prompted for an administrator password or confirmation, type the password or provide confirmation.
    • Right click on the C: partition in Disk 0 -> "Extend Volume..."

Access a Flask dev server running on the Ubuntu host from the Windows guest


Reference: http://stackoverflow.com/questions/1261975/addressing-localhost-from-a-virtualbox-virtual-machine

In Ubuntu host:

  • Run Flask dev server as normal on 127.0.0.1:5000

In Windows guest:

  • Open cmd.exe and run "ipconfig". Find the "Ethernet adapter Local Area Connection" section. Find the "Default Gateway" is 10.0.2.2
  • Point the web browser at http://10.0.2.2:5000

How to share a folder

You need Guest Additions to be installed. See above. Reference: https://help.ubuntu.com/community/VirtualBox/SharedFolders Note: I did not need to do the mount step.

  1. Ubuntu host: mkdir /home/yourusername/share
  2. Windows guest: Boot the Guest operating system in VirtualBox.
  3. Windows guest: Select Devices -> Shared Folders...
  4. Windows guest: Choose the 'Add' button.
  5. Windows guest: Input the following:
    • Folder Path: /home/yourusername/share
    • Folder Name: share
    • Optionally select the 'Make permanent' option
  6. Windows guest: Open cmd.exe and run:
    net use x: \\vboxsvr\share 

Comments