NI Linux Real-Time Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Restrict available memory at boot-up

Solved!
Go to solution

Hello all.

For test purposes I would like to restrict the available physical memory at boot-up of my IC-3120 target (LV Real-Time 18.0). This target has 4GB physical memory and I would like to restrict it to ~500MB for testing.

 

I learnt that I could use GRUB to achieve this, however the general documentation for GRUB2 (https://www.gnu.org/software/grub) does not match with the flavor of GRUB used on the target. The only GRUB-related command I could find available on the target is

fw_setenv

which modifies 

/boot/grub/grubenv

as far as I can tell. All commands, config-file locations, and directories seem to be changed plus it is unclear which parameter I actually have to modify (once I found the correct config-file...)

 

Could someone please instruct me on how to achieve this? 

 

Thanks a lot!

 

 

 

 

0 Kudos
Message 1 of 4
(2,294 Views)
Solution
Accepted by topic author tbn123

There are several ways to to this but the easiest would be to set the 'othbootargs' boot variable via fw_setenv. The contents of that variable gets appended to the kernel boot command line.

 

For example doing:

 

fw_setenv othbootargs 'mem=512M'

 

will limit the memory (after a reboot) to 512 MBytes. You can verify that the variable got added to the kernel command line by reading '/proc/cmdline' after a reboot.

 

You can unset this variable by calling fw_setenv on this variable w/o a value:

 

fw_setenv othbootargs

 

 

You can find a description of various kernel parameters including the 'mem' one here: https://www.kernel.org/doc/html/v4.14/admin-guide/kernel-parameters.html

Make sure you read the section for the 'mem' variable, on x86 there are some caveats around possible collisions with the PCI address space (i.e. you might need to set the memmap variable too).

Message 2 of 4
(2,261 Views)

Thanks for this hint! This worked for me without setting the memmap variable as well.

 

Having found nothing about the attribute 

othbootargs

is there documentation on all the available parameters for fw_setenv? As I understand, the kernel-parameters that you referenced can be passed as parameters for othbootargs, correct?

 

Thanks again!

tbn123

0 Kudos
Message 3 of 4
(2,223 Views)

The 'othbootargs' variable is not documented because it is an internal implementation detail subject to change. The way it currently works the variable gets appended in grub.cfg to the kernel command line. You are correct in assuming you can pass multiple kernel-parameters (from the referenced document) via the othbootargs.

 

WARNING: The 'othbootargs' variable contents get append to the kernel boot command line for both runmode and safemode. Erroneous values in this variable can render the system un-bootable and it will require recovery via a USB stick/recovery tool.

0 Kudos
Message 4 of 4
(2,203 Views)