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:
Connect the second hard drive to the system. Connect the second hard drive to the system using a SATA cable or a USB adapter.
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:
pvcreate /dev/sdb
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
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
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.