To detect newly added disks without rebooting, use the following command:
echo "- - -" > /sys/class/scsi_host/host32/scan
Replace 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 identifier
Add the new physical volume to your existing volume group:
sudo vgextend your-vg-name /dev/sdx # Replace your-vg-name and /dev/sdx appropriately
Allocate 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 names
Resize 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 filesystem
Before manipulating /var
, ensure all data is backed up and services that write to /var
are stopped:
sudo systemctl stop nginx zabbix-server grafana-server prometheus
Mount 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 2
Unmount and remount to verify:
sudo umount /mnt
sudo mount -a
Restart the stopped services:
sudo systemctl start nginx zabbix-server grafana-server prometheus
Using fdisk
or parted
, remove the OS disk partition (e.g., /dev/sda3
):
sudo fdisk /dev/sda
In 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/sda
Once the partition is deleted, convert it into a physical volume:
sudo pvcreate /dev/sda3
Extend 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)
host32
corresponds to the correct SCSI host for yoursdb
disk. You can list the available hosts using the following command:3. Verify the Updated Disk Information
After rescanning, check if the disk
sdb
reflects the updated size:4. Expand the Partition (if applicable)
If you need to expand a partition on the disk, use a partitioning tool like
fdisk
orparted
to 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
ext4
filesystem:This process should help update the disk to reflect the added space and make it available for use.