X

An Oracle blog about Exadata

  • January 9, 2009

Resizing the filesystem of your Oracle VM template

Rene Kundersma
Software Engineer

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

Join the discussion

Comments ( 10 )
  • Peter Saturday, January 10, 2009
    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 Saturday, January 10, 2009
    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
  • Keith Rust Tuesday, February 9, 2010
    I tried the image expansion method and it didn't work. Reading other posts I think Rene's method is the best way for Oracle VM when using the templates. I'm no expert here, but my guess is it has to do with the LVM management of the templates.
  • Dave Gillies Monday, September 6, 2010
    Rene, I have used this technique many times with great success. Thank you!
    Now I have a question...
    I have been increasing the root filesystem on a particular vm guest to accomodate database logging as we have encountered some issues with Oracle WMS. I am now up to 70 GB where 20 GB was plenty before. Once the issues are resolved, database logging is switched off and the space is freed up, is it possible to reduce the root filesystem back to 20 GB? I don't want to waste the 50 GB...
  • guest Friday, September 21, 2012

    Hi Rene Kundersma

    I had followed your doc for extending root mount point with LVM.but when i extend with lvextend -L 10G /dev/VolGroup00/LogVol00

    Couldn't find device with uuid 'VsgpZb-BiYi-IVBa-ggUg-7J10-1TiA-YlMqxf'.

    Cannot change VG VolGroup00 while PVs are missing.

    Consider vgreduce --removemissing.

    it says this error message.could you please suggest me a solution please.

    thanks

    k.goutham


  • Rene Monday, September 24, 2012

    k.goutham,

    The error message says PV's under the LV are missing.

    So I would check the status of the LV first and fix if required.

    Are you sure your LV is really LogVol00 ? (you may have another name)

    Please see the lvm howto.

    Rene


  • guest Wednesday, August 7, 2013

    Hi,Can you please let me know how to move / file system (root) to lvm after creating lvm. By default our vm template is not creating lvm's


  • guest Wednesday, August 7, 2013

    Hi,

    Provided your system supports usage of lvm, things could be done by creating a new physical volume, creating a volume group on it and creating an logical volume in it.

    Then mount that lvm and tar (or copy) over the entire contents of '/'.

    When that is done you need to make sure your fstab is updated. You may want to use a label to mount the lvm.

    After this re-install the grub bootloader.

    Make sure you put /boot not on LVM

    It maybe quicker to just grab a new template (based on lvm) and copy over your applications and use that.

    Regards,

    Rene


  • Prasad N Thursday, August 8, 2013

    Hi, we are creating vm's on exalogic x3-2 eighth rack through oracle ops center, the default template which comes with it creates boot, / and tmpfs on physical disk and we would like to move / to lvm, is it supported and how can we do it?


  • Rene Thursday, August 8, 2013

    Hi Prasad,

    Please see my earlier reply - with high level instructions:

    Add a new disk, make it lvm, transfer the files, update configuration (/etc/fstab and grub) (there maybe more)

    You need to double check if you are able to use lvm for /boot at all these days - until now I have only seen /boot as a regular partition.

    I cannot answer if this is supported from an Exalogic perspective and I don't have the time to help you with more details other than the highlevel steps. This blog entry is from 2009 btw.

    Rene


Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.