CentOS 8.x parted resize existing partition

From Notes_Wiki

Home > CentOS > CentOS 8.x > System Administration > Filesystem management > parted > CentOS 8.x parted resize existing partition

If a partition is created using LVM it can be resized by CentOS 7.x Create LVM partition on new disk However, if a partition is not created via LVM then resizing it requires following steps:

  1. If the underlying storage is iSCSI / FC and the storage disks needs resizing then resize disk at storage level
  2. After disk is resized at storage level need to reboot the machine for new disk size to be visible
  3. After reboot validate that updated size is visible using 'multipath -ll', if multipath is in use:
    [root@example ~]# multipath -ll
    san01 (3600601606d104c0046c5e75c2ed54946) dm-2 DGC ,VRAID
    size=510G features='2 queue_if_no_path retain_attached_hw_handler' hwhandler='1 alua' wp=rw
    |-+- policy='service-time 0' prio=50 status=active
    | `- 16:0:0:0 sdc 8:32 active ready running
    `-+- policy='service-time 0' prio=10 status=enabled
    `- 15:0:0:0 sdb 8:16 active ready running
    After resize and reboot the new size increase from old 510GB to 1.0TB
    [root@example ~]# multipath -ll
    san01 (3600601606d104c0046c5e75c2ed54946) dm-2 DGC ,VRAID
    size=1.0T features='2 queue_if_no_path retain_attached_hw_handler' hwhandler='1 alua' wp=rw
    |-+- policy='service-time 0' prio=50 status=active
    | `- 16:0:0:0 sdc 8:32 active ready running
    `-+- policy='service-time 0' prio=10 status=enabled
    `- 15:0:0:0 sdb 8:16 active ready running
  4. Check increased disk size using "fdisk -l". In case of multipath, the increased size should reflect for all device names (eg /dev/sdb, /dev/sdc) in above example.
  5. Umount the partition(s) such as
    umount /dev/mapper/san01p1
  6. Check the filesystem for errors using
    fsck -f /dev/mapper/san01p1
  7. Check partition table using 'parted <device-name> print' command and if prompted to fix gpt issues, choose to fix. Example:
    [root@example ~]# parted /dev/mapper/san01 print
    Error: The backup GPT table is not at the end of the disk, as it should be. This might mean that another operating system believes the disk is smaller. Fix, by moving
    the backup to the end (and removing the old backup)?
    Fix/Ignore/Cancel? Fix
    Warning: Not all of the space available to /dev/mapper/san01 appears to be used, you can fix the GPT to use all of the space (an extra 1098907648 blocks) or continue
    with the current setting?
    Fix/Ignore? Fix
    Model: Linux device-mapper (multipath) (dm)
    Disk /dev/mapper/san01: 1100GB
    Sector size (logical/physical): 512B/512B
    Partition Table: gpt
    Disk Flags:
    Number Start End Size File system Name Flags
    1 4194kB 532GB 531GB ext4 primary
  8. Resize the underlying partition using parted command 'parted /dev/mapper/san01', where san01 is the multipath device
    1. After starting parted change unit to GB using 'unit GB'
    2. Get free space details using 'print free'. Example output
      (parted) print free
      Model: Linux device-mapper (multipath) (dm)
      Disk /dev/mapper/san01: 1100GB
      Sector size (logical/physical): 512B/512B
      Partition Table: gpt
      Disk Flags:
      Number Start End Size File system Name Flags
      0.00GB 0.00GB 0.00GB Free Space
      1 0.00GB 532GB 531GB ext4 primary
      532GB 1100GB 568GB Free Space
    3. Resize existing partition using 'resizepart'. Then enter partition number (eg 1 in above example) and desired size. Example
      (parted) resizepart
      Partition number? 1
      End? [532GB]? 1070GB
      (parted) print
      Model: Linux device-mapper (multipath) (dm)
      Disk /dev/mapper/san01: 1100GB
      Sector size (logical/physical): 512B/512B
      Partition Table: gpt
      Disk Flags:
      Number Start End Size File system Name Flags
      1 0.00GB 1070GB 1070GB ext4 primary
      Here intentionally left 30GB space at end from 1070GB to 1100GB
  9. Again fsck partition using:
    fsck -f /dev/mapper/san01
  10. Resize ext file-system to use entire partition using:
    resize2fs /dev/mapper/san01
    For brtfs refer https://www.suse.com/support/kb/doc/?id=000018798 and for xfs use xfs_grow
  11. Mount the partition and check increased disk space



Home > CentOS > CentOS 8.x > System Administration > Filesystem management > parted > CentOS 8.x parted resize existing partition