Disk Expansion

Notes for expanding normal Linux/RHEL filesystems that are not managed by Veritas.

Use this page for standard LVM and filesystem expansion.

Important: if the filesystem, disk group, mount, or application is managed by Veritas or a cluster, do not use this page. Use the Veritas Disk Expansion page instead.


Safety rule

Before expanding disk space, check:

1. Am I on the correct server?
2. Is this production or test?
3. Which filesystem is full?
4. Is the filesystem local, LVM, SAN, NFS, or cluster-managed?
5. Is Veritas or another cluster tool managing this storage?
6. Is there free space available in the volume group?
7. What filesystem type is used: XFS or ext4?
8. Do I have approval?
9. Do I have a backup or rollback plan?

Do not run storage commands blindly.


First checks

Check disk usage

df -h

Show filesystem type:

df -Th

Check block devices

lsblk

With filesystem information:

lsblk -f

Check mount point

findmnt /mount/point

Example:

findmnt /data

Check LVM layout

sudo pvs
sudo vgs
sudo lvs

More detail:

sudo pvdisplay
sudo vgdisplay
sudo lvdisplay

Understand the structure

Normal LVM flow:

Disk / Partition
      โ†“
Physical Volume / PV
      โ†“
Volume Group / VG
      โ†“
Logical Volume / LV
      โ†“
Filesystem: XFS or ext4
      โ†“
Mount point: /data

Example:

/dev/sdb1
  โ†’ PV
  โ†’ vg_data
  โ†’ lv_app
  โ†’ xfs
  โ†’ /data

Check if there is free space in the VG

sudo vgs

Look for:

VFree

Example:

VG        VSize    VFree
vg_data   100.00g  20.00g

If VFree has enough space, you may be able to extend the logical volume.


Check filesystem type

df -Th /mount/point

Example:

df -Th /data

You need to know whether the filesystem is:

xfs
ext4

because the grow command is different.


Expand LVM when VG has free space

Example: add 10 GB to /data.

1. Identify the LV

df -h /data
lsblk
sudo lvs

Example LV:

/dev/vg_data/lv_app

2. Extend the logical volume

Add 10 GB:

sudo lvextend -L +10G /dev/VG_NAME/LV_NAME

Example:

sudo lvextend -L +10G /dev/vg_data/lv_app

3A. Grow XFS filesystem

For XFS, grow by mount point:

sudo xfs_growfs /mount/point

Example:

sudo xfs_growfs /data

3B. Grow ext4 filesystem

For ext4, grow by device:

sudo resize2fs /dev/VG_NAME/LV_NAME

Example:

sudo resize2fs /dev/vg_data/lv_app

4. Verify

df -h /data
sudo lvs
lsblk

One-command LVM and filesystem grow

Sometimes this works and is convenient:

sudo lvextend -r -L +10G /dev/VG_NAME/LV_NAME

Example:

sudo lvextend -r -L +10G /dev/vg_data/lv_app

The -r option attempts to resize the filesystem automatically.

Always verify after:

df -h
sudo lvs

Use all free VG space

Use all remaining free space in the volume group:

sudo lvextend -l +100%FREE /dev/VG_NAME/LV_NAME

Example:

sudo lvextend -l +100%FREE /dev/vg_data/lv_app

Then grow the filesystem.

For XFS:

sudo xfs_growfs /data

For ext4:

sudo resize2fs /dev/vg_data/lv_app

Verify:

df -h /data
sudo lvs

Expand when a new disk was added

If a new disk was added to the server, first identify it.

1. Check new disk

lsblk

Example new disk:

/dev/sdb

Be very careful to identify the correct disk.


2. Create a partition if required

Use company standard tools/procedure.

Common tools:

sudo fdisk /dev/sdb

or:

sudo parted /dev/sdb

This is dangerous if used on the wrong disk.

Example result might be:

/dev/sdb1

3. Create physical volume

sudo pvcreate /dev/sdb1

Verify:

sudo pvs

4. Add PV to existing VG

sudo vgextend VG_NAME /dev/sdb1

Example:

sudo vgextend vg_data /dev/sdb1

Verify:

sudo vgs

5. Extend LV

sudo lvextend -L +10G /dev/VG_NAME/LV_NAME

or use all free space:

sudo lvextend -l +100%FREE /dev/VG_NAME/LV_NAME

6. Grow filesystem

For XFS:

sudo xfs_growfs /mount/point

For ext4:

sudo resize2fs /dev/VG_NAME/LV_NAME

7. Verify

df -h
lsblk
sudo pvs
sudo vgs
sudo lvs

Expand when existing disk size was increased

Sometimes a virtual disk or SAN LUN is expanded.

1. Rescan disk

Example for sdb:

echo 1 | sudo tee /sys/class/block/sdb/device/rescan

Check:

lsblk

2. Grow partition if needed

If LVM uses a partition like /dev/sdb1, the partition may need to be grown.

Tools may include:

sudo growpart /dev/sdb 1

Then resize the PV:

sudo pvresize /dev/sdb1

If LVM uses the whole disk like /dev/sdb, use:

sudo pvresize /dev/sdb

Verify:

sudo pvs
sudo vgs

3. Extend LV and filesystem

Add space:

sudo lvextend -L +10G /dev/VG_NAME/LV_NAME

Grow filesystem:

sudo xfs_growfs /mount/point

or for ext4:

sudo resize2fs /dev/VG_NAME/LV_NAME

Verify:

df -h
sudo lvs

XFS notes

RHEL commonly uses XFS.

Important:

XFS can be grown online.
XFS cannot normally be shrunk.
xfs_growfs uses the mount point, not the block device.

Example:

sudo xfs_growfs /data

ext4 notes

Important:

ext4 can be grown.
resize2fs uses the block device.
Some ext4 operations may require the filesystem to be unmounted depending on the change.

Example:

sudo resize2fs /dev/vg_data/lv_app

Troubleshooting

LV expanded but df still shows old size

Filesystem was probably not grown.

Check filesystem type:

df -Th /mount/point

For XFS:

sudo xfs_growfs /mount/point

For ext4:

sudo resize2fs /dev/VG_NAME/LV_NAME

No free space in VG

Check:

sudo vgs

If VFree is 0, you need:

new disk added to VG
existing disk/LUN expanded
cleanup files
different storage request

Disk full but deleted files did not free space

Check for deleted files still held open:

sudo lsof | grep deleted

A service may need to be restarted to release the file.


First command set for disk expansion

hostnamectl
df -h
df -Th
findmnt
lsblk
lsblk -f
sudo pvs
sudo vgs
sudo lvs
blkid

Dangerous actions

Be careful with:

fdisk
parted
mkfs
wipefs
pvcreate
vgextend
lvremove
vgremove
pvremove
editing /etc/fstab
running commands on the wrong disk
expanding cluster-managed storage manually

These can destroy data or affect production.


Personal notes

Add sanitized notes here.

Examples:

- VG had free space, so LV was extended by 10 GB.
- LV was expanded but xfs_growfs was still needed.
- Disk was full because deleted log files were still open.
- New disk was added, then pvcreate and vgextend were used.