How to expand a volume given the following situation?
Looks like there is enough space on sda2
but I do not know how to make the volume centos-root
use it.
#> parted /dev/sda print free
Disk /dev/sda: 537GB
Number Start End Size Type File system Flags
32,3kB 1049kB 1016kB Free Space
1 1049kB 525MB 524MB primary xfs boot
2 525MB 537GB 536GB primary lvm
537GB 537GB 16,9kB Free Space
#> lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 500G 0 disk
├─sda1 8:1 0 500M 0 part /boot
└─sda2 8:2 0 499,5G 0 part
├─centos-root 253:0 0 8,5G 0 lvm /
└─centos-swap 253:1 0 1G 0 lvm [SWAP]
What I've tried so far:
resize2fs
lvextend
However I get the following errors:
#> resize2fs -P /dev/sda2
resize2fs: Device or resource busy while trying to open /dev/sda2
Couldn't find valid filesystem superblock.
#> lvextend -l 100%FREE /dev/mapper/centos-root
New size given (10 extents) not larger than existing size (2168 extents)
Update
With further experimenting, I've found out that I've missed to run pvresize
, then I could run also lvextend
successfully:
#> pvresize /dev/sda2
Physical volume "/dev/sda2" changed
1 physical volume(s) resized or updated / 0 physical volume(s) not resized
#> lvextend -l 100%FREE /dev/mapper/centos-root
Size of logical volume centos/root changed from <9,47 GiB (2424 extents) to <489,04 GiB (125194 extents).
Logical volume centos/root successfully resized.
Now the output of lsblk
looks much better:
#> lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 500G 0 disk
├─sda1 8:1 0 500M 0 part /boot
└─sda2 8:2 0 499,5G 0 part
├─centos-root 253:0 0 489G 0 lvm /
└─centos-swap 253:1 0 1G 0 lvm [SWAP]
Still, df -h
shows me the old size and the scsi rescan manual does not help, neither the official tool.
#> df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 7,8G 0 7,8G 0% /dev
tmpfs 7,8G 0 7,8G 0% /dev/shm
tmpfs 7,8G 17M 7,8G 1% /run
tmpfs 7,8G 0 7,8G 0% /sys/fs/cgroup
/dev/mapper/centos-root 8,5G 2,5G 6,1G 30% /
/dev/sda1 497M 151M 347M 31% /boot
tmpfs 1,6G 0 1,6G 0% /run/user/0
tmpfs 1,6G 0 1,6G 0% /run/user/1013
What to do?