Sunday, January 18, 2015

Ubuntu - VirtualBox - Setup - Add a new hard drive to Ubuntu VM

Environment:

OS: Ubuntu 14.04 guest VM
VirtualBox: 4.3.6 on Windows 7 host




Add a hard drive in VirtualBox:

  1. Go to VirtualBox Manager
  2. Select the VM where drive needs to be added and click 'Settings' (ctrl+S)
  3. On settings dialog, click on 'Storage' from left navigation panel. 'Storage Tree' and 'Attributes' will be shown at right side (see Pic-01)
  4. Under 'Storage Tree', select 'Controller: SATA', 'Add CD/DVD Device' and 'Add Hard Disk' icons will be displayed (see Pic-01)
  5. Click on 'Add Hard Disk' (see Pic-01)
  6. Pic-01: Settings dialog box
  7. Click on 'Create New Disk' on popup (see Pic-02)
    Pic-02
  8. Select 'VDI - VirtualBox Disk Image' and Click Next
    Pic-03: HDD file type
  9. Select hard drive file type and click Next
    Pic-04: Storage on Hard drive
  10. Specify file lcoation and size and click Create. It will take few minutes to finish. 

Make the hard drive available in Ubuntu:
  1. Check drives
    Command: "sudo fdisk -l"
    Output:
    Disk /dev/sdb: 107.4 GB, 107374182400 bytes255 heads, 63 sectors/track, 13054 cylinders, total 209715200 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x00000000Disk /dev/sdb doesn't contain a valid partition table
  2. Create partition
    Command: "sudo fdisk /dev/sdb"
  3. type 'n' to create partition
  4. Next select partition type p=Primary, e=Extended
  5. Specify number of partitions
  6. I had to create two partitions. For me next two options were to specify first sector and last sector where I selected default.
  7. 'w' to write the changes
  8. 'q' to quite fdisk
  9. Update kernel with changes
    Command: "sudo partprobe /dev/sdb"
  10. Format hard drive
    Command: "sudo mkfs /dev/sdb2 -t ext4"
  11. Create a directory for mount point. Following convention to create under /mnt
    Command: "sudo mkdir /mnt/sdb2"
  12. Make the folder writable
    Command: "sudo chmod 777 /mnt/sdb2"
  13. Mount drive to folder
    Command: "sudo mount /dev/sdb2 /mnt/sdb2 -t ext4"

Monday, January 12, 2015

VirtualBox - Ubuntu - create and share a SharedFolder in Ubuntu VM

Environment:
OS: Ubuntu 14.04 on Guest VM
VirtualBox: 4.3.6 on Host Machine Windows 7



Steps to follow:


  • Need to make sure "Virtualbox Guest Additions" is installed (see Resource-01)
  • Creating a folder in Host Windows
  • Create a 'Shared Folder' in VirtualBox
    1. Start the VM and go to 'Devices > Shared Folders Settings...'
    2. On Settings dialog, click on 'Shared Foldrers' which will show existing shared folders at right (see pic-01)
    3. Click on 'Add new shared folder definition' icon (see pic-01)
      Pic-01
    4. Specify 'folder path', 'Folder Name' (see pic-02) and click 'Ok' 
      Pic-02
    5. Click 'Ok' on Settings dialog

  • Prepare Ubuntu VM

    • Create a folder where host folder with be mapped to 
    • Run mount command - "sudo mount -t vboxsf -o uid=$UID,gid=$(id -g) SharedWithVMs ~/SharedWithVMs". In this case shared folder in VirtualBox and folder in Ubuntu VM having same name
Resources:
  1. How to install "VirtualBox Guest Additions" - http://peerprogrammer.blogspot.com/2015/01/virtual-box-setup-install-guest.html


Saturday, January 10, 2015

Eclipse - Ubuntu - Setup - Install Eclipse on Ubuntu OS

Environment:
OS: Ubuntu 14.04 64-bit
Eclipse: Luna 4.4 64-bit


Install Eclipse:


  • Make sure Java is installed. I have another post how to do so (see Resource-01)
  • Download Eclipse installer. URL="http://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/luna/R/eclipse-jee-luna-R-linux-gtk-x86_64.tar.gz"
  • Extract the file.
    using command in terminal: tar -zxvf eclipse-jee-luna-R-linux-gtk-x86_64.tar.gz
    using Archive Manager UI tool
  • Copy extracted folder to "/opt".
    Command: sudo mv eclipse /opt
Start eclipse:
  • From terminal
    1. Open terminal (shortcut ctrl+alt+t)
    2. Go to location "/opt/eclipse"
    3. Run executable "./eclipse"
  • From file browser
    1. Open file browser
    2. Go to location "/opt/eclipse"
    3. Double click on eclipse icon
  • Create desktop file and install. This will help opening eclipse from unity launcher (see Resource-02, Resource-03)
    1. Create eclipse desktop file
      Command: "gedit eclipse.desktop"
    2. Type following the file

      [Desktop Entry]
      Name=Eclipse Luna
      Type=Application
      Exec=/opt/eclipse/eclipse
      Terminal=false
      Icon=/opt/eclipse/icon.xpm
      Comment=Java Integrated Development Environment
      NoDisplay=false
      Categories=Development;IDE;
      Name[en]=Eclipse Luna

      Note: See Note-01, Note-03 for more information if desktop file not behaving as expected
    3. Execute the desktop file
      Command: "sudo desktop-file-install eclipse.desktop"
    4. Give eclipse permission to modify osgi file
      Command: "sudo chown -R $USER:$USER
      /opt/eclipse/configuration/org.eclipse.osgi
      "
    5. Give desktop file permission to execute (see Note-02)
      Command: "chmod a+x eclipse.desktop"
Notes:
  1. If icon is not displayed - icon file name cannot have extension unless full path is specified
  2. If desktop file is not displaying name mentioned in file. Showing 'eclipse.desktop' instead of 'Eclipse Luna' - desktop file's execution permission not set.
  3. Getting 'There was an error launching the application' - value mention in desktop file for Exec is not correct

Resources:
  1. How to install java - http://peerprogrammer.blogspot.com/2014/02/java-setup-install-java-in-ubuntu.html
  2. unity launcher - https://help.ubuntu.com/community/UnityLaunchersAndDesktopFiles
  3. How to create desktop file - http://askubuntu.com/questions/281293/creating-a-desktop-file-for-a-new-application

Friday, January 9, 2015

Virtual Box - Ubuntu - Setup - Install guest addition and make auto resize work in Ubuntu

Background:
This article helps to install VirtualBox guest addition and setup auto-resize window feature.

Environment:
1. Ubuntu - 14.04
2. VirtualBox - 4.3.6
 
 

Guest Additions offer the following features

1. Mouse pointer integration  Means pressing the Host key is no longer required to “free” the mouse from being captured by the guest OS as you used to do.
2. Shared foldersEasy to share files between host and guest machine just like you do in Windows network share.VirtualBox treat a certain host directory as a shared folder, and VirtualBox will make it available to the guest operating system as a network share.
3. Better video supportCustom video drivers shipped with VirtualBox Guest Additions provides extra high and non-standard video modes as well as accelerated video performance. With Guest Additions,3D graphics and 2D video for guest applications can be accelerated.

4. Time synchronization
Enables synchronization of host system’s time with guest operating system.

5. Shared clipboard
With the Guest Additions installed, the clipboard of the guest operating system can optionally be shared with your host operating system 
 
 
Steps to follow:
 
  • Install guest addition - option-01
    • Click on Install Guest Additions… from the Devices menu on VirtualBox screen, then choose Run when requested. This should start virtualBox guest addition installation automatically and just need to follow on screen instructions.
 
  • Install guest addition - option-02
    1. Open terminal (on Applications/System/Terminal or on Applications/Terminal or CTRL+ALT+T)
    2. Update APT database
      sudo apt-get update; (password might require)
    3. Install the latest security updates
      sudo apt-get upgrade;
    4. Install required packages
      sudo apt-get install build-essential module-assistant;
    5. Configure system for building kernel modules
      sudo m-a prepare;
    6. Click on Install Guest Additions… from the Devices menu on VirtualBox screen, then choose to browse the content of the CD when requested.
    7. Run
      sudo sh /media/cdrom/VBoxLinuxAdditions.run
    8. Follow the instructions on screen
 
 
  •  Setup auto-resize window
    Command: sudo apt-get install virtualbox-guest-dkms virtualbox-guest-utils virtualbox-guest-x11
 
 
Resources:
1. Link 01 - http://sharadchhetri.com/2014/10/07/ubuntu-14-04-install-virtualbox-guest-additions-also-create-videos/