To detect newly added disks without rebooting, use the following command:
echo "- - -" > /sys/class/scsi_host/host32/scanReplace host32 with the appropriate host number if different on your system.
Create a physical volume on the new disk:
sudo pvcreate /dev/sdx # Replace /dev/sdx with your new disk identifierAdd the new physical volume to your existing volume group:
sudo vgextend your-vg-name /dev/sdx # Replace your-vg-name and /dev/sdx appropriatelyAllocate the newly available space to the logical volume:
sudo lvextend -l +100%FREE /dev/your-vg-name/your-lv-name # Replace with your volume group and logical volume namesResize the filesystem to use the new space on the logical volume:
sudo resize2fs /dev/your-vg-name/your-lv-name # Adjust as necessary, assuming an ext4 filesystemBefore manipulating /var, ensure all data is backed up and services that write to /var are stopped:
sudo systemctl stop nginx zabbix-server grafana-server prometheusMount the new logical volume temporarily to /mnt and copy all data:
sudo mount /dev/your-vg-name/your-lv-name /mnt
sudo rsync -avxHAX /var/ /mnt/Update /etc/fstab to use the new logical volume for /var:
# Open /etc/fstab with an editor, e.g., nano
sudo nano /etc/fstab
# Add or modify the line for /var
/dev/your-vg-name/your-lv-name /var ext4 defaults 0 2Unmount and remount to verify:
sudo umount /mnt
sudo mount -aRestart the stopped services:
sudo systemctl start nginx zabbix-server grafana-server prometheusUsing fdisk or parted, remove the OS disk partition (e.g., /dev/sda3):
sudo fdisk /dev/sdaIn fdisk, use d to delete and w to write changes to the disk.
Inform the kernel of the changes to the partition table:
sudo partprobe /dev/sdaOnce the partition is deleted, convert it into a physical volume:
sudo pvcreate /dev/sda3Extend your volume group and logical volume as described in Steps 3 and 4.
Check the new size of the filesystem:
df -h /var
2. Rescan the SCSI Host (if the above command doesn't work)
host32corresponds to the correct SCSI host for yoursdbdisk. You can list the available hosts using the following command:3. Verify the Updated Disk Information
After rescanning, check if the disk
sdbreflects the updated size:4. Expand the Partition (if applicable)
If you need to expand a partition on the disk, use a partitioning tool like
fdiskorpartedto resize the partition.5. Resize the Filesystem (if applicable)
If you have an existing filesystem on the partition, resize it to utilize the new space. For example, for an
ext4filesystem:This process should help update the disk to reflect the added space and make it available for use.