Monday, September 20, 2021

Resize disk - growpart

 This is a very useful tool to resize your disk.

See this: Enlarge a disk and partition of any Linux VM without a reboot - CodeNotary

For Redhat, use this article: https://access.redhat.com/solutions/5540131


login as: root

root@192.168.0.52's password:

Last login: Mon Sep 20 17:50:45 2021 from gateway

[root@database-rhel79 ~]# df -k

Filesystem                             1K-blocks     Used Available Use% Mounted on

devtmpfs                                49301728        0  49301728   0% /dev

tmpfs                                   49318592        0  49318592   0% /dev/shm

tmpfs                                   49318592     9524  49309068   1% /run

tmpfs                                   49318592        0  49318592   0% /sys/fs/cgroup

/dev/mapper/rhel_database--rhel79-root  46110724 44819440   1291284  98% /

/dev/sda1                                1038336   242192    796144  24% /boot

/dev/sdb1                               50442784 31384040  16473352  66% /data

tmpfs                                    9863720        8   9863712   1% /run/user/42

tmpfs                                    9863720        0   9863720   0% /run/user/0

[root@database-rhel79 ~]# fdisk -l


Disk /dev/sdb: 161.1 GB, 161061273600 bytes, 314572800 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk label type: dos

Disk identifier: 0x2551332d


   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1            2048   102762495    51380224   83  Linux


Disk /dev/sda: 53.7 GB, 53687091200 bytes, 104857600 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk label type: dos

Disk identifier: 0x000bbcfa


   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *        2048     2099199     1048576   83  Linux

/dev/sda2         2099200   104857599    51379200   8e  Linux LVM


Disk /dev/mapper/rhel_database--rhel79-root: 47.2 GB, 47240445952 bytes, 92266496 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes



Disk /dev/mapper/rhel_database--rhel79-swap: 5368 MB, 5368709120 bytes, 10485760 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes


[root@database-rhel79 ~]# growpart /dev/sdb 1

bash: growpart: command not found...

[root@database-rhel79 ~]# resize2fs /dev/sdb1

resize2fs 1.42.9 (28-Dec-2013)

The filesystem is already 12845056 blocks long.  Nothing to do!


[root@database-rhel79 ~]# cat /sys/class/block/sdb/device/rescan

cat: /sys/class/block/sdb/device/rescan: Permission denied

[root@database-rhel79 ~]# id

uid=0(root) gid=0(root) groups=0(root)

[root@database-rhel79 ~]# ls -l /sys/class/block/sdb/device/rescan

--w------- 1 root root 4096 Sep 20 17:59 /sys/class/block/sdb/device/rescan

[root@database-rhel79 ~]# yum install cloud-utils

Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager


No package cloud-utils available.

Error: Nothing to do

[root@database-rhel79 ~]#

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

Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager

Resolving Dependencies

--> Running transaction check

---> Package cloud-utils-growpart.noarch 0:0.29-5.el7 will be installed

--> Finished Dependency Resolution


Dependencies Resolved


=======================================================================================================================================================================

 Package                                       Arch                            Version                               Repository                                   Size

=======================================================================================================================================================================

Installing:

 cloud-utils-growpart                          noarch                          0.29-5.el7                            rhel-7-server-rpms                           27 k


Transaction Summary

=======================================================================================================================================================================

Install  1 Package


Total download size: 27 k

Installed size: 61 k

Is this ok [y/d/N]: y

Downloading packages:

cloud-utils-growpart-0.29-5.el7.noarch.rpm                                                                                                      |  27 kB  00:00:06

Running transaction check

Running transaction test

Transaction test succeeded

Running transaction

  Installing : cloud-utils-growpart-0.29-5.el7.noarch                                                                                                              1/1

  Verifying  : cloud-utils-growpart-0.29-5.el7.noarch                                                                                                              1/1


Installed:

  cloud-utils-growpart.noarch 0:0.29-5.el7


Complete!

[root@database-rhel79 ~]# growpart /dev/sdb 1

CHANGED: partition=1 start=2048 old: size=102760448 end=102762496 new: size=314570719 end=314572767

[root@database-rhel79 ~]# df -k

Filesystem                             1K-blocks     Used Available Use% Mounted on

devtmpfs                                49301728        0  49301728   0% /dev

tmpfs                                   49318592        0  49318592   0% /dev/shm

tmpfs                                   49318592     9496  49309096   1% /run

tmpfs                                   49318592        0  49318592   0% /sys/fs/cgroup

/dev/mapper/rhel_database--rhel79-root  46110724 44821624   1289100  98% /

/dev/sda1                                1038336   242192    796144  24% /boot

/dev/sdb1                               50442784 31384040  16473352  66% /data

tmpfs                                    9863720       12   9863708   1% /run/user/42

tmpfs                                    9863720        0   9863720   0% /run/user/0

[root@database-rhel79 ~]# resize2fs /dev/sdb1

resize2fs 1.42.9 (28-Dec-2013)

Filesystem at /dev/sdb1 is mounted on /data; on-line resizing required

old_desc_blocks = 7, new_desc_blocks = 19

The filesystem on /dev/sdb1 is now 39321339 blocks long.


[root@database-rhel79 ~]# df -k

Filesystem                             1K-blocks     Used Available Use% Mounted on

devtmpfs                                49301728        0  49301728   0% /dev

tmpfs                                   49318592        0  49318592   0% /dev/shm

tmpfs                                   49318592     9496  49309096   1% /run

tmpfs                                   49318592        0  49318592   0% /sys/fs/cgroup

/dev/mapper/rhel_database--rhel79-root  46110724 44821568   1289156  98% /

/dev/sda1                                1038336   242192    796144  24% /boot

/dev/sdb1                              154685884 31391512 116472880  22% /data

tmpfs                                    9863720       12   9863708   1% /run/user/42

tmpfs                                    9863720        0   9863720   0% /run/user/0


No comments:

Post a Comment