Main | Running Oracle VM Server into an Oracle VM Server »

Resizing the filesystem of your Oracle VM template

To be quick on some testing you download one of the handy Oracle VM templates.
But after using the template for a while you notice the root filesystem of the VM got full, what do you do ?
Since this question came along for a couple of times now, one way to handle this is described below.
First, find out what the current size of the root filesystem is:


[root@vsupp1 ~]# df -m
Filesystem 1M-blocks Used Available Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
3844 2885 761 80% /
/dev/hda1 99 12 82 13% /boot
tmpfs 502 0 502 0% /dev/shm

So, we add a second 'disk' to the VM. In this case it is discovered as /dev/hdb. In order to use it, we put a partition on it with the label of LVM (logical volume manager):

[root@vsupp1 ~]# fdisk /dev/hdb
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.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): p

Disk /dev/hdb: 4194 MB, 4194304000 bytes
255 heads, 63 sectors/track, 509 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-509, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-509, default 509):
Using default value 509

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): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.


Now the partition is on it, we create a physical volume on top of it:

[root@vsupp1 ~]# pvcreate /dev/hdb1
Physical volume "/dev/hdb1" successfully created


Now, let's take a look the current volume groups we use:

[root@vsupp1 ~]# vgdisplay
  --- 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.88 GB
  PE Size               32.00 MB
  Total PE              188
  Alloc PE / Size       188 / 5.88 GB
  Free  PE / Size       0 / 0   
  VG UUID               o0hAPH-zDE1-dmlH-Ol3e-01yf-Y9fX-grxs1G

So, let's extend this volume group with the new physical volume:

[root@vsupp1 ~]#  vgextend VolGroup00 /dev/hdb1
  Volume group "VolGroup00" successfully extended

Let's find out if the VG size changed:


[root@vsupp1 ~]# vgdisplay
--- Volume group ---
VG Name VolGroup00
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 4
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 2
Act PV 2
VG Size 9.75 GB
PE Size 32.00 MB
Total PE 312
Alloc PE / Size 188 / 5.88 GB
Free PE / Size 124 / 3.88 GB
VG UUID o0hAPH-zDE1-dmlH-Ol3e-01yf-Y9fX-grxs1G

The VG size changed, now let's take a look at the Logical Volume (LV) size:

[root@vsupp1 ~]# lvdisplay
  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol00
  VG Name                VolGroup00
  LV UUID                DAbIh5-2rnI-Scah-xhcI-BM9a-lGIL-drQQXl
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                3.88 GB
  Current LE             124
  Segments               1
  Allocation             inherit
  Read ahead sectors     0
  Block device           253:0
   
  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol01
  VG Name                VolGroup00
  LV UUID                04Is4L-1miY-0t5W-3Fth-3EuT-eF5M-eE4DU4
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                2.00 GB
  Current LE             64
  Segments               1
  Allocation             inherit
  Read ahead sectors     0
  Block device           253:1

So the LV (VolGroup00/LogVol00) we use is 3.88 GB. Here is the resize:

   
[root@vsupp1 ~]# lvextend -L 7.6G /dev/VolGroup00/LogVol00
  Rounding up size to full physical extent 7.62 GB
  Extending logical volume LogVol00 to 7.62 GB
  Logical volume LogVol00 successfully resized

Cool, the LV is extended. Now the thing left to extend is the filesystem.
With Oracle Enterprise Linux we can do this online as we go:



[root@vsupp1 ~]# resize2fs /dev/VolGroup00/LogVol00 7G
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/VolGroup00/LogVol00 is mounted on /; on-line resizing required
Performing an on-line resize of /dev/VolGroup00/LogVol00 to 1835008 (4k) blocks.
The filesystem on /dev/VolGroup00/LogVol00 is now 1835008 blocks long.

And see, the filesystem is resized online.

[root@vsupp1 ~]# df -m
Filesystem           1M-blocks      Used Available Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                          6944      2886      3700  44% /
/dev/hda1                   99        12        82  13% /boot
tmpfs                      502         0       502   0% /dev/shm

Rene Kundersma
Oracle Expert Services, The Netherlands

TrackBack

TrackBack URL for this entry:
http://blogs.oracle.com/mte1521/mt-tb.cgi/9402

Comments (3)

Peter:

Rene,

Is it possible to add storage to your DomU without restarting DomU?
e.g: I provision 100G of storage to my vmserver (Dom0) and I want to add that 100G to my DomU. I COULD stop the DomU, change vm.cfg and add the new disk and restart but how do I do if I want to do this without restarting DomU? Is that even possible?

regards
/Peter

Rene Kundersma:

Yes, Peter quite recently I learned this is possible !
I like the question.

We could use one of the xm commands options to do this online I remember.

I will try to find out what the exact statement(s) are and put an example on our blog asap.

Thanks

Rene

René,

I found the following solution (http://www.vinacis.net/content/view/32/28/) where you don't have to add a new disk image file, but increase the size of the already existing disk image file. Haven't tried it personally, but maybe it's worth to give it a try.

Regards,

Rob

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

About This Entry

This page contains a single entry from the blog posted on January 9, 2009 1:57 PM.

The next post in this blog is Running Oracle VM Server into an Oracle VM Server.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type and Oracle