git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #25005 from Lassulus/copytoram

nixos/stage1: add copytoram support

commitfa5196e47e3a72553155f684c8e66a97d91e6dff authorJörg Thalheim <Mic92@users.noreply.github.com> dateSun 30 Apr 2017, 11:22 (10 years ago) parentdce7ebb87a4615
2 files changed+24
nixos/doc/manual/installation/installing-usb.xml+5 nixos/modules/system/boot/stage-1-init.sh+19
nixos/doc/manual/installation/installing-usb.xml+5
@@ -34,6 +34,11 @@ ISO, copy its contents verbatim to your drive, then either:
3434 in <link xlink:href="https://www.kernel.org/doc/Documentation/kernel-parameters.txt">
3535 the kernel documentation</link> for more details).</para>
3636 </listitem>
37+ <listitem>
38+ <para>If you want to load the contents of the ISO to ram after bootin
39+ (So you can remove the stick after bootup) you can append the parameter
40+ <literal>copytoram</literal>to the <literal>options</literal> field.</para>
41+ </listitem>
3742</itemizedlist>
3843</para>
3944
nixos/modules/system/boot/stage-1-init.sh+19
@@ -154,6 +154,9 @@ for o in $(cat /proc/cmdline); do
154154 fi
155155 ln -s "$root" /dev/root
156156 ;;
157+ copytoram)
158+ copytoram=1
159+ ;;
157160 esac
158161done
159162
@@ -474,6 +477,22 @@ while read -u 3 mountPoint; do
474477 # doing something with $device right now.
475478 udevadm settle
476479
480+ # If copytoram is enabled: skip mounting the ISO and copy its content to a tmpfs.
481+ if [ -n "$copytoram" ] && [ "$device" = /dev/root ] && [ "$mountPoint" = /iso ]; then
482+ fsType=$(blkid -o value -s TYPE "$device")
483+ fsSize=$(blockdev --getsize64 "$device")
484+
485+ mkdir -p /tmp-iso
486+ mount -t "$fsType" /dev/root /tmp-iso
487+ mountFS tmpfs /iso size="$fsSize" tmpfs
488+
489+ cp -r /tmp-iso/* /mnt-root/iso/
490+
491+ umount /tmp-iso
492+ rmdir /tmp-iso
493+ continue
494+ fi
495+
477496 mountFS "$device" "$mountPoint" "$options" "$fsType"
478497done
479498