fix: expand-overlay START=98 to run before dockerd(99)

This commit is contained in:
xiexiaobao 2026-06-27 15:32:55 +08:00
parent 30354fe40e
commit 2027ebc82e

View File

@ -1,9 +1,9 @@
#!/bin/sh /etc/rc.common
# /etc/init.d/expand-overlay
# Stage 2: Resize p3 filesystem, format & mount p4, configure Docker.
# Runs at START=99, after overlay is mounted and most services started.
# Runs at START=98 (before dockerd at 99) so Docker picks up data_root.
START=99
START=98
boot() {
local flag="/etc/resize2fs.done"
@ -11,7 +11,6 @@ boot() {
# ---- Stage 2a: Resize p3 filesystem ----
if [ ! -f "$flag" ]; then
# Wait for stage1 (uci-defaults) to finish
local i=0
while [ ! -f "/etc/expand-overlay.done" ] && [ $i -lt 30 ]; do
sleep 1
@ -26,27 +25,20 @@ boot() {
# ---- Stage 2b: Format and mount p4 data partition ----
if [ ! -f "$p4flag" ]; then
# Check if p4 is marked with RESET (needs formatting)
if dd if=/dev/mmcblk2p4 bs=5 count=1 2>/dev/null | grep -qF "RESET"; then
# Format p4 as ext4
mkfs.ext4 -F -L data /dev/mmcblk2p4 2>/dev/null
fi
# Mount p4 to /mnt/data
mkdir -p /mnt/data
mount /dev/mmcblk2p4 /mnt/data 2>/dev/null
# Create Docker directory on data partition
mkdir -p /mnt/data/docker
# Point Docker to data partition
uci -q set dockerd.globals.data_root="/mnt/data/docker"
uci -q commit dockerd
# Add to fstab for auto-mount on future boots
if ! grep -q "mmcblk2p4" /etc/config/fstab 2>/dev/null; then
block detect > /dev/null 2>&1
# block detect creates entries, we update the last one
local idx=$(( $(uci show fstab | grep -c "fstab.@mount") - 1 ))
[ "$idx" -ge 0 ] && uci -q set fstab.@mount[$idx].target="/mnt/data"
uci -q commit fstab