0

I've been asked to increase the disk size of an LVM managed CentOS (virtual) server. The current partition table is as follows:

Disk /dev/vda: 429.5 GB, 429496729600 bytes, 838860800 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: 0x000ba858

Device Boot Start End Blocks Id System
/dev/vda1 * 2048 1026047 512000 83 Linux
/dev/vda2 1026048 104857599 51915776 8e Linux LVM
/dev/vda3 104857600 314572799 104857600 8e Linux LVM
/dev/vda4 314572800 629145599 157286400 8e Linux LVM

There's a total of 4 primary partitions and there's about 100GB of free space. Since the maximum allowed primary partitions is limited to 4 a new one can't be added.

When using ext4 partitions I think I could just use fdisk, delete /dev/vda4 and re-add it with the same starting position but a new end position. However, LVM isn't my forte. Will I be able to do the same thing with LVM? I assume one would also need to call the lvextend command as well as a resize2fs/xfs_growfs afterwards?

Output of lvdisplay:

  --- Logical volume ---
  LV Path                /dev/vg_directadmin/swap
  LV Name                swap
  VG Name                vg_directadmin
  LV UUID                qD1ib9-TAqx-gkKb-9ybC-Jg7g-653o-dDehoj
  LV Write Access        read/write
  LV Creation host, time localhost.localdomain, 2015-07-08 15:02:22 +0200
  LV Status              available
  # open                 2
  LV Size                1.00 GiB
  Current LE             256
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:1

  --- Logical volume ---
  LV Path                /dev/vg_directadmin/lv_tmp
  LV Name                lv_tmp
  VG Name                vg_directadmin
  LV UUID                ezqLis-CBQt-IiZK-7BjX-gvf5-b476-xxlkTe
  LV Write Access        read/write
  LV Creation host, time localhost.localdomain, 2015-07-08 15:02:22 +0200
  LV Status              available
  # open                 1
  LV Size                1.00 GiB
  Current LE             256
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:2

  --- Logical volume ---
  LV Path                /dev/vg_directadmin/lv_root
  LV Name                lv_root
  VG Name                vg_directadmin
  LV UUID                FfvRs5-bQav-72te-GxcF-wlan-hWoT-Ir3I36
  LV Write Access        read/write
  LV Creation host, time localhost.localdomain, 2015-07-08 15:02:23 +0200
  LV Status              available
  # open                 1
  LV Size                297.50 GiB
  Current LE             76160
  Segments               3
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:0
1

Took the afternoon to study up on LVM and found a solution. So, my initial solution turns out to be a working solution. Here's what I did.

  1. Use fdisk to make /dev/vda4 bigger. To do that delete partition 4, re-add it as a primary partition and let it make use of all available sectors. It'll ask you about deleting the LVM2_member signature, make sure to answer no. Set partition type to Linux LVM (8e). Write the new partition table.
  2. pvresize /dev/vda4.
  3. lvextend -l +100%FREE /dev/vg_directadmin/lv_root.
  4. Finally you need to resize /dev/vg_directadmin/lv_root with resize2fs (or xfs_growfs on CentOS 7 if I'm not mistaken). I had to do a disk check as well with e2fsck -f /dev/vg_directadmin/lv_root followed by resize2fs /dev/vg_directadmin/lv_root.
  5. Finally, remount.

Hope this helps someone else. Linux LVM on HowToForge is a helpful tutorial as well!

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.