Skip to content

Instantly share code, notes, and snippets.

@JayaByu
Last active August 14, 2023 08:06
Show Gist options
  • Save JayaByu/4a9497f8f67a3dcb0384dae75bacbcb8 to your computer and use it in GitHub Desktop.
Save JayaByu/4a9497f8f67a3dcb0384dae75bacbcb8 to your computer and use it in GitHub Desktop.

How i extend LVM

In case i already insert a new disk and it's /dev/sdc so...

~: sudo fdisk -l

then select your disk, who want to be ur LVM disk it's (sd?)

create disk partition in case i use (sda) disk

~: sudo fdisk /dev/sdb

inside fdisk /dev/sda

: m (to help)
: n (to create new partition)
: p (to create as primary disk)
: i press enter at this section (Partition number), (First Sector), (Last Sector)
: t (to change Linux type to LVM)
: Hex code type (8) for LVM 
: w (to write your new partition)

Tree

sda                 8:16   0  500G  0 disk
└─sda1              8:17   0  500G  0 part
  └─olympus-artemis 253:3  0  450G  0 lvm
sdc                 8:32   0  200G  0 disk
└─sdc1              8:33   0  200G  0 part

Create PV

:~ pvcreate /dev/sdc1

Check your detail, what LVM you want to resize

Im gonna extend this artemislv you can see on tree

:~ pvs -v

PV         VG       Fmt   Attr  PSize     PFree   DevSize  PV UUID
/dev/sda1  olympus  lvm2  a--   1.33t     7.00m   1.33t    d7fX0h-Eko9-XH64-fqRX-0mjd-g7pp-j1bk08

Insert to exsisting VG

:~ vgextend olympus /dev/sdc

Extend the LV

:~ lvextend -l +100G /dev/olympus/artemis

In this case i use CentOS with File System is xfs

:~ xfs_growfs /dev/olympus/artemis

if you use Ext2/Ext3/Ext4 u can use

:~ resizef2 /dev/olympus/artemis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment