3

We have a CentOS 7 VPS with 20GB of SSD space, we later upgraded it to 160GB but I'm a little confused on how to extend the / partition. We have multiple full backups but I'd rather not reinstalling everything only to extend the disk size.

df -h gives the following result:

Filesystem              Size  Used Avail Use% Mounted on
/dev/mapper/vg-lv_root   18G   12G  5.3G  68% /
devtmpfs                3.9G     0  3.9G   0% /dev
tmpfs                   3.9G     0  3.9G   0% /dev/shm
tmpfs                   3.9G  8.5M  3.9G   1% /run
tmpfs                   3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/sda1               477M  193M  255M  44% /boot
tmpfs                   799M     0  799M   0% /run/user/0

fdisk -l gives the following result:

Disk /dev/sda: 171.8 GB, 171798691840 bytes, 335544320 sectors
Units = sectors 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: 0x0009fba7

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     1026047      512000   83  Linux
/dev/sda2         1026048    20971519     9972736   8e  Linux LVM
/dev/sda3        20971520    41943039    10485760   8e  Linux LVM

Thanks in advance.

edit:

pvdisplay output:

  --- Physical volume ---
  PV Name               /dev/sda2
  VG Name               vg
  PV Size               9.51 GiB / not usable 3.00 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              2434
  Free PE               0
  Allocated PE          2434
  PV UUID               ZltsYs-V501-Z2uY-28Z5-1ed1-v7VQ-Zh1yAH

  --- Physical volume ---
  PV Name               /dev/sda3
  VG Name               vg
  PV Size               10.00 GiB / not usable 4.00 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              2559
  Free PE               0
  Allocated PE          2559
  PV UUID               5ugv7f-KZPm-JQkB-g0fk-ZE3c-mD4d-4U2A9j

vgdisplay output:

  --- Volume group ---
  VG Name               vg
  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               19.50 GiB
  PE Size               4.00 MiB
  Total PE              4993
  Alloc PE / Size       4993 / 19.50 GiB
  Free  PE / Size       0 / 0
  VG UUID               gEjaWG-mvkc-k5FD-dtB0-9fA4-4VCY-k5619J

lvdisplay output:

  --- Logical volume ---
  LV Path                /dev/vg/lv_root
  LV Name                lv_root
  VG Name                vg
  LV UUID                Tvyt4e-11m4-kzsV-dPY9-VIPD-Uefx-UM7Tl6
  LV Write Access        read/write
  LV Creation host, time localhost, 2015-04-13 17:15:48 +0200
  LV Status              available
  # open                 1
  LV Size                17.42 GiB
  Current LE             4459
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:0

  --- Logical volume ---
  LV Path                /dev/vg/lv_swap
  LV Name                lv_swap
  VG Name                vg
  LV UUID                1ZT9Xj-3MZx-5gG7-Q7Lg-b3xU-jMVI-mHXDzJ
  LV Write Access        read/write
  LV Creation host, time localhost, 2015-04-13 17:15:50 +0200
  LV Status              available
  # open                 2
  LV Size                2.09 GiB
  Current LE             534
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:1
1
  • Outputs of 'pvdisplay', 'vgdisplay' and 'lvdisplay' please.
    – Chopper3
    Aug 11, 2017 at 14:40

1 Answer 1

2

Ok, so you need to use fdisk to create /dev/sda4 with the new space from the end of /dev/sda3 to the limit of the drive - basically you're going to use the 'n' command in fdisk to create a new disk, pretty much follow your nose and remember to use 't' to set the disk type to '8e' for LVM. /dev/sda4 should then show up in 'fdisk -l'.

Then you need to use pvcreate to create a pv on /dev/sda4 called /dev/sda4, allocate all memory. This should then show up in pvdisplay.

Then you need to add it to the vg using vgextend, basically adding the pv /dev/sda4 to the vg called vg. Your vg will then be ~180GB when you run a vgdisplay but most of it will be free.

Then you need to use lvextend to grow your /dev/vg/lv_root lv (if that's where you want it anyway), adding all spare space from the vg called vg. lvdisplay should show the grown LV and vgdisplay should show zero free.

Then all you need to do is run a resize2fs to grow your filesystem (you don't mention what it is, presumably XFS? and then your df -h will show up as you need.

0

You must log in to answer this question.