Here is a high-level overview of the steps to add an extra hard drive and increase the size of storage on Linux LVM:
- Prepare the new hard drive: Connect the new hard drive to your Linux system and use
fdisk
to create a new partition on the drive. - Create a physical volume: Use the
pvcreate
command to create a physical volume on the new partition. - Extend the volume group: Use the
vgextend
command to add the new physical volume to an existing volume group. - Extend a logical volume: Use the
lvextend
command to increase the size of a logical volume within the volume group. - Resize the file system: Use the
resize2fs
command to resize the file system to take advantage of the increased size of the logical volume.
Here is a more detailed explanation of each step:
- Prepare the new hard drive:
sudo fdisk /dev/sdb
- Press
n
to create a new partition - Press
p
for primary partition - Press
1
for the first partition - Press
Enter
to select the default first and last sectors - Press
w
to write the changes and exitfdisk
- Create a physical volume:
sudo pvcreate /dev/sdb1
- Extend the volume group:
sudo vgextend vg_name /dev/sdb1
where vg_name
is the name of the existing volume group.
- Extend a logical volume:
sudo lvextend -L +size /dev/vg_name/lv_name
where size
is the size to increase the logical volume by and lv_name
is the name of the logical volume to be extended.
- Resize the file system:
sudo resize2fs /dev/vg_name/lv_name
This will resize the file system to match the new size of the logical volume.
Note: These commands assume that the new hard drive is /dev/sdb and the existing volume group is named vg_name
. You should adjust these commands as necessary based on your system configuration. Additionally, it is recommended to back up important data before performing these steps.