Oracle VM: Adding a disk to a Guest OS


For my first VM, I used the Oracle Enterprise Linux template provided by Oracle.   Depending on which template you download you either have 4GB or 10GB of disk space configured.

From the README here are the details for two templates.


Template                   Kernel                    VCPU RAM Storage
------------------------   ------------------------- ---- --- -------

OVM_EL5U2_X86_64_PVM_10GB  2.6.18-    2 2GB 10GB
OVM_EL5U2_X86_64_PVM_4GB   2.6.18-    1 1GB 4GB

Depending on how you want to use the VM, this may not be enough space.  So the first thing your going to want to do is add another disk.   As you can see in the screenshot below, from the Virtual Machine tab select the VM you would like to add disk to and click on the configure button.


Once you click on the configure button you will be presented with the configuration screen.  Click on the storage link (tab) and you should see something similar to the following:


Click on the Create New Virtual Disk button and the following window will appear:


As you can see, I have already filled in the requested information. I usually use the mount point I plan on placing this disk under as the Virtual Disk Name .  Above I will be creating a ~10GB disk with the name u01.  Once you click on the Next button you will be provided with a summary screen:


After you click the Confirm button you will be brought back ot the Virtual Machine Configuration screen:


Notice that the disk I created, /u01 has a Disk Status of Creating.  If you login to the Oracle VM Machine your using to host this VM you will see that behind the scenes the dd command is being used to create a 10GB file named u01.img.   Below you can see I am ssh’d into the VM Server under the /OVS/running_pool directory where my VM is located.


Once the disk has finished being created it will be active:


Now that we have added the disk to the VM we need to format and mount it within the guest OS.   Notice the Front-end Device column in the screenshot above.  The value for u01 is xvdb and is the device name we will pass to fdisk to create a partition.   SSH or VNC into your VM as root.

[root@ ~]# fdisk -l
Disk /dev/xvdb: 10.4 GB, 10485760000 bytes
255 heads, 63 sectors/track, 1274 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/xvdb doesn't contain a valid partition table


Above is just a clip of the fdisk –l output showing the device /dev/xvdb and that it doesn’t contain any partitions.  Next create a partition:

[root@ ~]# fdisk /dev/xvdb

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
Partition number (1-4): 1
First cylinder (1-1274, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-1274, default 1274):
Using default value 1274
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.

[root@ ~]# fdisk -l

Disk /dev/xvdb: 10.4 GB, 10485760000 bytes
255 heads, 63 sectors/track, 1274 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

    Device Boot      Start         End      Blocks   Id  System
/dev/xvdb1               1        1274    10233373+  83  Linux

Now that we have a valid partition, format it as an ext3 filesystem:

[root@ ~]# /sbin/mkfs -t ext3 /dev/xvdb1
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
1281696 inodes, 2558343 blocks
127917 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2621440000
79 block groups
32768 blocks per group, 32768 fragments per group
16224 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 27 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

Next label the partition so we don’t have to use the device name in /etc/fstab.  Finally add the partition details in /etc/fstab so that its automatically mounted upon startup and mount the partition:

[root@ ~]# /sbin/e2label /dev/xvdb1 /u01
[root@ ~]# vi /etc/fstab
[root@ ~]# cat /etc/fstab
/dev/VolGroup00/LogVol00 /                       ext3    defaults        1 1
LABEL=/boot             /boot                   ext3    defaults        1 2
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
/dev/VolGroup00/LogVol01 swap                    swap    defaults        0 0
LABEL=/u01              /u01                    ext3    defaults        1 2
[root@ ~]# mount /u01
[root@ ~]# df -k
Filesystem           1K-blocks      Used Available Use% Mounted on
                      10125560   3011540   6591372  32% /
/dev/xvda1              101086     13229     82638  14% /boot
tmpfs                  1048576         0   1048576   0% /dev/shm
/dev/xvdb1            10072456    153696   9407092   2% /u01


Thats it!  To summarize, I used Oracle VM Manager to add a new disk to my VM.  Then I logged into the VM created a partition on the new disk, formatted it, added the details to /etc/fstab and finally mounted it.  Next step, 11G Fusion!


Anonymous said...

nice article, simpe, easy to follow and accurate

Anonymous said...

Nice post

CNC Administrator Oracle said...

Hi, I'm using VM 3.1 with JDEdwards Templates 9.1.
I need to expand the HD, I new hd was created (200GB). Fdisk worked find creating the partition however the formatting is ending on error:
[root@VMD ~]# /sbin/mkfs -t ext3 /dev/xvdb1
mke2fs 1.39 (29-May-2006)
/dev/xvdb1 is apparently in use by the system; will not make a filesystem here!
[root@VMD ~]#
Any idea how to proceed.
S.V. from Peoplecnc

Anonymous said...

incredibly objective, useful.

Anonymous said...

Thanks man, saved me some time!

Patricio said...

thanks.. was very helpful!

Anonymous said...

Incredible helpfull.

Sridevi Koduru said...

Sridevi Koduru (Senior Oracle Apps Trainer
LinkedIn profile -
Please Contact for One to One Online Training on Oracle Apps Technical, Financials, SCM, Oracle Manufacturing, OAF, ADF, SQL, PL/SQL, D2K at | +91 - 9581017828.