默认情况下,Pi设置为192MiB:64MiB RAM:VRAM拆分。由于我不会将Pi用于图形目的,因此我想更改拆分以分配更多普通RAM以简化交换使用。
还有一个类似的问题和相关的答案在这里。
—
吉文斯
默认情况下,Pi设置为192MiB:64MiB RAM:VRAM拆分。由于我不会将Pi用于图形目的,因此我想更改拆分以分配更多普通RAM以简化交换使用。
Answers:
这些是RAM拆分以及它们应用于的用途。
有几种方法可以管理RAM拆分:
您可以使用以下方法更改RAM拆分:
sudo cp /boot/arm[ram-split]_start.elf /boot/start.elf
[ram-split]
分配给CPU的RAM数量在哪里。重新启动后,将应用新值。
Hexxeh的rpi-update还支持更改RAM分配,您可以rpi-update [ram-split]
在[ram-split]
要分配给CPU的RAM数量的地方运行。重新启动后,将应用拆分。
最好的方法可能是使用select4.sh脚本,然后选择适当的RAM拆分。重新启动后,将应用新的拆分。
#!/bin/bash
##
## Raspberry Pi Memory Split Selector Script v4
## Author: SirLagz
## Website: http://sirlagz.net
##
## The purpose of this script is to make selecting the memory split
## on the RPi easy.
## Simply make this script executable if it's not already, move
## it to the directory with the elf files, and run it with ./select4.sh
## The menu should be pretty self explanatory.
##
cd /boot
clear
list=./*
b128det=0
b192det=0
b224det=0
b240det=0
bdefdet=0
for i in $list
do
case $i in
"./arm128_start.elf") b128det=1;;
"./arm192_start.elf") b192det=1;;
"./arm224_start.elf") b224det=1;;
"./arm240_start.elf") b240det=1;;
"./start.elf") bdefdet=1;;
esac
done
if [[ "$b192det" == "$bdefdet" ]] ; then
if cmp -s arm192_start.elf start.elf; then
current=192
fi
fi
if [[ "$b128det" == "$bdefdet" ]] ; then
if cmp -s arm128_start.elf start.elf; then
current=128
fi
fi
if [[ "$b224det" == "$bdefdet" ]] ; then
if cmp -s arm224_start.elf start.elf; then
current=224
fi
fi
if [[ "$b240det" == "$bdefdet" ]] ; then
if cmp -s arm240_start.elf start.elf; then
current=240
fi
fi
declare -i vram
vram=256-$current
success=1
sysram=`awk '/MemTotal/ { printf("%.0f",$2/1024) }' /proc/meminfo`
echo "##################################"
echo "## Raspberry Pi Memory ##"
echo "## Selector Script ##"
echo "##################################"
echo " Current Memory Split"
echo " CPU $current/$vram VRAM"
echo " Detected System RAM"
echo " $sysram MB"
echo "##################################"
echo "1) Set CPU/VRAM split to 128/128"
echo "2) Set CPU/VRAM split to 192/64"
if [[ "$b240det" == 0 ]] ; then
echo "3) Set CPU/VRAM split to 240/16 (NOT DETECTED. DO NOT USE)"
else
echo "3) Set CPU/VRAM split to 240/16"
fi
if [[ "$b224det" == 1 ]] ; then
echo "4) Set CPU/VRAM split to 224/32"
fi
echo "q) Quit"
echo "Enter Choice:";
read x
case $x in
1)
rm start.elf && cp arm128_start.elf start.elf
newram=128
;;
2)
rm start.elf && cp arm192_start.elf start.elf
newram=192
;;
3)
if [[ "$b240det" == 1 ]] ; then
rm start.elf && cp arm240_start.elf start.elf
newram=240
else
echo "The arm240_start.elf was not detected. Not changing ram split."
success=0
fi
;;
4)
rm start.elf && cp arm224_start.elf start.elf
newram=224
;;
q|Q)
exit 0
;;
*)
$0
;;
esac
if [[ $? -ne 0 ]]; then
echo "Memory Split setting failed"
elif [[ $success == 1 ]]; then
declare -i newvram
newvram=256-$newram
echo "Memory Split set to $newram/$newvram successfully"
fi
for i in $list
do
case $i in
"./arm128_start.elf") b128det=1;;
"./arm192_start.elf") b192det=1;;
"./arm224_start.elf") b224det=1;;
"./arm240_start.elf") b240det=1;;
"./start.elf") bdefdet=1;;
esac
done
if [[ "$bdefdet" -ne 1 ]]; then
$0
echo "=============================================================================="
echo "start.elf not detected. Please check that you have selected a valid ram split."
echo "=============================================================================="
fi
这是一个github链接,以防链接腐烂。
太大,无法发表评论,但相关。您可以通过运行以下命令检查ram拆分
$ sha1sum /boot/*start.elf
a3f72ae7eae537800454de8e4cb231cbd176c0e1 /boot/arm128_start.elf
7784527719031c1c7fce6f72cf3a5c8c23565f24 /boot/arm192_start.elf
82c6be2c9098c0c9c3d71f45bf16c1dc5adfcf08 /boot/arm224_start.elf
82c6be2c9098c0c9c3d71f45bf16c1dc5adfcf08 /boot/start.elf
拆分由具有匹配校验和的文件给定,因此在我的情况下是 224/32