Geavanceerd
Zoeken inHow-to-gidsen
Zo zoek je
  • Typ de taak in je eigen woorden (poort vinden, firewall openen, schijf vol) of plak een foutmelding tussen aanhalingstekens.
  • Kies "Snel antwoord" om alleen de commando's te zien, of een gebied om in één vakgebied te blijven.
  • "twee woorden" vindt precies die zin.
  • Gewone woorden vinden namen, teksten en voorbeelden.
  • ↑ ↓ bewegen · Enter openen · Esc sluiten · / zoeken
Probeer:

How-to 217System · Storage

How to grow an XFS file system online

The data disk is 95 % full. In the cloud you can make the disk bigger in a minute — but Linux still shows the old size, because the partition and the file system must grow too. XFS grows while mounted and in use, no downtime. This how-to grows the disk, the partition and the file system, for plain partitions and LVM, and for ext4 too.

  • 5 Lessen
  • 12 Commando's

Dit deel is nog niet vertaald. Je ziet de Engelse tekst.

$ als gewone gebruiker# als root (of met sudo)

217.1

The quick answer

lsblk /dev/sdb
growpart /dev/sdb 1
xfs_growfs /data
df -h /data

217.2

Step by step

  1. Snapshot first — a disk snapshot in the cloud takes seconds and makes every next step safe.
  2. Make the disk bigger in the cloud console or CLI (for example az disk update --size-gb 256, aws ec2 modify-volume --size 256). Most clouds allow it while the VM runs.
  3. Let Linux see the new size — usually automatic; if lsblk still shows the old size, rescan:
echo 1 > /sys/class/block/sdb/device/rescan
  1. Grow the partition (quick answer, line 2) — growpart (package cloud-utils-growpart / cloud-guest-utils) moves the end of partition 1 to the end of the disk, while mounted. Without growpart: parted /dev/sdb resizepart 1 100%.
  2. Grow the file system (line 3) — xfs_growfs takes the mount point. It uses all the new space of the partition.
  3. With LVM — grow the physical volume, then the logical volume and the file system in one step:
pvresize /dev/sdb1
lvextend -r -l +100%FREE /dev/vg_data/lv_data

-r calls xfs_growfs (or resize2fs) for you.

  1. ext4 — the same steps, but the last one is resize2fs /dev/sdb1 (it takes the device).
  2. No shrinking — XFS can only grow. To make it smaller you must create a new, smaller file system and copy the data. Plan sizes with that in mind; start smaller and grow.

217.3

Check that it worked

lsblk /dev/sdb shows the partition with the new size; df -h /data shows the new size and more free space; the app kept running the whole time.

217.4

Common problems

ProblemCauseFix
NOCHANGE: partition 1 … cannot be grownKernel still sees the old disk size.Rescan the device (step 3), then growpart again.
xfs_growfs: … is not a mounted XFS filesystemDevice given instead of the mount point, or not XFS.Use the mount point; check findmnt.
growpart: command not foundPackage missing.Install cloud-utils-growpart / cloud-guest-utils, or use parted resizepart.
LV did not growPV not resized.pvresize first; check vgs for free space.
Space still the same after xfs_growfsPartition not grown.growpart before xfs_growfs.
Need a smaller XFSXFS cannot shrink.New smaller file system and copy (rsync -aHAX).

217.5

Go further

1Which three layers must grow after a cloud disk is made bigger?

The disk as seen by Linux, the partition (or LVM volume), and the file system.

2Can an XFS file system be made smaller?

No — XFS can only grow; to shrink, create a smaller file system and copy the data.

Alle commando's in dit hoofdstuk