Tutorials

1, 2, 3, Ubuntu

How to install Ubuntu and Windows for OSS Developing Purposes

This pages describes how to get Ubuntu installed on a PC for software developing purposes. The main objective is to get a system that supports switching back and forth between Linux and Windows to develop and test OSS software on both platforms. This includes the installation of a virtual machine running Windows.

The Ubuntu installation procedure is organized in the following three main stages:

  1. Ubuntu Installation
  2. Ubuntu Tweaking
  3. Additional Software

The Windows installation procedure is organized in the following three main stages:

  1. Virtual Box Installation
  2. Windows 7 Installation
  3. Visual Studio Installation

The background story is that I used to be pretty content with developing on a MacBook Pro. The main focus of my open-source development projects was Mac and Linux, but I also needed to test my software on a Windows platform, since I am mostly using Qt as underlying UI. For the latter purpose I had another ASUS laptop with Windows 7 around. This had been working very well for quite a while until the file system of my Windows box just passed Jordan. When trying to reinstall Windows 7, I needed to identify all necessary drivers due to the lack of a recovery DVD. After numerous failing attempts, I remembered how easy the installation of my Linux box was. It was setup in less than an hour and has been working ever since as a reliable and speedy work horse.

At that point I decided, that I won’t try to to install Windows any more. Period. I’d rather install Ubuntu as primary operating system and have a virtual machine running Windows 7 (or XP). If Windows will ever crash again, I will just happily press the “roll back” button of the virtual machine.

So here is what I did in short:

  • Installed Ubuntu Desktop 14.04 LTS 64bit
  • Installed Virtual Box
  • Installed Windows 7 in a virtual machine.
  • Installed MSVC 2010 on the VM.
  • Took a snapshot of the virtual machine.
  • Saved a clone of the VM on an external hard drive that gets a daily backup.

1) Here is the Ubuntu installation in more detail:

  1. Get Ubuntu 14.04 LTS 64bit from www.ubuntu.com.
    1. In particular get the Ubuntu 14.04 LTS Desktop AMD64 installer iso image.
  2. Prepare a DVD containing the Ubuntu iso image. To burn the DVD I used the disk utility of my MacBook Pro.
  3. Change the boot order in the ASUS bios setup to first boot from CD/DVD. To enter the ASUS bios one needs to press and hold F2 during boot.
  4. Boot from the disc drive.
  5. After booting into the Ubuntu installer there is a popup window with two options. We select the “Install Ubuntu” option.
  6. In the installer window we select the following options:
    1. Select the option “Install third party software”.
    2. If you have your computer connected to the internet via ethernet cable, select “Download software updates while installing”.
  7. Installation method is “Replace Windows”.
  8. Select the location (in my case “Nuernberg”).
  9. Select “English (US)” keyboard.
  10. Enter name, login name and password.
  11. After ca. 15 minutes of installation, eject the DVD and click “Restart” to reboot your system.

2) Some fine tuning after we have booted into Ubuntu:

  1. In the top right menu, click at the network symbol and select your WLAN connection from the popup list.
  2. In case we have an NVIDIA graphics chip, we install the NVIDIA drivers using the Unix terminal:
    1. Open a terminal with the keyboard short-cut Ctrl-Alt-T.
    2. In the terminal type:
      1. sudo apt-get install nvidia-331
      2. Note: the above package is already installed if we checked “third party software” during Ubuntu installation.
  3. We also install some useful graphics tools:
    1. sudo apt-get install mesa-utils
  4. To find out about the actual installed graphics drivers, type:
    1. glxinfo | grep "OpenGL renderer string"
  5. To test the driver installation, we run the following graphics program that shows a 3D animation of three rotating gears:
    1. glxgears

3) Additional software packages

  1. Software development packages to be installed on the command line:
    1. Install Tom’s C shell (tcsh):
      1. sudo apt-get install tcsh
    2. Install the GNU C++ compiler:
      1. sudo apt-get install g++
    3. Install the Subversion software revisioning tool:
      1. sudo apt-get install subversion
    4. Install the CMake build system:
      1. sudo apt-get install cmake cmake-curses-gui
    5. OpenGL related development packages:
      1. sudo apt-get install freeglut3-dev mesa-utils
    6. We also install some common development packages:
      1. sudo apt-get install libjpeg-dev libpng-dev
    7. We also install some not so common development packages (at your option):
      1. sudo apt-get install libssl-dev
      2. sudo apt-get install libcurl4-openssl-dev libgdal-dev
    8. We also install the Qt4 development package:
      1. sudo apt-get install libqt4-dev
    9. We also install a ssh server so that we can log onto our Linux box via ssh:
      1. sudo apt-get install openssh-server
    10. We also install some helpful utilities and programs:
      1. sudo apt-get install wget curl git kate
  2. Optional graphical packages to be installed through the Software Center
    1. System Load Indicator
    2. Emacs24
    3. Gimp
    4. Inkscape
    5. ImageMagick
    6. KDevelop4

In case we need Qt5 instead of Qt4 for development, we install the Qt5 development packages from source (prebuilt packages are not recommended):

Some development packages like GDAL require libiconv. In such a case we install libiconv from source:

wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.11.tar.gz
tar zxf libiconv-1.11.tar.gz 
cd libiconv-1.11/

./configure 
make
sudo make install

4) Testing

Now our system is basically setup and ready for OSS development. It took only about an hour or so.

To test that everything went fine, we check out and compile a small OSS software package with svn/cmake/g++:

svn checkout http://svn.code.sf.net/p/libsquish/code/trunk libsquish
cd libsquish
cmake .
make
sudo make install

5) Installation of Virtual Box:

sudo apt-get install virtualbox

The above command installs VirtualBox 4.3. Virtual Box is available as desktop application in the search bar: Click at the top left Ubuntu icon and type “virtual box” on the search line. Then double click on “Virtual Box”.

6) Installation of Windows on a virtual machine:

  1. Launch Virtual Box.
  2. Click at the “New” button to create a new virtual machine (VM):
    1. Choose “Windows” as VM type.
    2. As VM size, select about a quarter of what your PC has. E.g. select 1024 MB on a machine with 4GB of RAM.
    3. Create a virtual hard drive of 32GB with otherwise default settings.
  3. Check VM settings:
    1. In the Virtual Box settings, make sure that the VM network mode is set to “NAT” and that the emulated network adapter is set to “Intel PRO/1000 MT Desktop” in case you are running Windows 7 or Vista. On Windows XP you need to choose the “PCnet-FAST III” adapter.
  4. Trouble Shooting:
    1. If you happen to experience “mouse freezes” while running Virtual Box, then switch to the console (Ctrl-Alt-F1) and back (Ctrl-Alt-F7).
  5. Start the virtual machine with the “Start” button.
    1. When asked, insert your Windows installer disc into your physical disc drive or mount a respective iso image as a virtual disc device. The latter is faster.
    2. Standby while the VM boots from the Windows installation disc and performs the installation…
      1. As for myself, I have chosen to install Windows 7 Professional (32 bit) /w Service Pack 1 from an iso image.
      2. This took about 30 minutes!

7) Finetuning Windows 7 (or XP):

  1. Change screen resolution
    1. Right-click at the desktop and choose “Screen resolution” from the context-menu (“Properties→Settings” on XP). Then set the resolution to 1024×768 or whatever you may find appropriate.
    2. Now press Right-Ctrl-F to switch to fullscreen mode.
    3. Press Right-Ctrl alone to uncapture the mouse.
  2. Guest additions
    1. It is recommended (although not necessary) to install the guest additions, which contain additional drivers for ease of use of the VM, as follows:
    2. Goto the VM’s menu, click at “Devices” and select “Insert Guest Additions CD image”. This mounts a CD containing additional drivers for your VM. Just wait until the driver installer starts automatically. Most notably a graphics driver for unconstrained screen sizes and extended copy&pasting from host to guest is installed. Also drivers for various network cards and media devices are installed that might not be part of the actual guest system.
  3. Virtual Box compatibility
    1. Windows 7 works properly on Ubuntu 13.10 with Virtual Box 3.1.8 and above.
    2. Same for or MacOS X 10.5 Leopard.
  4. Troubleshoot internet
    1. In case your internet connection is not working, try to “ping www.google.com” on the “cmd” command prompt.
    2. If there is no ping from google, then open the “Network and Sharing Center” and click at “Local Area Connection”. Look at the “Details” and check that the IP settings are ok. The IP address should be 10.0.2.x, the gateway 10.0.2.2 and the DNS server 10.0.2.3.
  5. Stopping Automatic Updates
    1. In a virtual machine that is safe behind the host’s firewall, we would like to stop automatic updates that would otherwise alter our working system.
    2. In the “Control Panel” select “System and Security→Windows Update→Change Settings” and set the policy to “Never check for updates”.
    3. And now for a last time, we may perform an update of our system by selecting “System and Security→Windows Update”.
      1. Due to problems with Visual Studio 10, it is not recommended to update your system, if you want to use Visual Studio 10! However, updating is recommended for Visual Studio 2013.
      2. Be aware that updating Windows 7 will amount to 150 updates with about 350MB in total and more than 3 hours of drinking coffee.
  6. Personalize the desktop
    1. Right-click at the desktop and choose “Personalize” from the context-menu. Then set the theme and the desktop background to your personal preferences (“Properties→Themes” resp. “Properties→Background” on XP). I prefer the classic theme with a solid blue background.
    2. I do not like IE. I am installing Firefox right away to get rid of that bloated web browser.
  7. Create a snapshot!!!
    1. Unmount the installer image (“Devices→CD/DVD Devices→Unmount”).
    2. Close the VM window to save the machine state (Right-Ctrl-Q) or simply power-off Windows.
    3. In the VirtualBox main window, click at “Snapshots” and take a snapshot of the actual VM’s state. If anything goes wrong with the VM, you can roll back the state of the machine to a prior snapshot.

8) Installing MSVC++:

  1. Insert your MSVC++ iso image into the virtual disc device of the VM by choosing VM→Menu→Devices→CD/DVD Devices→Choose a virtual CD/DVD disk file.
  2. Open the installer application contained on the virtual disc.
  3. Standby while MSVC is being installed…
    1. When opting to install the latest Visual Studio 2013 it is 7.7 GB of disk space /wo all the optional addons.
    2. Visual Studio 2010 is “only” 4GB.
  4. Finally, create another snapshot!!!

9) Cloning a VM:

If you want to run a virtual machine on a different host you can do it like so:

  • Power-off the machine which you want to clone. A running machine cannot be cloned.
  • Select the “Snapshots” tab of the machine.
  • Create a snapshot of the current machine.
  • Delete all previous snapshots by repeatedly removing the topmost snapshot.
  • Clone the current machine state with the “Sheep” symbol.
    • You must give the cloned machine a different name. The suggested name with the “_clone” extension will suffice.
    • This produces a .vdi file that is located under ~/Virtual Box/ on Unixes or in ~/Library/Virtual Box/ under MacOS X.
  • If you have an old version of Virtual Box like 3.1.6, you need to use the command line tool VBoxManage to clone the machine:
    • VBoxManage clonehd /full/path/to/machine.vdi /full/path/to/clone.vdi
  • Copy that .vdi file to the Virtual Box directory of the host machine you want to run your virtual machine on.
  • Then create a new machine. The process of creating the new virtual machine will be the same as if you were creating a standard virtual machine until you get to the “Virtual Hard Disk” creation screen. You will select “Use Existing Hard Disk”, click the folder icon, navigate to the newly copied .vdi file, select the file in question, and then click “Next”.
  • The new machine will be running in exactly the same fashion, regardless if you copied it from Linux→Linux, Linux→Mac or Mac-Linux, Mac→Windows or the other way round.
  • BTW: The .vdi images compress very well when compressing with tar/gzip:
    • tar zcf VM.tgz VM.vdi

10) Results:

After all is said and done, the entire Ubuntu/Win7 installation consumed about 6GB of disk space for Ubuntu and 20GB for the Windows 7 VM.

For an experienced developer, installing Ubuntu will roughly take about an hour /wo tweaking. Installing Windows 7 on a virtual machine will also take about an hour /wo updating the system. Installing Visual Studio 10 is about 30 minutes /wo updating. Updating will take more than 3 hours. In total be prepared to reserve an entire day for the installation of Ubuntu and the Windows 7 VM.

But more important, reserve an additional day or two for trouble shooting and testing. It took me about 3 days to work around the usual pitfalls and to get everything working as explained above.

UbuntuWinXP MacWin7

11) Backing things up:

As you certainly understand, backing things up is important! If something can go wrong, it will go wrong eventually. In particular when you need it most.

So please be sure, to clone your newly setup VM and copy the .vdi file to a place where it is safe.

For that purpose I personally recommend to have a pair of identical external hard drives, where all your important data is stored on one of the hard drives so that the current machine you are working with does not contain any data that shouldn’t get lost. Then backup the external drive to the other one, by using an automatic incremental backup via rsync as explained in this tutorial.

EOF!

Options: