From e4686b6185488e1e71fb9bbe2e25b3321b8e471b Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Sun, 14 Feb 2021 21:32:32 +0000 Subject: On systems with low RAM, remove unwanted packages after install (mga#27872). This avoids running out of space in the RAM overlay filesystem. --- NEWS | 3 +++ draklive-install | 16 ++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 134e680..17caa35 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,6 @@ +- on systems with low RAM, remove unwanted packages after install (mga#27872) + (this avoids running out of space in the RAM overlay filesystem) + 2.29 - revert generate report.bug.xz on exit diff --git a/draklive-install b/draklive-install index d508fa1..c084713 100755 --- a/draklive-install +++ b/draklive-install @@ -91,13 +91,20 @@ sub install_live() { my $persistent = -e '/run/mgalive/persistent'; + # Don't remove packages from a persistent live system, as they will no + # longer be available for future installs. Don't remove packages from + # a non-persistent live system with insufficient RAM to accomodate the + # changes that will be stored in the upper layer of the overlay file + # system (mga#27872). + my $remove_after_install = $persistent || ram_size_in_MB() < 750; + display_start_message(); init_hds($in, $all_hds, $fstab); ask_partitions_loop($in, $all_hds, $fstab, $copy_source); - remove_unused_packages($in, $copy_source) if !$persistent; + remove_unused_packages($in, $copy_source) if !$remove_after_install; prepare_root($in); copy_root($in, $copy_source); - remove_unused_packages($in, $::prefix) if $persistent; + remove_unused_packages($in, $::prefix) if $remove_after_install; complete_install($in, $all_hds); setup_bootloader($in, $all_hds, $fstab); install_updates($in); @@ -106,6 +113,11 @@ sub install_live() { $in->exit(0); } +sub ram_size_in_MB() { + my @mem_total = map { /(\d+)/ } grep { /^MemTotal:/ } cat_("/proc/meminfo"); + $mem_total[0] / 1024; +} + sub umount_all { my ($fstab, $o_except_swap) = @_; #- make sure nothing is mounted in the new root -- cgit v1.2.1