Extend LVM by adding new disk

Submitted on Thu, 06/10/2021 - 22:09

Steps:

1. Locate new physical disk.

2. Create new LVM physical volume in the newly added disk.

3.  Extend the existing volume group by adding the new LVM physical volume.

4.  Extend the concerned logical volume.

5. Resize the filesystem of the logical volume.

 

1. Locate new physical disk

After adding new disk, reboot the system and run following command:

fdisk -l

Output:

Disk /dev/sdb: .....  

The new physical disk is available at /dev/sdb

The new disk can also be found with following command:

lvmdiskscan

 

2. Create new LVM physical volume in the newly added disk

pvcreate /dev/sdb

Confirm this with following commands:

  • pvs
  • pvdisplay
  • lvmdiskscan -l

 

3.  Extend the existing volume group by adding the new LVM physical volume

vgextend <volume-group-name> /dev/sdb

Find out the name of the existing volume group with following command vgs or vgdisplay

 

4.  Extend the logical volume as required

lvm lvextend -l +100%FREE /dev/<volume group name>/<logical volume name>

example: 

lvm lvextend -l +100%FREE /dev/ubuntu-vg/root 

 

5. Resize the filesystem of the logical volume

For ext file system:

resize2fs -p <file system>

 

For xfs file system

xfs_growfs <file system>

 

The filesystem details can be found from df -h

 

 

Tags

Add new comment

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.