-1

I have the following problem:

I have a CentOS 7 VM virtualized by Hyper-V. Initially the Disk was about 200GB since it was only used as a MailServer. Now I'm running low on available diskspace and I thought "Yeah, you get a bigger hdd and problem is solved". At least thats what I thought.

CentOS sees the (now) larger space but i can't grow the root partition

Content of fdisk -l

Disk /dev/sda: 536.9 GB, 536870912000 bytes, 1048576000 sectors
Units = Sektoren of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000af050

Gerät  boot.     Anfang        Ende     Blöcke   Id  System
/dev/sda1   *        2048     1026047      512000   83  Linux
/dev/sda2         1026048   266338303   132656128   8e  Linux LVM

Disk /dev/mapper/centos-swap: 2181 MB, 2181038080 bytes, 4259840 sectors
Units = Sektoren of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/mapper/centos-root: 133.7 GB, 133655691264 bytes, 261046272     sectors
Units = Sektoren of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

Output of xfs_growfs /dev/mapper/centos-root

meta-data=/dev/mapper/centos-root isize=256    agcount=10, agsize=3276800 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0        finobt=0
data     =                       bsize=4096   blocks=32630784, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
log      =Intern                 bsize=4096   blocks=6400, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =keine                  extsz=4096   blocks=0, rtextents=0

resize2fs /dev/mapper/centos-root gives me an error about magic numbers in the superblock.

I have to admit I'm no pro in Linux and even less in all the RHEL-Derivates since I prefer Debian(based).

I hope you can help me on this.

Soundz
  • 109
  • 1
  • 4

2 Answers2

5

First:

It looks like you have an XFS filesystem, so of course resize2fs won't work (that's only for ext[234] filesystems). xfs_growfs, which you have already used, is the tool for growing XFS filesystems.

Second, and more importantly:

Your root filesystem is on a logical volume. There is no "root partition". There is a LVM "physical volume" (PV) on /dev/sda2. This makes up part of some volume group ("VG") on your system, and your root logical volume ("LV") is allocated from this pool.

If you have increased the size of your existing disk, you need to:

  1. Resize the /dev/sda2 partition to use the new space.
  2. Resize the physical volume with pvresize.
  3. Resize the root logical volume with lvextend
  4. Resize the filesystem with xfs_growfs.

You can probably combine the last two steps by using the --resizefs option to lvextend.

You could replace the first two steps by creating a new partition, create a new PV, and adding that PV to the existing volume group. The end result is approximately the same.

This is a lot of documentation here and in your favorite search engine.

larsks
  • 43,623
  • 14
  • 121
  • 180
1

Thanks for the answer but it didn't do the trick for me.

This is what I did:

fdisk /dev/sda
n
p
3
t
w

So i basically made a new partition using default values for size

partprobe

To rescan and make it known

then I did

 pvcreate /dev/sda3 

to add it to the physical volumes.

Afterwards I did

vgextend centos /dev/sda3

To add it to the volumegroup

Followed by extending the logical volume

lvextend -L +500G /dev/centos/root

And finally the growth

xfs_growfs /dev/centos/root

In case you are as inexperienced as me remember the commands

df -h
vgs
lvs
pvs
vgdisplay
lvdisplay
pvdisplay

Those commands provide valuable informations about the volumes.

Soundz
  • 109
  • 1
  • 4