From ff0b0ade51bcc90326ec7c3446a11a78cf0b663e Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Sat, 8 Apr 2017 08:53:39 +0100 Subject: Avoid out-of-memory error at end of install. draklive-install mounts the swap partitions of the installed system. On machines with low memory, these will get used during installation. If we unmount the swap partitions before draklive-install exits, there may not be enough free memory to copy back the swapped out data, leading to a kernel out-of-memory error. So let draklive-install-lock-storage unmount them instead, after draklive-install has exited and freed up some memory. When the installer is run from the boot menu, draklive-install-lock-storage is not used, but the swap partitions will be automatically unmounted on reboot. --- draklive-install | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'draklive-install') diff --git a/draklive-install b/draklive-install index 26a6550..a319249 100755 --- a/draklive-install +++ b/draklive-install @@ -76,14 +76,16 @@ sub install_live() { } sub umount_all { - my ($fstab) = @_; + my ($fstab, $o_except_swap) = @_; #- make sure nothing is mounted in the new root foreach (sort { $b cmp $a } grep { /^$::prefix/ } map { (split)[1] } cat_('/proc/mounts')) { system('umount', $_); } #- make sure selected devices aren't mounted, and swap isn't used - foreach (grep { isSwap($_) } @$fstab) { - eval { fs::mount::swapoff($_->{device}) }; + if (!$o_except_swap) { + foreach (grep { isSwap($_) } @$fstab) { + eval { fs::mount::swapoff($_->{device}) }; + } } foreach (map { $_->{isMounted} && !isSwap($_) ? "/dev/$_->{device}" : () } @$fstab) { system('umount', $_); @@ -362,7 +364,9 @@ sub finish_installation { run_program::rooted($::prefix, 'sed', '-i', '/for draklive-install/d', '/etc/pam.d/polkit-1'); sync_logs(); #- cleanly umount here, it will avoid fs journals to be corrupted after a hackish reboot - umount_all($fstab); + #- but leave swap space, to avoid out-of-memory error on machines with little memory + #- draklive-install-lock-storage will unmount swap after we exit and free up some memory + umount_all($fstab, 1); clean_live_system_hds(); } -- cgit v1.2.1