How to resize a physical disk or LUN and an ASM DISKGROUP

posted Mar 16, 2011, 6:48 AM by Sachchida Ojha
Most of the storage technology used is SAN or NAS.  The disks in the storage are configured as a unit (LUN) and presented to the host.  When the LUN run out of space, new disks can be added to the LUN.

In all platforms a LUN is identified in the host as a physical device (disk).  The hole LUN can be used  or it can be partitioned.  Each partition can be seen as an individual disk. There are platforms  that require a LVM in order to partition a LUN/disk.  If a LVM is not used,then the hole disk needs to be used.

When the space in the LUN is exhausted, in the storage side it is a simple task adding new disks to the current LUN.  Now, it is required  the operating system recognize the new space.

In Linux in order to work on a physical disk, it requires at least one partition.  The fdisk command is used to display and manipulate the partitions.

fdisk -l /dev/sdg returns:

[root@arlnx2 root]# fdisk -l /dev/sdg

Disk /dev/sdg: 9105 MB, 9105018880 bytes
64 heads, 32 sectors/track, 8683 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes

   Device Boot    Start       End    Blocks   Id  System
/dev/sdg1             1      1908   1953776   83  Linux

For this particular example we are using a disk of 9g but only 2gb have been used.

Also a diskgroup has been created using this disk:

SQL> select name,path,total_mb,free_mb from v$asm_disk;


DG1_0000 /dev/raw/raw4 1500 90

The previous output shows that most of the space has been allocated, so assuming that there are not ASM disks available, then the LUN will have to be expanded at the OS level and finally at the ASM level resize the diskgroup.

The first step will be adding space to the LUN. In this exercise we are using a DAS (Direct Attached Storage), using SCSI interface, but on SAN or NAS the steps will be similar.

As we saw in the output of fdisk command, the disk has a capacity of 9gb but only 2gb have been used for the partition. In order to use more space, the partition has to be recreated.  This operation is at the partition table level, which is stored in the first sectors of the disk.  Changing the partition table is not going to affect the data.

In other words, is extending the partition.

The general steps are:

1. resize LUN from storage
2. pick up new size from OS
3. in rolling fashion, shutdown ASM instances.
4. Only when all ASM have been recycled, you should resize the said disk on 1 ASM instance.

Now, some details/examples to resize the LUN in Linux:

A. Delete the current  partition.
B. Recreate the partition with the new size.

The device /dev/raw/raw4 is attached to the physical disk /dev/sdg.  fdisk command is used to modify the partition table.  Use d to delete the partition, n to create the partition and specify the new size.  Finish the operation using w to write the partition table..

At this point the partition has been configured but it requires the operating system recognize the new size.

When the LUN is ready at the OS level and the ASM instance has been recycled, the next step is resizing the diskgroup at the ASM level:

SQL> alter diskgroup DG1 resize disk dg1_0000 size 8000m;
 Note: this will not trigger a rebalance.

Note: bug 4110313 currently prevents ASM from resizing a disk without recycling the ASM instance.

In the previous example, the diskgroup will be expanded to 8000mb.

Information to resize a LUN using NetApps can be  found here and once the LUN has been expanded, then the diskgroup can be resized using the command referenced above.