新增 Edit/Write/MultiEdit 事件攔截(原僅攔截 git commit Bash 指令), 補齊 getenv fallback 模式偵測,防止 hardcoded Token 透過工具直寫入檔案。 - .claude/hooks/commit-quality.js: 改寫為 PreToolUse JSON 格式,覆蓋 Edit/Write/MultiEdit - .claude/settings.json: 新增 Edit|Write|MultiEdit|Bash matcher 註冊 - .claude/hooks/__test__/commit-quality.test.sh: 4 case 自動化測試 - docs/guides/DISK_EXPANSION_GUIDE.md: 磁碟擴充 SOP 歸檔 - docs/p9_completion_report_*.md: P9-1 + P9-2 Sprint 完成報告 - docs/refactor/callback_prefix_proposal.md: 308 按鈕回呼前綴分析(Method C) - docs/refactor/openclaw_bot_routes_split_plan.md: 5999 行神檔拆分計畫 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
4.2 KiB
4.2 KiB
Gitea 110 Server Hard Disk Expansion Guide
Current Situation
- Server: 192.168.0.110 (Gateway)
- Current Disk: 1TB (/dev/sda) - 100% Full
- Filesystem: LVM (Logical Volume Manager)
- Root Volume:
/dev/mapper/ubuntu--vg-ubuntu--lv(998G)
Immediate Actions Required
1. Emergency Space Cleanup (Temporary Fix)
Clean Harbor Logs (263MB)
# Connect to server
ssh wooo@192.168.0.110
# Clean Harbor logs (requires sudo)
sudo truncate -s 0 /var/log/harbor/proxy.log
sudo truncate -s 0 /var/log/harbor/portal.log
# Clean system logs older than 7 days
sudo find /var/log -name "*.log" -mtime +7 -exec truncate -s 0 {} \;
sudo journalctl --vacuum-time=7d
# Check freed space
df -h /
Clean Docker Resources
# Clean Docker unused resources
docker system prune -a -f
docker volume prune -f
# Clean old containers and images
docker container prune -f
docker image prune -a -f
2. Permanent Solution: Disk Expansion
Option A: Expand Existing Disk (Virtual Environment)
If this is a VM, you can expand the existing virtual disk:
-
Shutdown VM and Expand Disk (in hypervisor):
- Expand
/dev/sdafrom 1TB to 2TB - Start VM
- Expand
-
Expand Partition:
# Use fdisk to expand partition sda3
sudo fdisk /dev/sda
# Delete partition 3, recreate with larger size
# Use same start sector, extend to end
# Reboot or reload partition table
sudo partprobe /dev/sda
- Expand LVM:
# Expand physical volume
sudo pvresize /dev/sda3
# Expand logical volume
sudo lvextend -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv
# Resize filesystem
sudo resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv
Option B: Add New Disk (Physical/Cloud)
Add a new disk and extend LVM:
-
Add New Disk:
- Physical: Install new HDD/SSD
- Cloud: Attach new volume
- VM: Add new virtual disk
-
Initialize New Disk (assuming new disk is
/dev/sdb):
# Create partition
sudo fdisk /dev/sdb
# Create primary partition using entire disk
# Set type to Linux LVM (8e)
# Create physical volume
sudo pvcreate /dev/sdb1
# Add to volume group
sudo vgextend ubuntu-vg /dev/sdb1
# Extend logical volume
sudo lvextend -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv
# Resize filesystem
sudo resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv
3. Verification Steps
After expansion:
# Check disk space
df -h /
# Check LVM status
sudo pvs
sudo lvs
sudo vgs
# Verify filesystem
sudo fsck -f /dev/mapper/ubuntu--vg-ubuntu--lv
Recommendations
Short-term (Today)
- Clean Harbor logs - Free up ~263MB immediately
- Clean Docker resources - Free up additional space
- Test Git push after cleanup
Medium-term (This Week)
- Expand disk to 2TB - Recommended minimum
- Set up log rotation - Prevent future fill-ups
- Monitor disk usage - Set up alerts at 80%
Long-term (Next Month)
- Implement automated cleanup scripts
- Move large data to external storage
- Consider separate storage for Docker/Gitea data
Emergency Commands
If Git push still fails after cleanup:
# Force cleanup and restart services
sudo systemctl restart gitea
sudo docker system prune -a -f --volumes
# Check Gitea status
sudo systemctl status gitea
Monitoring Setup
Add disk monitoring to prevent future issues:
# Create disk monitor script
cat > /home/wooo/disk_monitor.sh << 'EOF'
#!/bin/bash
USAGE=$(df / | tail -1 | awk '{print $5}' | sed 's/%//')
if [ $USAGE -gt 80 ]; then
echo "WARNING: Disk usage is ${USAGE}%" | logger -t disk_monitor
# Send alert to Telegram
curl -X POST "https://api.telegram.org/bot$TELEGRAM_BOT_TOKEN/sendMessage" \
-d "chat_id=$TELEGRAM_CHAT_ID&text=Disk usage on 110 is ${USAGE}%"
fi
EOF
chmod +x /home/wooo/disk_monitor.sh
echo "0 */6 * * * /home/wooo/disk_monitor.sh" | crontab -
Contact Information
For hardware/disk expansion:
- Virtual Environment: Contact VM admin
- Physical Server: Contact datacenter admin
- Cloud Environment: Use cloud provider console
Safety Notes
- Always backup data before disk operations
- Test commands in non-production environment first
- Have rollback plan ready
- Monitor system during expansion process