How to add an extra second hard drive on Linux LVM and increase the size of storage

How to add an extra second hard drive on Linux LVM and increase the size of storage

To add an extra second hard drive on Linux LVM (Logical Volume Manager) and increase the size of storage, you will need to follow these steps:

  1. Connect the second hard drive to the system. Connect the second hard drive to the system using a SATA cable or a USB adapter.

  2. Create a physical volume on the second hard drive. Use the pvcreate command to create a physical volume on the second hard drive. Specify the device name of the hard drive as an argument.

For example, if the device name of the second hard drive is /dev/sdb, you can create a physical volume on it using the following command:

refer to:‮ual‬tturi.com
pvcreate /dev/sdb
  1. Extend the volume group with the second hard drive. Use the vgextend command to add the second hard drive to the volume group. Specify the name of the volume group and the device name of the second hard drive as arguments.

For example, if the name of the volume group is vg0 and the device name of the second hard drive is /dev/sdb, you can extend the volume group with the second hard drive using the following command:

vgextend vg0 /dev/sdb
  1. Increase the size of the logical volume. Use the lvextend command to increase the size of the logical volume. Specify the device name of the logical volume and the size that you want to add as arguments.

For example, if the device name of the logical volume is /dev/vg0/lv0, and you want to add 100GB of space to it, you can use the following command:

lvextend -L+100G /dev/vg0/lv0
  1. Resize the filesystem to use the additional space. Use the resize2fs command to resize the filesystem to use the additional space. Specify the device name of the logical volume as an argument.

For example:

resize2fs /dev/vg0/lv0

This will add the second hard drive to the volume group and increase the size of the logical volume and the filesystem.

Created Time:2017-10-28 21:38:57  Author:lautturi