ข้ามไปยังเนื้อหา

แผนขยายดิสก์ Database Host (194.1.0.2)

วันที่จัดทำ: 2026-05-27 สถานะ: COMPLETED — ดำเนินการเสร็จสิ้น 2026-05-27 14:53 ICT ผู้จัดทำ: RACKSYNC Engineering สัญญา: PM065-2026 (MA ประจำปี 2569) ระบบเป้าหมาย: Database / Time-Series Stack db (194.1.0.2)


Disk /dev/sda: 600 GiB (VMware virtual disk)
Partition table: MBR (dos)
/dev/sda1 2048 → 627144703 299 GiB ext4 / (bootable)
/dev/sda2 627146750 → 629143551 975 MiB Extended
/dev/sda5 627146752 → 629143551 975 MiB swap
Unallocated: sector 629143552 → 1258291199 = ~300 GiB FREE
Metric Value
Total visible filesystem 294 GB
Used 224 GB (81%)
Free 56 GB
VMware vDisk size 600 GB
Unallocated on disk ~300 GB
Data Size Location Mount Type
InfluxDB v2 data 112 GB /var/lib/docker/volumes/07acd356.../_data Anonymous Docker volume
Prometheus data 1 GB /var/lib/docker/volumes/fb83fec4.../_data Anonymous Docker volume
InfluxDB v2 config 8 KB /var/lib/docker/volumes/fe2b6109.../_data Anonymous Docker volume
Prometheus config 68 KB /var/lib/docker/volumes/fe37cd5b.../_data Anonymous Docker volume
MariaDB data 99 GB /home/mtd/rilf-db/mariadb/ Bind mount
Grafana data 50 MB /home/mtd/rilf-metrics/grafana-data/ Bind mount
Docker images 2.4 GB /var/lib/docker/ On root filesystem
Total data ~214 GB
Container Stack Ports
rilf-influxdb rilf-metrics 8086
rilf-grafana rilf-metrics 3000
rilf-prometheus rilf-metrics 9090 (internal)
rilf-chronograf rilf-metrics 8888
rilf-node-exporter rilf-metrics 9100
mariadb rilf-db 3306
phpmyadmin rilf-db 8090

Issue Detail Impact
MBR partition table MBR supports max 4 primary partitions. sda1=primary, sda2=extended, sda5=logical. Only 2 primary slots left (sda3, sda4) Can create sda3 as a new primary partition — no conflict
Extended partition blocks growpart sda2 (extended) starts at sector 627146750, immediately after sda1 (ends at 627144703). Gap is only 2046 sectors (~1 MB) Cannot grow sda1 rightward — sda2 is in the way
Swap inside extended sda5 (swap) is inside sda2. Deleting sda2 to grow sda1 requires disabling swap first Risky — if resize fails, system has no swap
Issue Detail Risk
InfluxDB on anonymous volume 112 GB of data on unnamed Docker volume 07acd356.... Compose file mounts ./influxdb → /var/lib/influxdb (v1 path) which is empty. Actual data is at /var/lib/influxdb2 on an auto-created anonymous volume docker compose down -v would destroy all InfluxDB data
Prometheus on anonymous volume 1 GB on fb83fec4.... No named volume in compose Same risk as above, lower impact
Moving Docker volumes If we move /var/lib/docker/ to the new partition, all anonymous volumes move with it — solves the space problem but requires Docker stop All 7 containers down during migration
Approach Downtime Affected Services
New partition + move Docker data dir 15-30 min All containers (InfluxDB, Grafana, Prometheus, MariaDB, etc.)
New partition + move only MariaDB 5-10 min MariaDB + phpMyAdmin only
New partition + symlink Docker volumes dir 15-30 min All containers
Tool Available Note
fdisk / sfdisk Yes Can create partitions
mkfs.ext4 Yes Can format
parted No Not installed
growpart No Not installed
rsync No Not installed — need apt install rsync or use cp -a

Strategy: New partition (sda3) + migrate /var/lib/docker/ to it

This is the safest approach because:

  • No partition resizing or deletion needed
  • All Docker data (including anonymous volumes with InfluxDB 112 GB) moves together
  • Root filesystem gets 112+ GB back, leaving plenty of room
  • One-time downtime, clean result
Partition Size Mount Contents After
/dev/sda1 (existing) 299 GB / OS + MariaDB bind mount (99 GB) + configs = ~110 GB used, ~185 GB free
/dev/sda3 (new) ~300 GB /var/lib/docker All Docker data: InfluxDB (112 GB), Prometheus (1 GB), images (2.4 GB), overlays = ~120 GB used, ~180 GB free
/dev/sda2+5 (keep) 975 MB swap Unchanged

If downtime must be minimized, move only MariaDB (99 GB) to /dev/sda3 mounted at /data, and update the compose bind mount. This avoids stopping all containers — only MariaDB restarts. But it doesn’t solve the anonymous volume risk.


Terminal window
# 0.1 Backup partition table
sfdisk -d /dev/sda > /root/sda-partition-backup-20260527.txt
# 0.2 Install rsync (needed for data migration)
apt update && apt install -y rsync
# 0.3 Verify current disk usage baseline
df -h / && docker system df
# 0.4 Create the new partition (no reboot needed if kernel re-reads)
# sda3 starts after sda2 ends (sector 629143552) and uses remaining space
fdisk /dev/sda <<'FDISK'
n
p
3
629143552
w
FDISK
# 0.5 Force kernel to re-read partition table
partprobe /dev/sda
# If partprobe fails (device busy), alternative:
# sfdisk --force --no-reread /dev/sda (then reboot)
# 0.6 Verify new partition
lsblk /dev/sda
# Expected: sda3 ~300G
# 0.7 Format new partition
mkfs.ext4 -L docker-data /dev/sda3
Terminal window
# 1.1 Stop all containers gracefully
cd /home/mtd/rilf-db && docker compose stop
cd /home/mtd/rilf-metrics && docker compose stop
# 1.2 Stop Docker daemon
systemctl stop docker
systemctl stop docker.socket
# 1.3 Mount new partition temporarily
mkdir -p /mnt/docker-new
mount /dev/sda3 /mnt/docker-new
# 1.4 Copy all Docker data (preserving permissions, ownership, xattrs)
rsync -aHAXx --info=progress2 /var/lib/docker/ /mnt/docker-new/
# 1.5 Verify copy
du -sh /var/lib/docker/ /mnt/docker-new/
# Sizes must match
# 1.6 Swap mount points
umount /mnt/docker-new
mv /var/lib/docker /var/lib/docker.old
mkdir -p /var/lib/docker
mount /dev/sda3 /var/lib/docker
Terminal window
# 2.1 Start Docker
systemctl start docker
# 2.2 Verify containers are intact
docker ps -a
# 2.3 Start containers
cd /home/mtd/rilf-metrics && docker compose start
cd /home/mtd/rilf-db && docker compose start
# 2.4 Verify all services
docker ps # all 7 containers running
curl -s http://localhost:8086/health # InfluxDB
curl -s http://localhost:3000/api/health # Grafana
curl -s http://localhost:3306 2>&1 # MariaDB (will get protocol error = running)
# 2.5 Verify disk usage
df -h
# Expected: / at ~40% (MariaDB 99GB + OS), /var/lib/docker at ~40%
Terminal window
# 3.1 Add to fstab (persistent mount across reboots)
echo "UUID=$(blkid -s UUID -o value /dev/sda3) /var/lib/docker ext4 defaults 0 2" >> /etc/fstab
# 3.2 Verify fstab syntax
mount -a # should succeed with no errors
# 3.3 Monitor for 24-48 hours before cleanup
# Check: InfluxDB writes, Grafana dashboards, MariaDB queries
# 3.4 After confirmed stable — remove old data (reclaims ~120 GB on root)
rm -rf /var/lib/docker.old

If anything goes wrong during migration:

Terminal window
# Stop Docker
systemctl stop docker docker.socket
# Unmount new partition
umount /var/lib/docker
# Restore original
mv /var/lib/docker.old /var/lib/docker
# Remove fstab entry if added
# vim /etc/fstab (remove the sda3 line)
# Start Docker
systemctl start docker
# Start containers
cd /home/mtd/rilf-metrics && docker compose start
cd /home/mtd/rilf-db && docker compose start

Priority Action Why
Immediate Pin all Docker image tags in both compose files Prevent accidental major version jumps (see pre-upgrade report §10)
Immediate Name the InfluxDB anonymous volume or convert to bind mount Even on new partition, docker compose down -v is still dangerous
Week 1 Clean old Docker images (docker image prune) Reclaim ~583 MB
MA 2569 Upgrade Docker Engine 20.10 → 28.x Current version is 4+ years old, missing security patches
MA 2569 Plan Debian 11 → 12 upgrade EOL Aug 2026 (3 months away)

Risk Mitigation
Data loss during copy rsync preserves everything; /var/lib/docker.old kept until verified
Partition creation fails Backup partition table saved; sfdisk can restore
Kernel doesn’t see new partition partprobe or reboot (low risk on VMware)
Services down too long Pre-stage all commands; estimated 15-30 min for 120 GB rsync
Copy corrupted Compare du -sh before/after; verify each service health endpoint
fstab typo breaks boot Test with mount -a before reboot; can fix via VMware console if needed

บทบาท ชื่อ วันที่
ผู้จัดทำแผน RACKSYNC Engineering 2026-05-27
ผู้อนุมัติแผน (RACKSYNC) — —
ผู้รับทราบ (OBH) — —
ผู้ดำเนินการ — —

  • ma/2569/db-host-pre-upgrade-report.md — full pre-upgrade assessment
  • ma/2569/plan.md — MA 2569 master plan
  • docs/architecture.md — VM stack overview
  • /home/mtd/rilf-metrics/docker-compose.yml — metrics stack compose (on db host)
  • /home/mtd/rilf-db/docker-compose.yml — database stack compose (on db host)