Showing posts with label Ubuntu. Show all posts
Showing posts with label Ubuntu. Show all posts

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


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/ 
 
 
 
 

Sunday, February 2, 2014

Java - Setup - Install Oracle JDK in Ubuntu

JDK Version: Java 7 (and 1.6.0_45 64bit)
Operation System: Ubuntu 14.04 (and Ubuntu 12.04 64 bit)



Check if java is installed:
Command: java -version

If below message is displayed on screen, meaning java not installed

The program 'java' can be found in the following packages:
 * default-jre
 * gcj-4.8-jre-headless
 * openjdk-7-jre-headless
 * gcj-4.6-jre-headless
 * openjdk-6-jre-headless

Try: apt-get install



How to remove openJDK: 
This step might be needed if openJDK is not preferred and want to install Oracle JDK.

Command: "sudo apt-get purge openjdk-\*"

Install JDK - steps to follow :
  • Install packages directly. Below commands are for Java 7. Might need to change with 'Java7' to appropriate version (like Java8).
    Commands:
    sudo add-apt-repository ppa:webupd8team/java
    sudo apt-get update
    sudo apt-get install oracle-java7-installer
    sudo apt-get install oracle-java7-set-default
  • Using .bin extension installer (this I tried with Java 6 on Ubuntu 12 earlier)
    1. Download JDK version from Oracle. File name is 'jdk-6u45-linux-x64.bin'
    2. Copy downloaded folder to '/usr/local/java'. (need to create the folder if desn't exist)Command: "sudo mkdir -p /usr/local/java" (to create folder)"sudo cp jdk-6u45-linux-x64.bin /usr/local/java/"
    3. Set the executable permissionsCommand: "sudo chmod a+x jdk-6u45-linux-x64.bin"
    4. Add java to the path.
      C
      ommand:"sudo gedit /etc/profile" (gedit editor is used)
      Lines need to be added in the profile. 
      JAVA_HOME=/usr/local/java/jdk1.6.0_45PATH=$PATH:$HOME/bin:$JAVA_HOME/binJRE_HOME=/usr/local/java/jdk1.6.0_45/jrePATH=$PATH:$HOME/bin:$JRE_HOME/binexport JAVA_HOMEexport JRE_HOMEexport PATH
    5. Inform Ubuntu where to look for JDKCommand:"sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jdk1.6.0_45/jre/bin/java" 1"
      "sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/local/java/jdk1.6.0_45/bin/javac" 1
      "
      "sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/local/java/jdk1.6.0_45/bin/javaws" 1
      "
    6. Inform Ubuntu Linux system that Oracle Java JDK must be the default JavaCommand: "sudo update-alternatives --set java /usr/local/java/jdk1.6.0_45/jre/bin/java"
      "
      sudo update-alternatives --set javac /usr/local/java/jdk1.6.0_45/bin/javac"
      "
      sudo update-alternatives --set javaws /usr/local/java/jdk1.6.0_45/bin/javaws"
    7. Load profile changesCommand:  "./etc/profile"

Test java successfully installed:

Command: "java -version"

Output: 
java version "1.7.0_72"
Java(TM) SE Runtime Environment (build 1.7.0_72-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.72-b04, mixed mode)