Decreasing the Size of a Linux Data Partition

Note: Linux file systems like ext2/ext3/ext4/xfs do not allow you to reduce the filesystem size without unmounting the disk. This means that you cannot decrease the size of the root device because you cannot unmount it.
  1. Unmount the disk and reduce the size of the disk using your hypervisor tools. For example:

    # umount /dev/mapper/clear_sdb1
    # e2fsck -f /dev/mapper/clear_sdb1
    # resize2fs /dev/mapper/clear_sdb1 <newsize>
  2. Detach the disk using the command hcl detach diskname, where diskname is the short form of the disk name (for example, you would use sdb1 instead of /dev/sdb1).

    # hcl detach sdb1

  3. If this is a non-GPT data partition, decrease the underlying volume using the fdisk command. For example:

    # fdisk /dev/sdb
  4. If the data partition is a GPT partition, do the following:

    1. Access the device using gdisk.

      # gdisk /dev/sdb

    2. Print all the information about the old partition using the i partition-number command and note the "Partition unique GUID".

      Command (? for help): i 1
      Using 1
      Partition GUID code: EBD0A0A2-B9E5-4433-87C0-68B6B72699C7 (Microsoft basic data)
      Partition unique GUID: 1390EA67-17AB-48F9-9851-8C8D54A9E454
      First sector: 2048 (at 1024.0 KiB)
      Last sector: 585727 (at 286.0 MiB)
      Partition size: 583680 sectors (285.0 MiB)
      Attribute flags: 0000000000000000
      Partition name: '1'
    3. Delete the old partition.

      Command (? for help): d 1

    4. Re-create the new partition with same start but different size when prompted.

      Command (? for help): n 1

    5. Switch to expert mode.

      Command (? for help): x

    6. Set the saved GUID for the partition.

      Expert command (? for help): c 1
      Using 1
      Enter the partition's new unique GUID ('R' to randomize): 1390EA67-17AB-48F9-9851-8C8D54A9E454 
    7. Save the changes to disk.

      Expert command (? for help): w

  5. Re-read the partition table using the partprobe command. For example:

    # partprobe /dev/sdb
    Note: partprobe may fail if the underlying device is busy, which can happen if LVM is configured for another partition on the same disk. If it fails, reboot the VM and continue with this procedure. The partition table will be correctly updated during the reboot.
  6. Reattach the disk using the command hcl attach diskname, where diskname is the short form of the disk name.

    # hcl attach sdb1