Wednesday, May 5, 2021

How to increase XFS root filesystem

 Reference: 

linux - How to resize root partition online , on xfs filesystem? - Stack Overflow

Expanding (resize) persistent & mounted Centos 7 disk size in Custom Google Compute Image. · GitHub


[root@okd4-services ~]# df -h

Filesystem      Size  Used Avail Use% Mounted on

devtmpfs        7.8G     0  7.8G   0% /dev

tmpfs           7.8G     0  7.8G   0% /dev/shm

tmpfs           7.8G   18M  7.8G   1% /run

tmpfs           7.8G     0  7.8G   0% /sys/fs/cgroup

/dev/sda4        91G   91G   26M 100% /

/dev/sda2       976M  258M  651M  29% /boot

/dev/sda1       599M  6.9M  592M   2% /boot/efi

tmpfs           1.6G  1.2M  1.6G   1% /run/user/42

overlay          91G   91G   26M 100% /var/lib/docker/overlay2/6848dec23c5ea31afdcc552cf8a2d44ad792b75d2e62fd4185a0274f72afa6ab/merged

tmpfs           1.6G  4.0K  1.6G   1% /run/user/1001

tmpfs           1.6G  6.8M  1.6G   1% /run/user/1000

/dev/sr0        7.7G  7.7G     0 100% /run/media/unica/CentOS-8-2-2004-x86_64-dvd

tmpfs           1.6G  4.0K  1.6G   1% /run/user/0

[root@okd4-services ~]#  xfs_growfs -d ^C

[root@okd4-services ~]# growpart

bash: growpart: command not found...

Install package 'cloud-utils-growpart' to provide command 'growpart'? [N/y] y



 * Waiting in queue...

 * Loading list of packages....

The following packages have to be installed:

 cloud-utils-growpart-0.31-1.el8.noarch Script for growing a partition

Proceed with changes? [N/y] y



 * Waiting in queue...

 * Waiting for authentication...

 * Waiting in queue...

 * Loading list of packages....

 * Downloading packages...

 * Requesting data...

 * Testing changes...

 * Installing packages...

growpart disk partition

   rewrite partition table so that partition takes up all the space it can

   options:

    -h | --help       print Usage and exit

         --fudge F    if part could be resized, but change would be

                      less than 'F' bytes, do not resize (default: 1048576)

    -N | --dry-run    only report what would be done, show new 'sfdisk -d'

    -v | --verbose    increase verbosity / debug

    -u | --update  R  update the the kernel partition table info after growing

                      this requires kernel support and 'partx --update'

                      R is one of:

                       - 'auto'  : [default] update partition if possible

                       - 'force' : try despite sanity checks (fail on failure)

                       - 'off'   : do not attempt

                       - 'on'    : fail if sanity checks indicate no support


   Example:

    - growpart /dev/sda 1

      Resize partition 1 on /dev/sda

must supply disk and partition-number


[root@okd4-services ~]# growpart /dev/sda 4

CHANGED: partition=4 start=20105216 old: size=189607936 end=209713152 new: size=231552991 end=251658207

[root@okd4-services ~]# xfs_growfs -d /dev/sda4

meta-data=/dev/sda4              isize=512    agcount=4, agsize=5925248 blks

         =                       sectsz=512   attr=2, projid32bit=1

         =                       crc=1        finobt=1, sparse=1, rmapbt=0

         =                       reflink=1

data     =                       bsize=4096   blocks=23700992, imaxpct=25

         =                       sunit=0      swidth=0 blks

naming   =version 2              bsize=4096   ascii-ci=0, ftype=1

log      =internal log           bsize=4096   blocks=11572, version=2

         =                       sectsz=512   sunit=0 blks, lazy-count=1

realtime =none                   extsz=4096   blocks=0, rtextents=0

data blocks changed from 23700992 to 28944123

[root@okd4-services ~]# df -h

Filesystem      Size  Used Avail Use% Mounted on

devtmpfs        7.8G     0  7.8G   0% /dev

tmpfs           7.8G     0  7.8G   0% /dev/shm

tmpfs           7.8G   18M  7.8G   1% /run

tmpfs           7.8G     0  7.8G   0% /sys/fs/cgroup

/dev/sda4       111G   91G   20G  82% /

/dev/sda2       976M  258M  651M  29% /boot

/dev/sda1       599M  6.9M  592M   2% /boot/efi

tmpfs           1.6G  1.2M  1.6G   1% /run/user/42

overlay         111G   91G   20G  82% /var/lib/docker/overlay2/6848dec23c5ea31afdcc552cf8a2d44ad792b75d2e62fd4185a0274f72afa6ab/merged

tmpfs           1.6G  4.0K  1.6G   1% /run/user/1001

tmpfs           1.6G  6.8M  1.6G   1% /run/user/1000

/dev/sr0        7.7G  7.7G     0 100% /run/media/unica/CentOS-8-2-2004-x86_64-dvd

tmpfs           1.6G  4.0K  1.6G   1% /run/user/0