mirror of
https://github.com/nix-community/disko
synced 2024-11-10 06:14:14 +00:00
debug memory usage
This commit is contained in:
parent
55e874b9c1
commit
54bf06ba8c
1 changed files with 22 additions and 3 deletions
|
@ -67,13 +67,32 @@ let
|
|||
'';
|
||||
|
||||
installer = ''
|
||||
if [[ -f /sys/module/zfs/parameters/zfs_arc_max ]]; then
|
||||
# We have seen `cp` run out of memory when copying the store paths and using zfs.
|
||||
# Default for ARC is 1/2 of RAM, we choose 1/4 of RAM.
|
||||
# Since we mostly write to the store and don't read from it, we don't need a large ARC.
|
||||
# This hopefully gives zfs enough time to free up memory.
|
||||
QUARTER_RAM=$(($(grep MemTotal /proc/meminfo | awk '{print $2 * 1024}') / 4))
|
||||
echo "$QUARTER_RAM" > /sys/module/zfs/parameters/zfs_arc_max
|
||||
fi
|
||||
|
||||
# Useful for monitoring memory usage
|
||||
#echo $(($(cat /sys/module/zfs/parameters/zfs_arc_max) / 1024 / 1024)) MB
|
||||
#(while true; do
|
||||
# ${pkgs.procps}/bin/free -h
|
||||
# if [[ -f /sys/module/zfs/parameters/zfs_arc_max ]]; then ${pkgs.zfs}/bin/arcstat; fi
|
||||
# ${pkgs.procps}/bin/ps -eo pid,ppid,comm,%mem,%cpu --sort=-%mem | head -n 4
|
||||
# # this can be very verbose
|
||||
# # ${pkgs.linuxPackages_latest.mm-tools}/bin/slabinfo
|
||||
# sleep 1
|
||||
#done) &
|
||||
|
||||
# populate nix db, so nixos-install doesn't complain
|
||||
export NIX_STATE_DIR=${systemToInstall.config.disko.rootMountPoint}/nix/var/nix
|
||||
nix-store --load-db < "${closureInfo}/registration"
|
||||
|
||||
# We copy files with cp because `nix copy` seems to have a large memory leak
|
||||
mkdir -p ${systemToInstall.config.disko.rootMountPoint}/nix/store
|
||||
xargs cp --recursive --target ${systemToInstall.config.disko.rootMountPoint}/nix/store < ${closureInfo}/store-paths
|
||||
# We copy files with rsync because `nix copy` seems to have a large memory leak
|
||||
${pkgs.rsync}/bin/rsync -rtpl --files-from=${closureInfo}/store-paths / ${systemToInstall.config.disko.rootMountPoint}
|
||||
|
||||
${systemToInstall.config.system.build.nixos-install}/bin/nixos-install --root ${systemToInstall.config.disko.rootMountPoint} --system ${systemToInstall.config.system.build.toplevel} --keep-going --no-channel-copy -v --no-root-password --option binary-caches ""
|
||||
umount -Rv ${systemToInstall.config.disko.rootMountPoint}
|
||||
|
|
Loading…
Reference in a new issue