Difference between revisions of "Extend lvm partition"

From DevOps Notebook
(Created page with "== Create lvm partition with fdisk == <pre> # fdisk /dev/sdX </pre> To Create new partition Press '''n'''. <br> Choose primary partition use '''p'''. <br> Choose which numbe...")
 
 
Line 30: Line 30:
 
</pre>
 
</pre>
  
# check if volume is extended and by how many Physical Extend (PE) are available.
+
Check if volume is extended and by how many Physical Extend (PE) are available.
 
<pre>
 
<pre>
 
# vgdisplay
 
# vgdisplay

Latest revision as of 17:09, 22 November 2019

Create lvm partition with fdisk

# fdisk  /dev/sdX

To Create new partition Press n.
Choose primary partition use p.
Choose which number of partition to be selected to create the primary partition.
Press 1 if any other disk available.
Change the type using t.
Type 8e to change the partition type to Linux LVM.
Press w to write the changes.

Create new PV (Physical Volume)

# pvcreate /dev/sdX1

Extend Volume Group

First get volume group name

# vgdisplay
  --- Volume group ---
  VG Name               vg_sql
  ...

Then run extend

# vgextend vg_sql /dev/sdX1

Check if volume is extended and by how many Physical Extend (PE) are available.

# vgdisplay
  ...
  Free  PE / Size       5119 / <20.00 GiB
  ...

Extend Logical Volume

You can take volume name from df

# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_sql-root   45G   37G  8.1G  83% /

Take free PE size from previous step (5119)

lvextend -l +5119 /dev/mapper/vg_sql-root

Resize filesystem

For ext3/4

# resize2fs /dev/mapper/vg_sql-root

For xfs

# xfs_grow /dev/mapper/vg_sql-root