skip to Main Content

This is probably a stupid question, but I have a centos VM which I allocated a 20GB disk to. I’ve since realized that is way to small for my needs. In virtualbox I’ve increase the size of the disk by 100GB, and I’ve assigned that to a new physical volume in the vm. I’ve added that volume to the same volume group and logical group as my root file system, but I’m not seeing any change in size available to the file system.

What do I need to do to allocate more space to the file system?

[root@localhost ~]$ 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  9.5M  7.8G   1% /run
tmpfs                    7.8G     0  7.8G   0% /sys/fs/cgroup
/dev/mapper/centos-root   18G   17G  353M  98% /
/dev/sda1               1014M  270M  745M  27% /boot
tmpfs                    1.6G   32K  1.6G   1% /run/user/1000


[root@localhost ~]# pvdisplay
  --- Physical volume ---
  PV Name               /dev/sda2
  VG Name               centos
  PV Size               19.04 GiB / not usable 0   
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              4875
  Free PE               0
  Allocated PE          4875
  PV UUID               OyPa3x-9gvv-wn7u-H9V4-GZUr-NvXS-rUyb29
   
  --- Physical volume ---
  PV Name               /dev/sda3
  VG Name               centos
  PV Size               <110.50 GiB / not usable 3.25 MiB
  Allocatable           yes 
  PE Size               4.00 MiB
  Total PE              28287
  Free PE               128
  Allocated PE          28159
  PV UUID               gP1ANK-7qVz-91bX-I5e0-Jhhj-P12c-rlyQXm

[root@localhost ~]# vgdisplay
  --- Volume group ---
  VG Name               centos
  System ID             
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  5
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               <129.54 GiB
  PE Size               4.00 MiB
  Total PE              33162
  Alloc PE / Size       33034 / <129.04 GiB
  Free  PE / Size       128 / 512.00 MiB
  VG UUID               w3y0SR-KCrW-njIZ-i1yU-Wx9A-c6jJ-iLSqtM

[root@localhost ~]# lvdisplay
  --- Logical volume ---
  LV Path                /dev/centos/swap
  LV Name                swap
  VG Name                centos
  LV UUID                DNZWst-UWUa-pAw5-PJQ1-8UNl-AjfV-zsjTRv
  LV Write Access        read/write
  LV Creation host, time localhost, 2020-09-01 16:00:13 +0100
  LV Status              available
  # open                 2
  LV Size                2.00 GiB
  Current LE             513
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:1
   
  --- Logical volume ---
  LV Path                /dev/centos/root
  LV Name                root
  VG Name                centos
  LV UUID                Yz0o0j-B164-JNi3-y5jd-Q9oo-EFe6-ecMgaM
  LV Write Access        read/write
  LV Creation host, time localhost, 2020-09-01 16:00:14 +0100
  LV Status              available
  # open                 1
  LV Size                <127.04 GiB
  Current LE             32521
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:0

2

Answers


  1. It seems you already resized the logical volume, so the last step is to resize the file system to match. Most current filesystems can be grown on-line while the system is running and the filesystem is mounted. Each has its own tool.

    For example for ext* you would run resize2fs /dev/mapper/centos-root .
    This needs no more arguments, by default it grows to the size of the partition/volume it’s in.

    The current default filesystem for centos is xfs, the command for that is xfs_growfs .

    Login or Signup to reply.
  2. First tell the kernel about the new partitions using partprobe:

     partprobe
    

    we need to resize our filesystem on /dev/sda(your root volume).You can first start with checking the filesystem on the partition using the e2fsck command and then resize it.

    e2fsck -f /dev/(your root volume)
    resize2fs /dev/(your root volume)
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search