Merge pull request #25005 from Lassulus/copytoram

nixos/stage1: add copytoram support

authored by Jörg Thalheim and committed by GitHub fa5196e4 dce7ebbd

+24
+5
nixos/doc/manual/installation/installing-usb.xml
··· 34 34 in <link xlink:href="https://www.kernel.org/doc/Documentation/kernel-parameters.txt"> 35 35 the kernel documentation</link> for more details).</para> 36 36 </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> 37 42 </itemizedlist> 38 43 </para> 39 44
+19
nixos/modules/system/boot/stage-1-init.sh
··· 154 154 fi 155 155 ln -s "$root" /dev/root 156 156 ;; 157 + copytoram) 158 + copytoram=1 159 + ;; 157 160 esac 158 161 done 159 162 ··· 473 476 # Wait once more for the udev queue to empty, just in case it's 474 477 # doing something with $device right now. 475 478 udevadm settle 479 + 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 476 495 477 496 mountFS "$device" "$mountPoint" "$options" "$fsType" 478 497 done