Skip to content

Commit

Permalink
feat: mount root as tmpfs instead of rootfs
Browse files Browse the repository at this point in the history
  • Loading branch information
sevenautumns committed Oct 29, 2024
1 parent aab6a28 commit 000a660
Showing 1 changed file with 16 additions and 2 deletions.
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 /* /.newroot/
exec bin/switch_root . "/bin/init" "$@"
'';
} // extraRootfsFiles;


Expand Down

0 comments on commit 000a660

Please sign in to comment.