Monday, October 5, 2015

Linux. Увеличение размера multipath диска


  1. Extend the LUN from storage device (IBM DS, IBM Storwize etc).
  2. Identify the SCSI device for this LUN.

    # multipath -ll
    mpath21 (3600a0b80003ac4d800001057506d4309) dm-1 IBM,1726-4xx  FAStT
    size=6.0G features='1 queue_if_no_path' hwhandler='1 rdac' wp=rw
    |-+- policy='round-robin 0' prio=6 status=active
    | `- 3:0:0:21 sdf 8:80 active ready running
    `-+- policy='round-robin 0' prio=1 status=enabled
      `- 2:0:0:21 sdc 8:32 active ghost running
  3. Rescan the SCSI device

    # echo 1 > /sys/block/sdf/device/rescan
    # echo 1 > /sys/block/sdc/device/rescan
  4. Reload multipathd service

    # service multipathd reload
    Reloading multipathd:                                      [  OK  ]
  5. Check and verify multipath whether it claims the new LUN size

    # multipath -ll
    mpath21 (3600a0b80003ac4d800001057506d4309) dm-1 IBM,1726-4xx  FAStT
    size=7.0G features='1 queue_if_no_path' hwhandler='1 rdac' wp=rw
    |-+- policy='round-robin 0' prio=6 status=active
    | `- 3:0:0:21 sdf 8:80 active ready running
    `-+- policy='round-robin 0' prio=1 status=enabled
      `- 2:0:0:21 sdc 8:32 active ghost running
  6. Unmount the partition

    # umount /dev/mapper/mpath21p1
  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.
    Before deleting partition check start sector for partition. Because partition may start from 63 sector (not aligned) or 64 sector (aligned).

    # fdisk /dev/mapper/mpath21
    WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
             switch off the mode (command 'c') and change display units to
             sectors (command 'u').
    Command (m for help): p
    Disk /dev/mapper/mpath21: 7516 MB, 7516192768 bytes
    255 heads, 63 sectors/track, 913 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0xab317070
                   Device Boot      Start         End      Blocks   Id  System
    /dev/mapper/mpath21p1               1         783     6289415+  83  Linux
    Partition 1 has different physical/logical beginnings (non-Linux?):
         phys=(0, 1, 1) logical=(0, 1, 2)

    --------------Here we check start sector for partition
    Command (m for help): x

    Expert command (m for help): p

    Disk /dev/mapper/mpath21: 255 heads, 63 sectors, 913 cylinders
    Nr AF  Hd Sec  Cyl  Hd Sec  Cyl     Start      Size ID
     1 00   1   1    0 254  63  782         64   12578831 83
    Partition 1 has different physical/logical beginnings (non-Linux?):
         phys=(0, 1, 1) logical=(0, 1, 2)
     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): d
    Selected partition 1
    Command (m for help): p
    Disk /dev/mapper/mpath21: 7516 MB, 7516192768 bytes
    255 heads, 63 sectors/track, 913 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0xab317070
                   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-913, default 1):
    Using default value 1
    Last cylinder, +cylinders or +size{K,M,G} (1-913, default 913):
    Using default value 913
    Command (m for help): x
    Expert command (m for help): b
    Partition number (1-4): 1
    New beginning of data (1-14667344, default 63): 64
    Expert command (m for help): p
    Disk /dev/mapper/mpath21: 255 heads, 63 sectors, 913 cylinders
    Nr AF  Hd Sec  Cyl  Hd Sec  Cyl     Start      Size ID
     1 00   1   1    0 254  63  912         64   14667281 83
    Partition 1 has different physical/logical beginnings (non-Linux?):
         phys=(0, 1, 1) logical=(0, 1, 2)
     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): 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 or after you run partprobe(8) or kpartx(8)
    Syncing disks.
  8. Let kernel identify the new partition table.

    # partprobe
    Warning: WARNING: the kernel failed to re-read the partition table on /dev/sda (Device or resource busy).  As a result, it may not reflect all of your changes until after reboot.
    Warning: WARNING: the kernel failed to re-read the partition table on /dev/sdd (Device or resource busy).  As a result, it may not reflect all of your changes until after reboot.
    device-mapper: remove ioctl on mpathfp1 failed: Device or resource busy
    Warning: parted was unable to re-read the partition table on /dev/mapper/mpathf (No such file or directory).  This means Linux won't know anything about the modifications you made.
    device-mapper: create ioctl on mpathfp1 failed: Device or resource busy
    device-mapper: remove ioctl on mpathfp1 failed: Device or resource busy

    This warnings and errors is normal because other partition is still mounted.
  9. Add the partitioning table to device mapper.

    # kpartx -a /dev/mapper/mpath21
  10. Run filesystem check.

    # e2fsck -f /dev/mapper/mpath21p1
    e2fsck 1.41.12 (17-May-2010)
    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/mpath21p1: 12/393216 files (8.3% non-contiguous), 85614/1572353 blocks
  11. Extend the filesystem.

    # resize2fs /dev/mapper/mpath21p1
    resize2fs 1.41.12 (17-May-2010)
    Resizing the filesystem on /dev/mapper/mpath21p1 to 1833410 (4k) blocks.
    The filesystem on /dev/mapper/mpath21p1 is now 1833410 blocks long.
  12. Mount partition and check new size.

    # mount -a
    # df -h
    Filesystem            Size  Used Avail Use% Mounted on
    /dev/mapper/mpath21p1
                          6.9G  240M  6.4G   4% /test
This manual was created based on this post How To: Extend LUN without reboot (Redhat)

No comments:

Post a Comment