How To: Extend LUN without reboot (Redhat)

Posted: April 2, 2011 in How-to, Linux

1)    Extend the LUN from storage array (If you HP EVA, locate the LUN, extend it and finally save the changes). And you need wait a few seconds here (to allow the changes to be identified by the OS) before you proceed with the next step.

2)    Identify the underlying SCSI devices (use multipath -ll to see the underlying devices) and rescan the SCSI devices

[root@zenhat ~]# echo 1 > /sys/block/sds/device/rescan
[root@zenhat ~]# echo 1 > /sys/block/sdr/device/rescan

3)    Drop and add each device path from multipath(no problem, multipath will correctly failover the paths) and resize the related multipath map ( OR reloading the multipathd will do the same job sometimes)

[root@zenhat ~]# multipathd -k
multipathd>
multipathd> del path sds
ok
multipathd> add path sds
ok
multipathd> del path sdr
ok
multipathd> add path sdr
ok
multipathd> resize map dm-23
ok

4)    Check and verify multipath whether it claims the new LUN size

[root@zenhat ~]# multipath -ll
vcb1_100G (3600508b400103e9b0000600001570000) dm-12 HP,HSV200
[size=100G][features=1 queue_if_no_path][hwhandler=0][rw]
\_ round-robin 0 [prio=50][active]
\_ 1:0:1:6 sdo 8:224 [active][ready]
\_ round-robin 0 [prio=10][enabled]
\_ 1:0:0:6 sdg 8:96  [active][ready]
test1_10G (3600508b400103e9b0000600001630000) dm-23 HP,HSV200
[size=15G][features=1 queue_if_no_path][hwhandler=0][rw]
\_ round-robin 0 [prio=50][enabled]
\_ 1:0:1:9 sds 65:32 [active][ready]
\_ round-robin 0 [prio=10][enabled]
\_ 1:0:0:9 sdr 65:16 [active][ready]

5)    Unmount the partition

[root@zenhat ~]# umount /dev/mapper/test1_10G1

6)    Remove the device’s partition table from device mapper

[root@zenhat ~]# kpartx -d /dev/mapper/test1_10G

7)    Fdisk the device, drop and recreate the partition with desired size. (I’ll also do the 64k block alignment do get the maximum performance)

root@zenhat ~]# fdisk /dev/mapper/test1_10G

The number of cylinders for this disk is set to 1958.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): p

Disk /dev/mapper/test1_10G: 16.1 GB, 16106127360 bytes
255 heads, 63 sectors/track, 1958 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System
/dev/mapper/test1_10G1               1        1305    10482380+  83  Linux

Command (m for help): m
Command action
a   toggle a bootable flag
b   edit bsd disklabel
c   toggle the dos compatibility flag
d   delete a partition
l   list known partition types
m   print this menu
n   add a new partition
o   create a new empty DOS partition table
p   print the partition table
q   quit without saving changes
s   create a new empty Sun disklabel
t   change a partition’s system id
u   change display/entry units
v   verify the partition table
w   write table to disk and exit
x   extra functionality (experts only)

Command (m for help): d
Selected partition 1

Command (m for help): p

Disk /dev/mapper/test1_10G: 16.1 GB, 16106127360 bytes
255 heads, 63 sectors/track, 1958 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-1958, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-1958, default 1958):
Using default value 1958

Command (m for help): x

Expert command (m for help): m
Command action
b   move beginning of data in a partition
c   change number of cylinders
d   print the raw data in the partition table
e   list extended partitions
f   fix partition order
g   create an IRIX (SGI) partition table
h   change number of heads
m   print this menu
p   print the partition table
q   quit without saving changes
r   return to main menu
s   change number of sectors/track
v   verify the partition table
w   write table to disk and exit

Expert command (m for help): p

Disk /dev/mapper/test1_10G: 255 heads, 63 sectors, 1958 cylinders

Nr AF  Hd Sec  Cyl  Hd Sec  Cyl     Start      Size ID
1 00   1   1    0 254  63 1023         63   31455207 83
2 00   0   0    0   0   0    0          0          0 00
3 00   0   0    0   0   0    0          0          0 00
4 00   0   0    0   0   0    0          0          0 00

Expert command (m for help): b
Partition number (1-4): 1
New beginning of data (63-31455269, default 63): 64

Expert command (m for help): p

Disk /dev/mapper/test1_10G: 255 heads, 63 sectors, 1958 cylinders

Nr AF  Hd Sec  Cyl  Hd Sec  Cyl     Start      Size ID
1 00   1   1    0 254  63 1023         64   31455206 83
2 00   0   0    0   0   0    0          0          0 00
3 00   0   0    0   0   0    0          0          0 00
4 00   0   0    0   0   0    0          0          0 00

Expert command (m for help): r

Command (m for help): p

Disk /dev/mapper/test1_10G: 16.1 GB, 16106127360 bytes
255 heads, 63 sectors/track, 1958 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System
/dev/mapper/test1_10G1               1        1958    15727603   83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 22: Invalid argument.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.

8)    Let kernel identify the new partition table

[root@zenhat ~]# partprobe

9)    Add the partitioning table to device mapper

[root@zenhat ~]# kpartx -a /dev/mapper/test1_10G

10)    Run filesystem check

[root@zenhat ~]# e4fsck -f /dev/mapper/test1_10G1
e4fsck 1.41.9 (22-Aug-2009)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/mapper/test1_10G1: 73/655360 files (8.2% non-contiguous), 714120/2620595 blocks

11)    Extend the filesystem

[root@zenhat ~]# resize4fs /dev/mapper/test1_10G1
resize4fs 1.41.9 (22-Aug-2009)
Resizing the filesystem on /dev/mapper/test1_10G1 to 3931900 (4k) blocks.
The filesystem on /dev/mapper/test1_10G1 is now 3931900 blocks long.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s