Codebase list lowmem / 506811ed-28f8-43f0-80ca-4a1bb68a1def/main
506811ed-28f8-43f0-80ca-4a1bb68a1def/main

Tree @506811ed-28f8-43f0-80ca-4a1bb68a1def/main (Download .tar.gz)

This package is, frankly, a collection of hacks, hung on a reasonable
framework to which you can add more hacks to save memory. The memory saving
hacks are divided into four groups, which run at different times:
initialisation, post anna run, and pre partitioning.

Initialisation hacks are in the debian-installer-startup.d/*lowmem script,
in the lowmemcheck package. The is what decides if the system is low on
memory, and it creates /var/lib/lowmem as a flag indicating the system
should be in lowmem mode. Other hacks test for this file. There are
actually different low memory levels, as determined by the number in the
file. 1 is standard low memory mode, 2 turns on additional lowmem hacks
that can make the installation more difficult for the user.

Post anna run hacks are in the lowmem package, which is queued for install
by anna on lowmem systems, and provides a menu item.

Pre partitioning hacks are also in the lowmem package, and are run as
the partitioner is starting up.

Current hacks:

	disable framebuffer
		Running w/o framebuffer saves lots of memory. The unifont.bgf
		is also removed, saving much ram.

	remove translations, force English
		Happens at both init, and also trimtemplates is called by
		udpkg when unpacking packages.

		Saves a significant, but not huge amount of memory.
		(Used to save more, but cdebconf has gotten pretty good at
		dropping unused translations on its own.)

	truncate log files
		Happens after anna run. By now the log files may be rather
		large, and so this truncates them and restarts the tails.

		Saves a few hundred K of memory, at the expense of
		diagnostics.

	remove debconf templates after load
		This is done at initialisation by rootskel. After
		initialisation, udpkg takes care of it. It's not in lowmem,
		because this is a safe, simple trick that's worth doing on
		even systems with lots of memory.

		Saves a few hundred K of memory.
	
	allow user more control over what udebs are loaded
		This hack is enabled in level 2 lowmem mode. It makes anna
		not install standard priority udebs by default, and the
		user can choose which to install. Careful selection by the
		user can allow for installs with as little as 24 mb of
		memory.

	remove all keymaps
		After keyboard is selected, not needed. Done post-anna.
	
	remove selected modules
		Pre partitioning, only kernel modules for filesystems,
		raid, lvm, and the like are needed anymore. This hack
		deletes some other modules to save memory. This frees
		up several megabytes for the partitioner to run in, but
		unfortunately runs too late (after all these udebs are
		unpacked to the initrd) to reduce the overall amount of
		memory needed to install by more than the memory footprint
		of the partitioner. Therefore, removing even more modules
		at this point is not likely to help save any more memory.
	
Possible future hacks:

	remove locale definition
		Removing /usr/lib/locale might be worth it. If done after
		the main cdebconf is running, we should not even notice
		this 300k of stuff is gone, unless cdebconf is started
		on another VT or the like. It does cause cdebconf to not
		display borders properly and some other display ugliness
		for wide characters.

	progressive udeb installation
		Anna can install udebs on demand, so use this to defer
		loading some udebs until we know we need them, and
		particularly until after partitioning has enabled swap.
		
		For example, have os-prober only load its kernel module
		udebs on demand.

	find swap partitions and auto-swapon
		Try to scan disks for existing swap partitions and swapon.
		This will make later partitioning a bit more difficult, and
		requires a previous install.
	
	let user choose a partition to use as swap
		Scan disks for existing small-ish partitions, list them,
		and offer to turn them into swap space.

Updating lowmem levels
----------------------

To update the various lowmem levels, the process is to perform installations
with tight memory constraints. If the installer does not crash before the base
system installation, the amount of memory can be considered fine for the lowmem
level being tested. When possible, the xen platform should be tried as well.

To limit the amount of available memory for an installations, this can be
either done by specifying emulator settings (e.g. qemu -m option) or by booting
the kernel with the 'mem=...' option (which will work for real machines).

The levels are set in debian-installer-startup.d/S15lowmem. In order to test
lower limits than currently allowed, one can set e.g. lowmem=+0 to force the use
of level 0.

The free memory required to use LVM and encryption should be set in the
partman-base package, in ./partman, in load_extra() and in the partman-crypto
package, in ./lib/crypto-base.sh, in crypto_check_mem(). Use Portuguese as
language (because that will ask for country and timezone) and choose Guided
partitioning with all partitions separate to test this, first with LVM only to
set the LVM level, then with LVM+crypto to set the crypto level.

The level1 value should be set to the lowest amount of memory that will support
an install not in lowmem mode. (This is the max memory footprint of the
installer in non lowmem mode up to running the partitioner and swapon.) Use
Portuguese as language (because that will ask for country and timezone) and
choose Guided partitioning with all partitions separate to test this!
(without LVM nor encryption)

The level2 value should be set to the lowest amount of memory that will support
an install in lowmem mode. (This is the max memory footprint of the installer
in lowmem mode up to running the partitioner and swapon.). The lowmem mode can
be forced by booting with lowmem=1.
Again, choose Guided partitioning on encrypted LVM with all partitions separate.

The distinction between these two levels are extremely minimal since all unused
debconf translations are dropped after anna. In most cases, the two levels can
probably be set to the same value. Exception is when an architecture uses
DEBCONF_DROP_TRANSLATIONS=0. This can be necessary for installs where running
languagechooser is postponed (as is currently the case for installs to arm NAS
devices).

In both cases, you need to set min to absolute minimum amount of memory needed
for an install, booting with lowmem=2, loading only the nic-modules udeb,
partitioning by hand, etc.

Ideally, constraints should be tested for both netboot and businesscard images
(businesscard CD will use slightly more memory before partitioning that netinst
because of mirror selection).

NB: the minimum value should be updated in the manual in build/arch-options.
For architectures for which the level could not be tested, set lowmem-unchecked
in the lowmem variable.

NB: the minimum value should be updated in debian-installer/build/boot/x86/f2.txt

NB: the minimum memory required to run the graphical installer must
also be tested. See rootskel (debian-installer.d/S60frontend).