Wednesday, December 2, 2015

linux - Logical Volume /dev/centos/root is extended but /dev/mapper/centos-root is not



New to Linux Fileservers and trying to extend /dev/mapper/centos-root
This is a test server




The Logical Volume /dev/centos/root is 27.99GB large:




--- Logical volume ---
LV Path /dev/centos/root
LV Name root
VG Name centos
LV UUID pTluxe-mE75-6X38-DVUa-QjkH-fCTg-odhdzY
LV Write Access read/write
LV Creation host, time localhost, 2018-09-28 13:08:05 +0200
LV Status available
# open 1
LV Size 27.99 GiB
Current LE 7166
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:0




But the filesystem /dev/mapper/centos-root is only 18G big





Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 18G 2.0G 17G 11% /
devtmpfs 192M 0 192M 0% /dev
tmpfs 204M 0 204M 0% /dev/shm
tmpfs 204M 5.0M 199M 3% /run
tmpfs 204M 0 204M 0% /sys/fs/cgroup
/dev/sda1 1014M 129M 885M 13% /boot
tmpfs 41M 0 41M 0% /run/user/1000




resize2fs returns the following error:




resize2fs 1.42.9 (28-Dec-2013)
resize2fs: Bad magic number in super-block while trying to open /dev/mapper/centos-root



Answer



Thomas's note about --resizefs really needs to be an answer. You can do both LV size change and file system extend in one command:




lvextend -r --size 28g /dev/centos/root


Just the file system part is also exposed as the fsadm command, which you can run on both ext and xfs file systems.



  fsadm resize /dev/centos/root

No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...