Wednesday, October 9, 2013

Creating logical partition on Exalogic X3-2 ECHO vServer using LVM

I switched to using the recently announced Exalogic X3-2 Echo (2.0.6.0.0) guest template for packaging the application software VM. However, on trying to increase the disk space as in the Navstar (2.0.4.0.0) template version using the modifyjeos tool (version 1.1.0-17), I ran into the the following error:

# modifyjeos -f System.img -P App.img 6144 /u01 -S 2048 -n EL_ECHO_MYAPP_2.0_VM_TEMPLATE
Starting VM image reconfiguration...
ERROR: Unknow filesystem.

No detailed messages other than the single line below were logged to /var/log/modifyjeos.log
       ...modifyjeos version 1.1.0-17 starting
 
I later learnt that modifyjeos does not support LVM and this is one of the new feature in Exalogic ECHO (2.0.6.0.0) release. Using Logical Volume Manager (LVM) is recommended to increase/create the virtual disk space. Here are the steps followed to prepare the Exalogic Echo guest VM instance for creating a logical partition to host the application software.


Creating '/u01' logical partition on a guest Exalogic X3-2 ECHO vServer using LVM
-----------------------------------------------------------------------------------
1. From eDelivery.oracle.com download "Oracle Exalogic 2.0.6.0.0 Base Guest Template for Exalogic Linux x86-64 (64 bit)"
- Select product pack [Oracle Fusion Middleware -> Linux x86-64 -> Oracle Exalogic Elastic Cloud Software 11g Media Pack]
2. Extract the Exalogic Template contents to a directory location (say /Exalogic/BASE) on your OVM Server 3.2
(Xen hypervisor ) installation
# mkdir -p /Exalogic/BASE
# pwd
/Exalogic/BASE
BASE]# ls
System.img vm.cfg
3. Create the disk image 'MyApp.img' size by creating a sparse file (http://en.wikipedia.org/wiki/Sparse_file)
# dd if=/dev/zero of=MyApp.img bs=1 count=0 seek=8GB
4. Change the path to the virtual disk in the vm.cfg file, as follows:
disk = ['file:/OVS/seed_pool/OVM_simple_/System.img,hda,w'] to
disk = ['file:/Exalogic/BASE/System.img,hda,w',
'file:/Exalogic/BASE/MyApp.img,hdb,w']
- Configure xend-config.sxp on the OVM server to use bridge networking as needed
5. Start the Exalogic Echo Guest VM by running the following Xen command:
# cd /Exalogic/BASE
# xm create vm.cfg -c
- Login as 'root/ovsroot' to the guest VM
6. Find out about VM instance hard disks
# fdisk -l
Disk /dev/xvda: 6292 MB, 6292504576 bytes
255 heads, 63 sectors/track, 765 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/xvda1 * 1 13 104391 83 Linux
/dev/xvda2 14 765 6040440 8e Linux LVM
Disk /dev/xvdb: 8000 MB, 8000000000 bytes
255 heads, 63 sectors/track, 972 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/xvdb doesn't contain a valid partition table
Disk /dev/dm-0: 5637 MB, 5637144576 bytes
255 heads, 63 sectors/track, 685 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/dm-0 doesn't contain a valid partition table
Disk /dev/dm-1: 536 MB, 536870912 bytes
255 heads, 63 sectors/track, 65 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/dm-1 doesn't contain a valid partition table
7. Examine the current partitioning by running the following command
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
5.1G 3.3G 1.6G 68% /
/dev/xvda1 99M 23M 71M 25% /boot
tmpfs 4.0G 0 4.0G 0% /dev/shm
8. Examine the Volume Group Info:
# vgdisplay
VG Name VolGroup00
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size 5.75 GB
PE Size 32.00 MB
Total PE 184
Alloc PE / Size 184 / 5.75 GB
Free PE / Size 0 / 0
VG UUID c2a4OZ-tlKy-yCqe-640d-b5cI-V6MM-mldKY9
- goal is to extend VolGroup00 with the unpartitioned free space on disk partition /dev/xvdv
9. Examine disk partition /dev/xvdb to extend the Volume Group size
# fdisk /dev/xvdb
Command (m for help): p
Disk /dev/xvdb: 8000 MB, 8000000000 bytes
255 heads, 63 sectors/track, 972 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
- we have some unpartitioned free space (972 cylinders)
10. Create a new partition for the logical Volume using fdisk and change the filesystem type of it to '8e' (Linux LVM)
# fdisk /dev/xvdb
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-972, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-972, default 972): +6000M
Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)
Command (m for help): p
Disk /dev/xvdb: 8000 MB, 8000000000 bytes
255 heads, 63 sectors/track, 972 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/xvdb1 1 730 5863693+ 8e Linux LVM
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
11. Create a new Physical Volume to use this new partition:
# pvcreate /dev/xvdb1
Writing physical volume data to disk "/dev/xvdb1"
Physical volume "/dev/xvdb1" successfully created
12. Examine the Physical Volumes Info:
# pvdisplay
--- Physical volume ---
PV Name /dev/xvda2
VG Name VolGroup00
PV Size 5.76 GB / not usable 10.87 MB
Allocatable yes (but full)
PE Size (KByte) 32768
Total PE 184
Free PE 0
Allocated PE 184
PV UUID SaMlQo-Ct55-8IhX-ZEaf-rT4X-gISK-XEwdvc
"/dev/xvdb1" is a new physical volume of "5.59 GB"
--- NEW Physical volume ---
PV Name /dev/xvdb1
VG Name
PV Size 5.59 GB
Allocatable NO
PE Size (KByte) 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID I16Mx7-WotK-OfYv-pRxM-Zqlg-191Q-9BB9Zb
- Alternatively, you can run the following command on the vServer
# cat /proc/partitions
major minor #blocks name
202 0 6145024 xvda
202 1 104391 xvda1
202 2 6040440 xvda2
202 16 7812500 xvdb
202 17 5863693 xvdb1
253 0 5505024 dm-0
253 1 524288 dm-1
13. Create a volume group for the new physical volume:
# vgcreate myVolGroup /dev/xvdb1
Volume group "myVolGroup" successfully created
- Alternatively, Extend VolGroup00 with this new Physical Volume if you do not wish to create a new Volume group
# vgextend /dev/VolGroup00 /dev/xvdb1
Volume group "VolGroup00" successfully extended
14. Activate the new volume group
# vgchange -a y myVolGroup
0 logical volume(s) in volume group "myVolGroup" now active
15. Examine the Volume Group Info again:
# vgdisplay
--- Volume group ---
VG Name myVolGroup
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 1
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 1
Act PV 1
VG Size 5.59 GB
PE Size 4.00 MB
Total PE 1431
Alloc PE / Size 0 / 0
Free PE / Size 1431 / 5.59 GB
VG UUID AlUOEU-ztlO-4U3a-PCSy-A0kU-NFzE-1MVzw0
--- Volume group ---
VG Name VolGroup00
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size 5.75 GB
PE Size 32.00 MB
Total PE 184
Alloc PE / Size 184 / 5.75 GB
Free PE / Size 0 / 0
VG UUID c2a4OZ-tlKy-yCqe-640d-b5cI-V6MM-mldKY9
16. Create logical Volume partition giving the name of a new logical volume, its size, and the volume group it will live on
# lvcreate -L 5G myVolGroup -n myLogVol
Logical volume "myLogVol" created
- INFO: command to get a list of all logical volumes installed on the system
# lvs
17. Change the type of the new logical volume to ext3
# mkfs.ext3 /dev/myVolGroup/myLogVol
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
655360 inodes, 1310720 blocks
65536 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1342177280
40 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 39 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
18. Mount the logical volume to say '/u01' to host the application software
# mkdir -p /u01
# mount /dev/myVolGroup/myLogVol /u01/
- Verify whether /u01 has the modified space
# df -h
/dev/mapper/VolGroup00-LogVol00
5.1G 3.3G 1.6G 68% /
/dev/xvda1 99M 23M 71M 25% /boot
tmpfs 4.0G 0 4.0G 0% /dev/shm
/dev/mapper/myVolGroup-myLogVol
5.0G 139M 4.6G 3% /u01
19. After the Volume is partitioned and file system created, mount it using the /etc/fstab file on the vServer to make the
filesystem accessible
# vi /etc/fstab (e.g. add the following entry)
/dev/myVolGroup/myLogVol /u01 ext3 defaults 1 1
20. Reboot the VM instance and verify that all changes are intact. The Echo VM instance is now ready for installing your
application software on '/u01' partition and packaging the template.
Refer the official Exalogic X3-2 Elastic Cloud Administrator's Guide "Managing LVM Partitions on Guest vServers" for more details on this subject