Resize xfs partition without LVM
2 min readSep 7, 2020
I just resized XFS partition size of Oracle Linux 7 running on Vmware. It was /dev/sdh1 without lvm. Adding just 10 GB to demonstrate how to do it.
This is the current situation:
# gdisk -l /dev/sdhGPT fdisk (gdisk) version 0.8.10
Partition table scan:
MBR: protective
BSD: not present
APM: not present
GPT: presentFound valid GPT with protective MBR; using GPT.
Disk /dev/sdh: 8610906112 sectors, 4.0 TiB
Logical sector size: 512 bytes
Disk identifier (GUID): E4AD0C09-4AA1-4419-B5FF-D3CC55F1825A
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 8610906078
Partitions will be aligned on 2048-sector boundaries
Total free space is 2015 sectors (1007.5 KiB)Number Start (sector) End (sector) Size Code Name1 2048 8610906077 4.0 TiB 8300 Linux filesystem
First install growpart
package.
# yum install cloud-utils-growpart -y
Increase disk size on Vmware.
Then rescan devices for disk size change. Replace sdh
with your own disk.
echo 1 > /sys/class/block/sdh/device/rescan
Check dmesg
output to see capacity change
# dmesg |grep sdh
[10494469.408338] sd 3:0:0:0: [sdh] 8610906112 512-byte logical blocks: (4.40 TB/4.00 TiB)
[10494469.408516] sdh: detected capacity change from 4398046511104 to 4408783929344
Time to run growpart
to resize partition size
# growpart /dev/sdh 1
CHANGED: partition=1 start=2048 old: size=8589932511 end=8589934559 new: size=8610904030 end=8610906078
This change is not visible to the file system. To grow the file system run xfs_growfs
# xfs_growfs /dev/sdh1
meta-data=/dev/sdh1 isize=256 agcount=17, agsize=67108800 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0 finobt=0 spinodes=0
data = bsize=4096 blocks=1073741563, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=131071, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 1073741563 to 1076363003
And check it with df -h
# df -h /dev/sdh1
Filesystem Size Used Avail Use% Mounted on
/dev/sdh1 4.1T 4.0T 11G 100% /data
That’s all.