linux:misc:expand_partition_and_filesystem

Expand partinion and filesystem using Growpart

Resizing /dev/sdb1 to fill all disk space

root@server# lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0   40G  0 disk
└─sda1   8:1    0   40G  0 part /
sdb      8:16   0  200G  0 disk
└─sdb1   8:17   0  100G  0 part /mnt/data
 
root@server# partprobe /dev/sdb
root@server# lsblk
 
# if this doesn't show newly available disk size, use the following command:
root@server# echo 1 > /sys/class/block/sdb/device/rescan
root@server# lsblk
 
# install cloud-guest-utils
root@server# apt install cloud-guest-utils -y
 
# Expand the partition
root@server# growpart /dev/sdb 1
 
root@server# df -Th /dev/sdb1
 
# for ext4
root@server# resize2fs /dev/sdb1
 
# for xfs (you must give mount point, not the device (id /dev/sdb1 is mounted in /mnt/data)
root@server# xfs_growfs /mnt/data
 
# verify
root@server# lsblk
root@server# df -h
  • linux/misc/expand_partition_and_filesystem.txt
  • Last modified: 2025/10/15 09:05
  • by tplecko