XFS Grow
Initially, I allocated root mount point as 30 GB during OS installation, but now it seems a little small for future growth. So I decide to enlarge the file system that was formatted as XFS.
[root@test ~]# df -h /
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/ol-root 30G 20G 11G 66% /
The disk that I used has 240 GB, in which 40 GB is allocated at installation. So I'm pretty sure that I have plenty of available space that can allocate to root mount point.
Here are the main steps to achieve our goal:
- Make a New Partition
- Create a New Physical Volume
- Extend Target Volume Group
- Extend Target Logical Volume
- Grow root Mount Point
A. Make a New Partition
Since I have plenty of space that has not been allocated yet, so I know I can have another partition to extend the file system. First of all, I used fdisk to make a new partition.
Print Current Partitions
[root@test ~]# fdisk /dev/sda
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): p
Disk /dev/sda: 257.7 GB, 257698037760 bytes, 503316480 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: 0x000c84a6
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 83886079 40893440 8e Linux LVM
New a Partition
Command (m for help): n
Partition type:
p primary (2 primary, 0 extended, 2 free)
e extended
Select (default p):
Using default response p
Partition number (3,4, default 3):
First sector (83886080-503316479, default 83886080):
Using default value 83886080
Last sector, +sectors or +size{K,M,G} (83886080-503316479, default 503316479): +30G
Partition 3 of type Linux and of size 30 GiB is set
Print Current Partitions Before Writing to Table
Command (m for help): p
Disk /dev/sda: 257.7 GB, 257698037760 bytes, 503316480 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: 0x000c84a6
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 83886079 40893440 8e Linux LVM
/dev/sda3 83886080 146800639 31457280 83 Linux
Write to Partition Table
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
Recognize the New Partition
[root@test ~]# partprobe -s
/dev/sda: msdos partitions 1 2 3
B. Create a New Physical Volume
Display Current Physical Volume
[root@test ~]# pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name ol
PV Size <39.00 GiB / not usable 3.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 9983
Free PE 0
Allocated PE 9983
PV UUID ev12ft-GseE-h7qo-2XYi-VZBe-D3b3-VdKAA5
Create a Physical Volume
[root@test ~]# pvcreate /dev/sda3
Physical volume "/dev/sda3" successfully created.
Display Current Physical Volumes Again
[root@test ~]# pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name ol
PV Size <39.00 GiB / not usable 3.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 9983
Free PE 0
Allocated PE 9983
PV UUID ev12ft-GseE-h7qo-2XYi-VZBe-D3b3-VdKAA5
"/dev/sda3" is a new physical volume of "30.00 GiB"
--- NEW Physical volume ---
PV Name /dev/sda3
VG Name
PV Size 30.00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID KswvSM-fYhp-aLmC-2eaX-CVPD-pjUu-mjcuLX
Check Physical Volume Status
[root@test ~]# pvscan
PV /dev/sda2 VG ol lvm2 [<39.00 GiB / 0 free]
PV /dev/sda3 lvm2 [30.00 GiB]
Total: 2 [<69.00 GiB] / in use: 1 [<39.00 GiB] / in no VG: 1 [30.00 GiB]
C. Extend Target Volume Group
Display Volume Group Before Extending
[root@test ~]# vgdisplay
--- Volume group ---
VG Name ol
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 4
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 3
Max PV 0
Cur PV 1
Act PV 1
VG Size <39.00 GiB
PE Size 4.00 MiB
Total PE 9983
Alloc PE / Size 9983 / <39.00 GiB
Free PE / Size 0 / 0
VG UUID u0n6d0-aG74-n2wW-IQ7z-w1tw-UvUM-ctCVHA
Extend Volume Group ol
[root@test ~]# vgextend ol /dev/sda3
Volume group "ol" successfully extended
Check Physical Volume Status Again
[root@test ~]# pvscan
PV /dev/sda2 VG ol lvm2 [<39.00 GiB / 0 free]
PV /dev/sda3 VG ol lvm2 [<30.00 GiB / <30.00 GiB free]
Total: 2 [68.99 GiB] / in use: 2 [68.99 GiB] / in no VG: 0 [0 ]
Display Volume Group After Extending
[root@test ~]# vgdisplay
--- Volume group ---
VG Name ol
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 5
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 3
Max PV 0
Cur PV 2
Act PV 2
VG Size 68.99 GiB
PE Size 4.00 MiB
Total PE 17662
Alloc PE / Size 9983 / <39.00 GiB
Free PE / Size 7679 / <30.00 GiB
VG UUID u0n6d0-aG74-n2wW-IQ7z-w1tw-UvUM-ctCVHA
D. Extend Target Logical Volume
Display Logical Volume Before Extending
[root@test ~]# lvdisplay
--- Logical volume ---
LV Path /dev/ol/root
LV Name root
VG Name ol
LV UUID jAS3mc-TbSG-E4hI-ol6x-Gkth-OHfm-wifSJt
LV Write Access read/write
LV Creation host, time primary.example.com, 2018-09-21 07:54:32 -0400
LV Status available
# open 1
LV Size 30.00 GiB
Current LE 7680
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 249:0
--- Logical volume ---
LV Path /dev/ol/home
LV Name home
VG Name ol
LV UUID O4tO2O-NUds-DrwV-Z02n-HddX-Rgw4-5JZuSd
LV Write Access read/write
LV Creation host, time primary.example.com, 2018-09-21 07:54:32 -0400
LV Status available
# open 1
LV Size 5.00 GiB
Current LE 1280
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 249:2
--- Logical volume ---
LV Path /dev/ol/swap
LV Name swap
VG Name ol
LV UUID w1zDoC-ekv5-eqj7-uX3n-H3Uz-Pja5-tF1YzR
LV Write Access read/write
LV Creation host, time primary.example.com, 2018-09-21 07:54:32 -0400
LV Status available
# open 2
LV Size <4.00 GiB
Current LE 1023
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 249:1
Extend the Logical Volume
[root@test ~]# lvextend /dev/ol/root /dev/sda3
Size of logical volume ol/root changed from 30.00 GiB (7680 extents) to <60.00 GiB (15359 extents).
Logical volume ol/root successfully resized.
Display Logical Volume After Extending
[root@test ~]# lvdisplay
--- Logical volume ---
LV Path /dev/ol/root
LV Name root
VG Name ol
LV UUID jAS3mc-TbSG-E4hI-ol6x-Gkth-OHfm-wifSJt
LV Write Access read/write
LV Creation host, time primary.example.com, 2018-09-21 07:54:32 -0400
LV Status available
# open 1
LV Size <60.00 GiB
Current LE 15359
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 249:0
--- Logical volume ---
LV Path /dev/ol/home
LV Name home
VG Name ol
LV UUID O4tO2O-NUds-DrwV-Z02n-HddX-Rgw4-5JZuSd
LV Write Access read/write
LV Creation host, time primary.example.com, 2018-09-21 07:54:32 -0400
LV Status available
# open 1
LV Size 5.00 GiB
Current LE 1280
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 249:2
--- Logical volume ---
LV Path /dev/ol/swap
LV Name swap
VG Name ol
LV UUID w1zDoC-ekv5-eqj7-uX3n-H3Uz-Pja5-tF1YzR
LV Write Access read/write
LV Creation host, time primary.example.com, 2018-09-21 07:54:32 -0400
LV Status available
# open 2
LV Size <4.00 GiB
Current LE 1023
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 249:1
E. Grow root Mount Point
Check XFS Infomation
[root@test ~]# xfs_info /
meta-data=/dev/mapper/ol-root isize=256 agcount=4, agsize=1966080 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0 finobt=0 spinodes=0
data = bsize=4096 blocks=7864320, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=3840, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
Grow root Mount Point
[root@test ~]# xfs_growfs /
meta-data=/dev/mapper/ol-root isize=256 agcount=4, agsize=1966080 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0 finobt=0 spinodes=0
data = bsize=4096 blocks=7864320, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=3840, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 7864320 to 15727616
Finally, I have expanded XFS file system on root mount point. Let's check current overall space usage.
[root@test ~]# df -h /
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/ol-root 60G 20G 41G 33% /
Thanks, very helpful.
My pleasure!