This article describes how to edit a partition after you enlarge block storage in Linux.

After you have increased the block storage of your Cloud Servers, you need to resize the partition manually. 

To resize the partition manually:

Requirements
  • You restarted the server after increasing the block storage size.

  • You have logged on to the server as administrator.

  • Install the growpart program.

    Ubuntu:

    [root@localhost ~]# apt-get update
    [root@localhost ~]# apt-get install cloud-initramfs-growroot

    CentOS 7, CentOS Stream 8 and CentOS Stream 9:

    [root@localhost ~]# yum install cloud-utils-growpart

  • To list the block of storage that is assigned to the server, enter the following command:

    [root@localhost ~]# lsblk

    After entering the command, you will be shown all the important information about the existing disks and the assigned block of storage that you have enlarged.

    Example:

    [root@localhost ~]# lsblk
    NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
    sda               8:0    0  100G  0 disk
    ├─sda1            8:1    0  512M  0 part /boot
    └─sda2            8:2    0 99.5G  0 part
      ├─centos-root 253:0    0 97.5G  0 lvm  /
      └─centos-swap 253:1    0    2G  0 lvm  [SWAP]
    sdb               8:16   0   40G  0 disk
    └─sdb1            8:17   0   20G  0 part /mnt/block
    sr0              11:0    1 1024M  0 rom

    In the above example, the server is assigned a block of storage, the size of which has been increased from 20 GB to 40 GB. This block has the name sdb.

  • Use the following growpart command to expand the first partition on the Storage block. Note that there is a space between the device name and the partition number.

    [root@localhost ~]# growpart /dev/dev/dev_name 1

    Example:

    [root@localhost ~]# growpart /dev/sdb 1

  • To customise the ext4 file system, type the following command:

    [root@localhost ~]# resize2fs -p /dev/sdb1

Note

If the file system is not enlarged, restart the server. Then enter the command resize2fs -p /dev/sdb1 again.

  • To check the available space of the Block Storage, type the following command:

    [root@localhost ~]# df -h

    You will then see the new size of the Block Storage.

    Example:

    [root@localhost ~]# df -h
    Filesystem               Size  Used Avail Use% Mounted on
    devtmpfs                 1.9G     0  1.9G   0% /dev
    tmpfs                    1.9G     0  1.9G   0% /dev/shm
    tmpfs                    1.9G   17M  1.9G   1% /run
    tmpfs                    1.9G     0  1.9G   0% /sys/fs/cgroup
    /dev/mapper/centos-root   98G  2.3G   96G   3% /
    /dev/sdb1                 40G   48M   38G   1% /mnt/block
    /dev/sda1                507M  228M  280M  45% /boot
    tmpfs                    376M     0  376M   0% /run/user/0