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
This command shows the volume groups and how much free space (
VFree
) is available.2. Extend the Logical Volume
Use the free space in
vgdata
to extendlvdata
. To use all available free space:If you only want to extend by a specific size (e.g., 200GB), use:
3. Resize the Filesystem
After extending the LV, resize the filesystem to make use of the additional space.
If Using ext4:
If Using XFS:
Replace
/mountpoint
with the actual mount location of/dev/vgdata/lvdata
.4. Verify the New Size
Check the filesystem size:
Optionally, confirm the updated logical volume size:
You should now see the extended size of your logical volume and filesystem.