I know that I am supposed to set mem=MEMORY_LIMIT
. But I do not know where to go, during runtime, or during boot time, in order to set a limit to the total physical memory that the OS has control of.
I am running I/O benchmarks, and I would like to limit the amount of overall physical memory that is available.
I found the answer I was looking for. Basically, the parameter that sets the total available physical memory is "mem=MEMORY_LIMIT". And this is a kernel boot parameter. You need to add, say "mem=1G" for maximum of 1GB available physical memory to the kernel boot parameter. For more info on how to add kernel boot parameters look at https://wiki.ubuntu.com/Kernel/KernelBootParameters
Edit your kernel boot parameters in lilo.conf
, grub.conf
, grub.cfg
, or menu.lst
(which one depends on your particular distro and bootloader; check your distro's documentation for more detail) to include the parameter mem=512M
(or whatever size you want to emulate) on the line specifying your kernel parameters.
For instance, in Grub, there should be a line that says something like kernel /boot/vmlinuz param1=val1 param2=val2
. Add the mem=512M
to that list of parameters. You can create separate entries for your boot menu by copying these entire definitions, renaming them, and configuring each with a different amount of memory, so you can quickly boot with different settings.
To add to Brian Campbell's list, for the uBoot bootloader on the BeagleBone / Black devices, edit the kernel paramters in /boot/uboot/uEnv.txt
Add or modify the line mmcargs=setenv bootargs mem=512M
[tested with Debian]
Use > free
before and after [reboot] to confirm the modification
I've followed the instructions in this page that KZcoding mentioned (part: Permanently Add a Kernel Boot Parameter)
My Linux is (vm in virtualbox):
Linux ubuntu 4.4.0-21-generic #37-Ubuntu SMP Mon Apr 18 18:33:37 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
Before setting:
yavuz@ubuntu:~$ free -m
total used free shared buff/cache available
Mem: 3630 305 3010 6 314 3264
Swap: 3767 0 3767
Just changed this line in /etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT=""
to
GRUB_CMDLINE_LINUX_DEFAULT="mem=2G"
then restart the server. After restart:
yavuz@ubuntu:~$ free -m
total used free shared buff/cache available
Mem: 2000 298 1385 4 315 1651
Swap: 3767 0 3767
A1: Yes, you have to reboot.
A2: The kernel is rather unforgiving with respect to typos. There are no error messages. Could that be your problem? Examples: " mem=512M" and " mem=2G". Don't forget the space following the previous parameter, mem is in lower case, and K, M or G are upper case.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.