Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: mount root as tmpfs instead of rootfs #37

Merged
merged 1 commit into from
Oct 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions pkgs/linux-vm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,12 @@ let
"/etc/init.d/rcS".copy = writeScript "script" ''
#!/bin/sh

mkdir -p -- /dev /proc /sys
mkdir -p -- /dev /proc /sys /tmp
mount -t devtmpfs none /dev
mount -t proc procfs /proc
mount -t sysfs sysfs /sys/
mount -t cgroup2 none /sys/fs/cgroup
mount -t tmpfs none /tmp

ip link set dev eth0 up
udhcpc -A 0 -b -R
Expand All @@ -76,8 +78,20 @@ let
CONFIG_UDHCPC_DEFAULT_SCRIPT "/default.script"
'';
};
"/init".copy = writeScript "init" ''
#!/bin/sh

# mount new root as tmpfs
mkdir /.newroot
mount -t tmpfs none /.newroot
cd /.newroot

"/init".target = "/bin/init";
# move all files to new root
cp /init .
mv --no-clobber --target-directory=/.newroot /.* /*

exec bin/switch_root . "/bin/init" "$@"
'';
} // extraRootfsFiles;


Expand Down