新增 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>
179 lines
4.2 KiB
Markdown
179 lines
4.2 KiB
Markdown
# 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)
|
|
```bash
|
|
# 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
|
|
```bash
|
|
# 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:
|
|
|
|
1. **Shutdown VM and Expand Disk** (in hypervisor):
|
|
- Expand `/dev/sda` from 1TB to 2TB
|
|
- Start VM
|
|
|
|
2. **Expand Partition**:
|
|
```bash
|
|
# 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
|
|
```
|
|
|
|
3. **Expand LVM**:
|
|
```bash
|
|
# 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:
|
|
|
|
1. **Add New Disk**:
|
|
- Physical: Install new HDD/SSD
|
|
- Cloud: Attach new volume
|
|
- VM: Add new virtual disk
|
|
|
|
2. **Initialize New Disk** (assuming new disk is `/dev/sdb`):
|
|
```bash
|
|
# 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:
|
|
```bash
|
|
# 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)
|
|
1. **Clean Harbor logs** - Free up ~263MB immediately
|
|
2. **Clean Docker resources** - Free up additional space
|
|
3. **Test Git push** after cleanup
|
|
|
|
### Medium-term (This Week)
|
|
1. **Expand disk to 2TB** - Recommended minimum
|
|
2. **Set up log rotation** - Prevent future fill-ups
|
|
3. **Monitor disk usage** - Set up alerts at 80%
|
|
|
|
### Long-term (Next Month)
|
|
1. **Implement automated cleanup scripts**
|
|
2. **Move large data to external storage**
|
|
3. **Consider separate storage for Docker/Gitea data**
|
|
|
|
## Emergency Commands
|
|
|
|
If Git push still fails after cleanup:
|
|
```bash
|
|
# 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:
|
|
```bash
|
|
# 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
|