Fix chroot DNS and mkfs.ext4 path for remote deployment

- Copy host /etc/resolv.conf into chroot before apk install (fixes DNS)
- Set static DNS (8.8.8.8) after chroot install for runtime
- Use PATH-based mkfs.ext4 instead of hardcoded /usr/sbin/
- Show chroot package install output (stdio: inherit)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-07 16:00:16 +00:00
parent 1fee80f1d7
commit b5ad20ce51

View File

@@ -68,7 +68,7 @@ export async function runSetup() {
execFileSync("truncate", ["-s", "256M", CONFIG.baseRootfs], {
stdio: "pipe",
});
execFileSync("sudo", ["/usr/sbin/mkfs.ext4", "-q", CONFIG.baseRootfs], {
execFileSync("sudo", ["mkfs.ext4", "-q", CONFIG.baseRootfs], {
stdio: "pipe",
});
execFileSync("sudo", ["mount", CONFIG.baseRootfs, ext4Mount], {
@@ -78,9 +78,9 @@ export async function runSetup() {
stdio: "pipe",
});
// DNS
// DNS — copy host resolv.conf for chroot package install, then set static
execSync(
`echo "nameserver 8.8.8.8" | sudo tee ${ext4Mount}/etc/resolv.conf > /dev/null`
`sudo cp /etc/resolv.conf ${ext4Mount}/etc/resolv.conf`
);
// Inittab for serial console
@@ -112,7 +112,12 @@ EOF`);
"rc-update add sshd default && ssh-keygen -A && " +
"echo 'PermitRootLogin prohibit-password' >> /etc/ssh/sshd_config && " +
"mkdir -p /run/openrc && touch /run/openrc/softlevel"],
{ stdio: "pipe", timeout: 120_000 }
{ stdio: "inherit", timeout: 120_000 }
);
// Set static DNS for runtime (replace host resolv.conf used during install)
execSync(
`echo "nameserver 8.8.8.8" | sudo tee ${ext4Mount}/etc/resolv.conf > /dev/null`
);
// Networking init script