Installing Linux on Microsoft Windows using VirtualBox

We like Mac machines because their operating system is essentially a BSD variant that can work seamlessly with the Unix world and is popular enough that companies like Microsoft and Adobe would care to develop versions of their products specifically for the platform. Nice as this is, when it comes to buying computers ourselves, we may not always want to buy Mac for various reasons and as a result we have to resort to work-around methods like this article describes, to get Unix stuff work under Microsoft Windows without the need for dual-booting. Windows is picked as the host OS here because most vendor-provided hardware drivers are only available for Windows, and therefore graphics performance, battery life, etc. tend to be better. For more information, such as Ubuntu gets inside Windows, and how to use Linux as the host OS and run Windows both within Linux and native:Windows 7: In both VM and native (using Linux as host OS), HOWTO: Windows XP in both VM and native, and Taming Windows 7 in a VirtualBox VM Using Raw Disk Access, and more on VDIs: Tutorial: All about VDIs and HOWTO: manage VDIs and import native installations.

  1. To allow multiple operating systems to share the processor resources efficiently and safely, many processors now support hardware virtualization. You will need to enable this in BIOS. You can enter the BIOS configuration often by pressing the ESC, DEL, F2, or F12 key during system booting. For Intel chips, the name for the hardware virtualization option is often called “Intel’s VT-x”. To do this in Windows 8, follow the steps 1
  2. Download a copy (ISO image) of the operating system you want to install, such as Ubuntu. The 64 bit version is used here for demonstration purposes.
  3. Download and install VirtualBox and, optionally, the Extension Pack.
  4. After installation, run VirtualBox as administrator, click button “New” to create a new virtual machine.
  5. You can choose whatever Name for the virtual machine. For OS Type, choose Linux as Operating System, and Ubuntu (64 bit) as Version.
  6. Depending on the total amount of memory, select an appropriate amount of memory you want the virtual machine to be able to use.
  7. If this is the first time you create a new virtual machine, you will need to create a virtual hard drive to be used in the guest OS.
    • In the Virtual Disk Creation wizard that pops up, choose VDI as virtual hard disk file type. The other file types are from other virtual machine software programs; for details, see Chapter 5. Virtual storage#Disk image files (VDI, VMDK, VHD, HDD).
    • You can allow the virtual disk file to grow in size dynamically as it fills up, or to allocate a fix amount of space at its creation. The guest OS will always see the hard disk with a size you specify in the next page, no matter which option you choose. It is only a matter of efficiency.
    • Choose the location to save the virtual disk file and select its size. For a typical Linux installation with additional software we are going to use, the default size should be sufficient. However, selecting a larger size such as 20 or 40 GB could be safer.

    ADVANCED: if you want to be able to both run Ubuntu in VirtualBox under Windows and boot into native Ubuntu or if you already have a dual-boot setup and want to import the Ubuntu installation to VirtualBox, you will need to use raw disks/partitions as virtual disks. Read more about Using a raw host hard disk from a guest

    • Check which partitions you will be using:
    C:\Program Files\Oracle\VirtualBox> VBoxManage.exe internalcommands listpartitions -rawdisk \\.\PhysicalDrive0
    • Create vmdk for the whole disk
    C:\Program Files\Oracle\VirtualBox> VBoxManage.exe internalcommands createrawvmdk -filename C:\somewhere\ubuntu.vmdk -rawdisk \\.\PhysicalDrive0 -register

    or create vmdk for select partitions

    C:\Program Files\Oracle\VirtualBox> VBoxManage.exe internalcommands createrawvmdk -filename C:\somewhere\ubuntu.vmdk -rawdisk \\.\PhysicalDrive0 -partitions 3,5,6 -register
    • Make a bootable GRUB CD to be used during the booting phase of the guest OS:

    mkdir -p iso/boot/grub cp /boot/grub/grub.cfg iso/boot/grub grub-mkrescue -o grub.iso iso And copy “grub.iso” to your host OS and mount it as CD during booting (either directly to a shared folder or to a USB flash drive, etc.).

  8. Click “Settings”, select “Storage” from the left panel, you can choose the Ubuntu iso image to be mounted as CD/DVD (often the entry belonging to Controller: IDE) for the guest OS. Save the settings.
  9. Click “Start” to boot the guest OS, now consider what happens inside VirtualBox as happening in another real machine, and install the guest OS as you would for a real machine. This means you might need to press the ESC, DEL, F2, or F12 key to make it boot from CD.
  10. After installing the guest OS, boot into it, and then select Devices -> Install Guest Additions from the menu of the VirtualBox window containing the running guest system. This will install software that will offer the guest OS a few nice features, see Chapter 4. Guest Additions.
  11. After installing the Guest Additions, you can select Devices -> Shared Folders to add folders from your host OS (Windows) that you want the guest OS (Ubuntu) to be able to access. You can make them permanent and auto-mount. To see if auto-mount works, use “mount” or “df -h” and check their output. HOWTO: Use Shared Folders explains a little bit more on how to use shared folders in Linux guest OS.


Comments powered by Disqus