persistir /persist en qemu

This commit is contained in:
Cat /dev/Nulo 2023-02-22 20:09:07 -03:00
parent 497e915167
commit 07a9a95b10
2 changed files with 10 additions and 6 deletions

3
.gitignore vendored
View file

@ -2,4 +2,5 @@ node_modules/
build-javascript build-javascript
cache/ cache/
artifacts/ artifacts/
secrets/ secrets/
tmp.ext4

13
qemu.ts
View file

@ -1,7 +1,7 @@
import { mkdtemp, rm } from "node:fs/promises"; import { mkdtemp, rm } from "node:fs/promises";
import { tmpdir } from "node:os"; import { tmpdir } from "node:os";
import path from "node:path"; import path from "node:path";
import { execFile } from "./helpers/better-api.js"; import { canAccess, execFile } from "./helpers/better-api.js";
import { sudoChownToRunningUser } from "./helpers/sudo.js"; import { sudoChownToRunningUser } from "./helpers/sudo.js";
export async function runQemu( export async function runQemu(
@ -17,9 +17,12 @@ export async function runQemu(
await sudoChownToRunningUser(squashfs); await sudoChownToRunningUser(squashfs);
const tmp = await mkdtemp(path.join(tmpdir(), "define-alpine-qemu-")); const tmp = await mkdtemp(path.join(tmpdir(), "define-alpine-qemu-"));
try { try {
const disk = path.join(tmp, "tmp.ext4"); // const disk = path.join(tmp, "tmp.ext4");
await execFile("fallocate", ["--length", "1G", disk]); const disk = "tmp.ext4";
await execFile("mkfs.ext4", ["-F", disk]); if (!(await canAccess(disk))) {
await execFile("fallocate", ["--length", "1G", disk]);
await execFile("mkfs.ext4", ["-F", disk]);
}
let kernelAppend = [ let kernelAppend = [
"root=/dev/sda", "root=/dev/sda",
@ -69,5 +72,5 @@ await runQemu(
initramfs: "artifacts/kernel/initramfs", initramfs: "artifacts/kernel/initramfs",
vmlinuz: "artifacts/kernel/vmlinuz", vmlinuz: "artifacts/kernel/vmlinuz",
}, },
{ graphic: true } { graphic: true, noShutdown: true }
); );