Running out of disk space on a Hong Kong VPS without LVM means taking the server offline to resize partitions. LVM (Logical Volume Manager) lets you expand volumes online, add new disks to an existing volume group, and take consistent snapshots — all without downtime. Combined with NVMe-specific kernel tuning for maximum I/O throughput, LVM transforms raw VPS storage into a flexible, scalable layer.
Step 1: Check Current Disk Usage
<code">df -h # Filesystem usage summary lsblk # Block devices and partitions du -sh /var/* | sort -rh # Largest directories under /var du -sh /home/* | sort -rh # Identify what's consuming space ncdu / # Interactive disk usage explorer (apt install ncdu)
Step 2: Set Up LVM on a New Disk
<code">apt install -y lvm2 # Identify unpartitioned disk lsblk # Example: /dev/sdb (unpartitioned) # Create physical volume pvcreate /dev/sdb pvdisplay # Create volume group vgcreate data_vg /dev/sdb vgdisplay data_vg # Create logical volumes lvcreate -L 20G -n app_lv data_vg # 20 GB for app lvcreate -L 30G -n db_lv data_vg # 30 GB for database lvcreate -l 100%FREE -n logs_lv data_vg # Rest for logs # Format and mount mkfs.ext4 /dev/data_vg/app_lv mkfs.ext4 /dev/data_vg/db_lv mkfs.ext4 /dev/data_vg/logs_lv mkdir -p /var/www /var/lib/postgresql /var/log/apps # Add to /etc/fstab echo "/dev/data_vg/app_lv /var/www ext4 defaults 0 2" >> /etc/fstab echo "/dev/data_vg/db_lv /var/lib/postgresql ext4 defaults 0 2" >> /etc/fstab echo "/dev/data_vg/logs_lv /var/log/apps ext4 defaults 0 2" >> /etc/fstab mount -a df -h
Step 3: Expand a Logical Volume Online
<code"># When /var/www is running low — expand online (no downtime) # Check current size lvdisplay /dev/data_vg/app_lv # Option A: Add specific size lvextend -L +10G /dev/data_vg/app_lv # Option B: Fill remaining free space in VG lvextend -l +100%FREE /dev/data_vg/app_lv # Resize the filesystem (ext4 — no unmount required) resize2fs /dev/data_vg/app_lv # Verify df -h /var/www
Step 4: Add a New Disk to Existing VG
<code"># VPS provider added a new volume (/dev/sdc) # Add to existing volume group without downtime pvcreate /dev/sdc vgextend data_vg /dev/sdc # Now extend any LV using the new space lvextend -L +50G /dev/data_vg/db_lv resize2fs /dev/data_vg/db_lv vgdisplay data_vg # Shows new total size
Step 5: LVM Snapshots for Backups
<code"># Take a point-in-time snapshot before risky operations # (database migrations, OS upgrades, application deployments) # Snapshot uses copy-on-write — minimal space when nothing changes lvcreate -L 5G -s -n db_lv_snap /dev/data_vg/db_lv # Mount snapshot (read-only) and back up mkdir -p /mnt/snap mount -o ro /dev/data_vg/db_lv_snap /mnt/snap tar czf /backup/db_$(date +%Y%m%d).tar.gz -C /mnt/snap . umount /mnt/snap # Remove snapshot after backup lvremove /dev/data_vg/db_lv_snap # If deployment went wrong — restore snapshot: # umount /var/lib/postgresql # lvconvert --merge /dev/data_vg/db_lv_snap # mount /var/lib/postgresql
Step 6: NVMe Performance Tuning
<code"># Verify you have NVMe
lsblk -d -o NAME,TYPE,ROTA
# ROTA=0 means SSD/NVMe
# Check current I/O scheduler
cat /sys/block/nvme0n1/queue/scheduler
# [mq-deadline] kyber none — 'none' is usually best for NVMe
# Set to 'none' (pass-through) for NVMe
echo 'none' > /sys/block/nvme0n1/queue/scheduler
# Make permanent
cat > /etc/udev/rules.d/60-nvme-scheduler.rules << 'EOF'
ACTION=="add|change", KERNEL=="nvme[0-9]*", ATTR{queue/scheduler}="none"
EOF
# Increase read-ahead for sequential I/O (databases, backups)
blockdev --setra 4096 /dev/nvme0n1 # 2 MB read-ahead
# Filesystem mount options for NVMe in /etc/fstab:
# Add: noatime,nodiratime
# /dev/data_vg/db_lv /var/lib/postgresql ext4 defaults,noatime,nodiratime 0 2
# Benchmark NVMe performance
apt install -y fio
fio --name=seq_read --ioengine=libaio --direct=1 --rw=read \
--bs=1M --size=1G --numjobs=1 --runtime=30 --filename=/tmp/fio_test
# Expected NVMe: 1500–3500 MB/s sequential readStep 7: Monitor Disk Usage with Alerts
<code"># Alert when any filesystem exceeds 80%
cat > /opt/disk-alert.sh << 'EOF'
#!/bin/bash
THRESHOLD=80
df -H | grep -vE '^Filesystem|tmpfs|cdrom|udev' | while read line; do
USE=$(echo $line | awk '{print $5}' | sed 's/%//')
MOUNT=$(echo $line | awk '{print $6}')
if [ "$USE" -ge "$THRESHOLD" ]; then
echo "DISK ALERT: $MOUNT is ${USE}% full on $(hostname)" | \
mail -s "Disk Alert: $(hostname)" admin@yourdomain.com
fi
done
EOF
chmod +x /opt/disk-alert.sh
crontab -l | { cat; echo "*/30 * * * * /opt/disk-alert.sh"; } | crontab -Quick Reference: LVM Commands
| Task | Command |
|---|---|
| List physical volumes | pvs |
| List volume groups | vgs |
| List logical volumes | lvs |
| Extend LV by 10 GB | lvextend -L +10G /dev/vg/lv && resize2fs /dev/vg/lv |
| Create snapshot | lvcreate -L 5G -s -n snap /dev/vg/lv |
| Check VG free space | vgdisplay | grep Free |
Conclusion
LVM on a Hong Kong VPS turns static partitions into flexible storage — expand volumes online as your application grows, add new disks to an existing volume group without reconfiguration, and snapshot before risky operations for instant rollback. NVMe I/O scheduler tuning and filesystem mount options ensure the fast VPS storage is fully utilised. Together, these practices eliminate the “disk full at 3am” emergency for production Asia-Pacific applications.
Get reliable storage: Browse Server.HK Hong Kong VPS plans — all plans include NVMe SSD storage; additional disk volumes available for LVM expansion.