设置Linux中可用的总物理内存的限制

时间:2022-10-02 16:58:28

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.

我知道我应该设置mem=MEMORY_LIMIT。但我不知道在运行时或启动时该往哪里走,以便对操作系统控制的总物理内存设置一个限制。

I am running I/O benchmarks, and I would like to limit the amount of overall physical memory that is available.

我正在运行I/O基准,我希望限制可用的总体物理内存的数量。

5 个解决方案

#1


13  

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

我找到了我想要的答案。基本上,设置总可用物理内存的参数是“mem=MEMORY_LIMIT”。这是一个内核引导参数。您需要向内核引导参数添加最大1GB可用物理内存的“mem=1G”。有关如何添加内核引导参数的更多信息,请参见https://wiki.ubuntu.com/Kernel/KernelBootParameters

#2


5  

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.

在lilo中编辑内核引导参数。相依,grub。相依,grub。cfg或菜单。lst(这取决于您的特定发行版和引导加载程序;检查发行版的文档以获得更多细节),以便在指定内核参数的行中包含参数mem=512M(或您想要模拟的任何大小)。

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.

例如,在Grub中,应该有一行代码,比如内核/boot/vmlinuz param1=val1 param2=val2。将mem=512M添加到参数列表中。您可以为您的引导菜单创建单独的条目,方法是复制这些完整的定义、重命名它们,并使用不同的内存对它们进行配置,这样您就可以使用不同的设置快速地引导它们。

#3


2  

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]

要添加到Brian Campbell的列表,对于BeagleBone / Black设备上的uBoot bootloader,请在/boot/ uBoot /uEnv中编辑内核参数。txt添加或修改mmcargs=setenv bootargs mem=512M[用Debian测试]

Use > free before and after [reboot] to confirm the modification

使用>免费前后[重新启动]确认修改

#4


0  

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.

A2:内核对于拼写错误是不宽容的。没有错误消息。这是你的问题吗?例如:“mem=512M”和“mem=2G”。不要忘记前面参数的空间,mem是小写的,K, M或G是大写的。

#5


0  

I've followed the instructions in this page that KZcoding mentioned (part: Permanently Add a Kernel Boot Parameter)

我已经按照KZcoding提到的本页中的说明(部分:永久添加内核引导参数)

My Linux is (vm in virtualbox):

我的Linux是(虚拟机中的vm):

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

只是在/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

#1


13  

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

我找到了我想要的答案。基本上,设置总可用物理内存的参数是“mem=MEMORY_LIMIT”。这是一个内核引导参数。您需要向内核引导参数添加最大1GB可用物理内存的“mem=1G”。有关如何添加内核引导参数的更多信息,请参见https://wiki.ubuntu.com/Kernel/KernelBootParameters

#2


5  

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.

在lilo中编辑内核引导参数。相依,grub。相依,grub。cfg或菜单。lst(这取决于您的特定发行版和引导加载程序;检查发行版的文档以获得更多细节),以便在指定内核参数的行中包含参数mem=512M(或您想要模拟的任何大小)。

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.

例如,在Grub中,应该有一行代码,比如内核/boot/vmlinuz param1=val1 param2=val2。将mem=512M添加到参数列表中。您可以为您的引导菜单创建单独的条目,方法是复制这些完整的定义、重命名它们,并使用不同的内存对它们进行配置,这样您就可以使用不同的设置快速地引导它们。

#3


2  

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]

要添加到Brian Campbell的列表,对于BeagleBone / Black设备上的uBoot bootloader,请在/boot/ uBoot /uEnv中编辑内核参数。txt添加或修改mmcargs=setenv bootargs mem=512M[用Debian测试]

Use > free before and after [reboot] to confirm the modification

使用>免费前后[重新启动]确认修改

#4


0  

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.

A2:内核对于拼写错误是不宽容的。没有错误消息。这是你的问题吗?例如:“mem=512M”和“mem=2G”。不要忘记前面参数的空间,mem是小写的,K, M或G是大写的。

#5


0  

I've followed the instructions in this page that KZcoding mentioned (part: Permanently Add a Kernel Boot Parameter)

我已经按照KZcoding提到的本页中的说明(部分:永久添加内核引导参数)

My Linux is (vm in virtualbox):

我的Linux是(虚拟机中的vm):

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

只是在/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