Exalogic 2.0.1 Tea Break Snippets - Creating a ModifyJeOS VirtualBox

Following on from my previous blog entry "Modifying the Base Template" I decided to put together a quick blog to show how to create a small VirtualBox, guest, that can be used to execute the ModifyJeOS and hence edit you templates. One of the main advantages of this is that Templates can be created away from the Exalogic Environment. For the Guest OS I chose Oracle Linux 6u3 and decided to create it as a basic server because I did not require a graphical interface but it's a simple change to create it with a GUI.

Required Software

Creating the VM

I'll assume that the reader is experienced with Virtual Box and installing Oracle Linux and hence will make this section brief.

Create VirtualBox Guest

Create a new VirtualBox Guest and select oracle Linux 64 bit. Follow through the create process and select Dynamic Disk Size and the default 12GB disk size. The actual image will be a lot smaller than this but the Oracle Linux install will fail with insufficient disk space if you attempt a smaller size.

VBox

Once the guest has been created attach the previously downloaded Oracle Linux 6u3 iso to the cd drive and start the guest.

Install Oracle Linux

On starting the guest the system will boot off the associated Oracle Linux 6u3 iso and take you through the standard installation process. Select all the appropriate information but when you reach the installation type select Basic Server because we do not need that additional packages and only need to access through the command line interface.

OEL

Complete the installation and reboot the Guest. At this point we now have a basic Oracle Linux server running.

Installing Guest Add-ons

Before we can easily access the Guest we will need to add the VirtualBox guest add-ons. These will provide better keyboard and mouse integration and allow access the shared folders on the host machine. Before we can do this we will need to do the following:

  1. Enable Networking.
  2. Install additional rpms. 

To enable the networking (eth0), that appears to be disabled by default, we can execute:

ifup eth0

Network

This will start the eth0 connection but once the Guest is rebooted the network will be down again. To resolve this you will need to edit the /etc/sysconfig/network-scripts/ifcfg-eth0 file and change the ONBOOT parameter to "yes".

Now we have enabled the network we will need to install a number of addition rpm. First we will need to configure the yum repository as follows:

[ol6_latest]
name=Oracle Linux $releasever Latest ($basearch)
baseurl=http://public-yum.oracle.com/repo/OracleLinux/OL6/latest/$basearch/
gpgkey=http://public-yum.oracle.com/RPM-GPG-KEY-oracle-ol6
gpgcheck=1
enabled=1

[ol6_ga_base]
name=Oracle Linux $releasever GA installation media copy ($basearch)
baseurl=http://public-yum.oracle.com/repo/OracleLinux/OL6/0/base/$basearch/
gpgkey=http://public-yum.oracle.com/RPM-GPG-KEY-oracle-ol6
gpgcheck=1
enabled=0

[ol6_u1_base]
name=Oracle Linux $releasever Update 1 installation media copy ($basearch)
baseurl=http://public-yum.oracle.com/repo/OracleLinux/OL6/1/base/$basearch/
gpgkey=http://public-yum.oracle.com/RPM-GPG-KEY-oracle-ol6
gpgcheck=1
enabled=0

[ol6_u2_base]
name=Oracle Linux $releasever Update 2 installation media copy ($basearch)
baseurl=http://public-yum.oracle.com/repo/OracleLinux/OL6/2/base/$basearch/
gpgkey=http://public-yum.oracle.com/RPM-GPG-KEY-oracle-ol6
gpgcheck=1
enabled=0

[ol6_u3_base]
name=Oracle Linux $releasever Update 3 installation media copy ($basearch)
baseurl=http://public-yum.oracle.com/repo/OracleLinux/OL6/3/base/$basearch/
gpgkey=http://public-yum.oracle.com/RPM-GPG-KEY-oracle-ol6
gpgcheck=1
enabled=0

[ol6_UEK_latest]
name=Latest Unbreakable Enterprise Kernel for Oracle Linux $releasever ($basearch)
baseurl=http://public-yum.oracle.com/repo/OracleLinux/OL6/UEK/latest/$basearch/
gpgkey=http://public-yum.oracle.com/RPM-GPG-KEY-oracle-ol6
gpgcheck=1
enabled=1

[ol6_UEK_base]
name=Unbreakable Enterprise Kernel for Oracle Linux $releasever ($basearch)
baseurl=http://public-yum.oracle.com/repo/OracleLinux/OL6/UEK/base/$basearch/
gpgkey=http://public-yum.oracle.com/RPM-GPG-KEY-oracle-ol6
gpgcheck=1
enabled=0

Once the repository has been edited we will need to execute the following yum commands:

yum update
yum install gcc
yum install kernel-uek-devel
yum install kernel-devel
yum install createrepo

At this point we now have all the additional packages required to install the VirtualBox Guest Add-ons. So select Devices->InstallGuest Additions on you running guest:

Add-ons

This will simply place the VirtualBoxGuestAdditions.iso in the virtual cd and we will need to execute the following before we can run them.

mkdir /media/cdrom
mount -t iso9660 -o ro /dev/cdrom /media/cdrom
cd /media/cdrom/
ls
./VBoxLinuxAdditions.run

add-ons

This will initiate the install and kernel rebuild. What you will notice is that during the installation a Failed will be displayed but this is simply because we have no graphical components.

Failed

At this point we the installation will also have added the vboxsf group to the system and to access any shared folders we will create our user will need to be a member of this group an so the next stage is to add the root user to this group as follows:

usermod -G vboxsf root

cat /etc/group
cat /etc/passwd
init 0

Now simply shutdown the guest and add the Shared folder within your guests settings.

Install ModifyJeOS

Once the shared folder has been added restart the guest and change directory into the shared folder (/media/sf_<folder name>). For the next step I am assuming the ModifyJeOS rpms are located in the shared folder. We can simply execute:

rpm -ivh ovm-modify-jeos-1.1.0-17.el5.noarch.rpm

# Test with

modifyjeos

modifyjeos

Using ModifyJeOS

I have a modified MountSystemImg.sh script that should be copied into the /root/bin directory (you may need to create this) and from here it can be executed from any location:

MountSystemImg.sh
#!/bin/sh

# The script assumes it's being run from the directory containing the System.img

# Export for later i.e. during unmount
export LOOP=`losetup -f`
export SYSTEMIMG=/mnt/elsystem
export TEMPLATEDIR=`pwd`
# Make Temp Mount Directory
mkdir -p $SYSTEMIMG
# Create Loop for the System Image
losetup $LOOP System.img
kpartx -a $LOOP
mount /dev/mapper/`basename $LOOP`p2 $SYSTEMIMG
#Change Dir into mounted Image
cd $SYSTEMIMG
echo "######################################################################"
echo "### ###"
echo "### Starting Bash shell for editing. When completed log out to ###"
echo "### Unmount the System.img file. ###"
echo "### ###"
echo "######################################################################"
echo
bash
cd ~
cd $TEMPLATEDIR
umount $SYSTEMIMG
kpartx -d $LOOP
losetup -d $LOOP
rm -rf $SYSTEMIMG

This script will simple create a mount directory, mount the System.img and then start a new shell in the mounted directory. On exiting the shell it will unmount the System.img. It only requires that you execute the script in the directory containing the System.img. These can be created under the mounted shared directory.

In the example below I have extracted the Base template within the shared folder and then renamed it OEL_40GB_ROOT before changing into that directory and executing the script.

mount

This entry was originally posted on the The Old Toxophilist Site. 

Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
About

The primary contributors to this blog are comprised of the Exalogic and Cloud Application Foundation contingent of Oracle's Fusion Middleware Architecture Team, fondly known as the A-Team. As part of the Oracle development organization, The A-Team supports some of Oracle's largest and most strategic customers worldwide. Our mission is to provide deep technical expertise to support various Oracle field organizations and customers deploying Oracle Fusion Middleware related products. And to collect real world feedback to continuously improve the products we support. In this blog, our experts and guest experts will focus on Exalogic, WebLogic, Coherence, Tuxedo/mainframe migration, Enterprise Manager and JDK/JRockIT performance tuning. It is our way to share some of our experiences with Oracle community. We hope our followers took away something of value from our experiences. Thank you for visiting and please come back soon.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today