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

1
.gitignore vendored
View file

@ -3,3 +3,4 @@ build-javascript
cache/
artifacts/
secrets/
tmp.ext4

13
qemu.ts
View file

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