mirror of
https://github.com/DrHo1y/orangepi-build.git
synced 2026-11-13 03:23:48 +07:00
Update bsp
This commit is contained in:
@@ -31,7 +31,7 @@ MACADDR=$(printf ${prefixes[$random]}':%02X:%02X:%02X:%02X:%02X\n' $[RANDOM%256]
|
||||
}
|
||||
|
||||
|
||||
# set fixed IP address from first randomly assigned one. If nothing is deteceted, generate one.
|
||||
# set fixed IP address from first randomly assigned one. If nothing is detected, generate one.
|
||||
set_fixed_mac ()
|
||||
{
|
||||
if [ -n "$(command -v nmcli)" ]; then
|
||||
@@ -47,10 +47,10 @@ set_fixed_mac ()
|
||||
[[ -z $MACADDR ]] && get_random_mac
|
||||
|
||||
if [[ -n "$(command -v nmcli)" && -n $UUID ]]; then
|
||||
nmcli connection modify $UUID ethernet.cloned-mac-address $MACADDR
|
||||
nmcli connection modify $UUID -ethernet.mac-address ""
|
||||
nmcli connection down $UUID >/dev/null 2>&1
|
||||
nmcli connection up $UUID >/dev/null 2>&1
|
||||
nmcli connection modify "$UUID" ethernet.cloned-mac-address "$MACADDR"
|
||||
nmcli connection modify "$UUID" -ethernet.mac-address ""
|
||||
nmcli connection down "$UUID" >/dev/null 2>&1
|
||||
nmcli connection up "$UUID" >/dev/null 2>&1
|
||||
elif [[ -f /etc/systemd/network/$DEVNAME.network ]]; then
|
||||
if ! grep '^ *MACAddress=' /etc/systemd/network/$DEVNAME.network > /dev/null; then
|
||||
sed -i "s/#MACAddress=/MACAddress=$MACADDR/g" /etc/systemd/network/$DEVNAME.network
|
||||
|
||||
@@ -50,6 +50,7 @@ syncToDisk () {
|
||||
if [ "$USE_RSYNC" = true ]; then
|
||||
${NoCache} rsync -aXWv \
|
||||
--exclude "lost+found" --exclude orangepi-ramlog.log \
|
||||
--delete \
|
||||
--links \
|
||||
${XTRA_RSYNC_TO[@]+"${XTRA_RSYNC_TO[@]}"} \
|
||||
$RAM_LOG $HDD_LOG 2>&1 | $LOG_OUTPUT
|
||||
|
||||
@@ -13,6 +13,15 @@
|
||||
|
||||
do_expand_partition()
|
||||
{
|
||||
# check if growroot (from cloud-initramfs-growroot package) is installed.
|
||||
# despite it's name, that package does NOT require cloud-init.
|
||||
# if so, it means the partition with root filesystem was already resized during initramfs.
|
||||
# in this case do nothing here, but return 0 to allow resize2fs to run (growroot does not handle that).
|
||||
if [[ -f /usr/share/initramfs-tools/hooks/growroot ]] || [[ -f /usr/share/initramfs-tools/scripts/local-bottom/growroot ]]; then
|
||||
echo "partition resize skipped: growroot detected."
|
||||
return 0
|
||||
fi
|
||||
|
||||
# trim any btrfs subvolume identifier given in square brackets (e.g. /dev/mapper/orangepi-root[/@])
|
||||
local rootsource=$(findmnt -n -o SOURCE / | sed 's~\[.*\]~~') # i.e. /dev/mmcblk0p1 or /dev/mapper/orangepi-root
|
||||
|
||||
@@ -162,6 +171,7 @@ do_resize_crypt()
|
||||
do_expand_ext4()
|
||||
{
|
||||
echo -e "\n### [resize2fs] Start resizing ext4 partition $1 now\n" >> ${Log}
|
||||
echo "Running 'resize2fs ${rootpart}' now..."
|
||||
resize2fs ${rootpart} >> ${Log} 2>&1
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) Authors: https://www.armbian.com/authors
|
||||
#
|
||||
@@ -29,5 +29,5 @@ if [ $logusage -ge $treshold ]; then
|
||||
# remove
|
||||
/usr/bin/find /var/log -name '*.[0-9]' -or -name '*.gz' | xargs -r rm -f
|
||||
# vacuum systemd-journald
|
||||
[ -d /var/log/journal ] && journalctl --vacuum-size=${JOURNAL_SIZE}
|
||||
[ -d /var/log/journal ] && journalctl --quiet --vacuum-size=${JOURNAL_SIZE}
|
||||
fi
|
||||
|
||||
@@ -37,7 +37,7 @@ activate_zram() {
|
||||
cpu_cores=$(grep -c '^processor' /proc/cpuinfo | sed 's/^0$/1/')
|
||||
[[ ${cpu_cores} -gt ${zram_max_devs} ]] && zram_devices=${zram_max_devs} || zram_devices=${cpu_cores}
|
||||
module_args="$(modinfo zram | awk -F" " '/num_devices/ {print $2}' | cut -f1 -d:)"
|
||||
[[ -n ${module_args} ]] && modprobe zram ${module_args}=$(( ${zram_devices} + 2 )) || return
|
||||
[[ -n ${module_args} ]] && modprobe zram ${module_args}=$(( zram_devices + 2 )) || return
|
||||
|
||||
swap_algo=${SWAP_ALGORITHM:=lzo}
|
||||
# Expose 50% of real memory as swap space by default
|
||||
@@ -45,11 +45,11 @@ activate_zram() {
|
||||
mem_info=$(LC_ALL=C free -w 2>/dev/null | grep "^Mem" || LC_ALL=C free | grep "^Mem")
|
||||
mem_info=$(echo $mem_info | awk '{print $2}')
|
||||
memory_total=$(( mem_info * 1024 ))
|
||||
mem_per_zram_device=$(( ${memory_total} / ${zram_devices} * ${zram_percent} / 100 ))
|
||||
mem_per_zram_device=$(( memory_total * zram_percent / zram_devices / 100 ))
|
||||
|
||||
# Limit memory available to zram to 50% by default
|
||||
mem_limit_percent=${MEM_LIMIT_PERCENTAGE:=50}
|
||||
mem_limit_per_zram_device=$(( ${memory_total} / ${zram_devices} * ${mem_limit_percent} / 100 ))
|
||||
mem_limit_per_zram_device=$(( memory_total * mem_limit_percent / zram_devices / 100 ))
|
||||
}
|
||||
|
||||
activate_zram_swap() {
|
||||
@@ -67,7 +67,7 @@ activate_zram_swap() {
|
||||
|
||||
for (( i=1; i<=zram_devices; i++ )); do
|
||||
swap_device=$(zramctl -f |sed 's/\/dev\///')
|
||||
[[ ! ${swap_device} =~ ^zram ]] && echo -e "\n### No more available zram devices (${swap_device})\n" >>${Log} && exit 1;
|
||||
[[ ! ${swap_device} =~ ^zram ]] && printf "\n### No more available zram devices (%s)\n" "${swap_device}" >> ${Log} && exit 1;
|
||||
if [ -f /sys/block/${swap_device}/comp_algorithm ]; then
|
||||
# set compression algorithm, if defined as lzo choose lzo-rle if available
|
||||
# https://www.phoronix.com/scan.php?page=news_item&px=ZRAM-Linux-5.1-Better-Perform
|
||||
@@ -88,7 +88,7 @@ activate_zram_swap() {
|
||||
# Swapping to HDDs is stupid so switch to settings made for flash memory and zram/zswap
|
||||
echo 0 > /proc/sys/vm/page-cluster
|
||||
|
||||
echo -e "\n### Activated ${zram_devices} ${swap_algo} zram swap devices with $(( ${mem_per_zram_device} / 1048576 )) MB each\n" >>${Log}
|
||||
printf "\n### Activated %s %s zram swap devices with %dMB each.\n" "${zram_devices}" "${swap_algo}" "$((mem_per_zram_device / 1048576))" >> ${Log}
|
||||
} # activate_zram_swap
|
||||
|
||||
activate_ramlog_partition() {
|
||||
@@ -97,7 +97,7 @@ activate_ramlog_partition() {
|
||||
ENABLED=$(awk -F"=" '/^ENABLED/ {print $2}' /etc/default/orangepi-ramlog)
|
||||
[[ "$ENABLED" != "true" ]] && return
|
||||
log_device=$(zramctl -f |sed 's/\/dev\///')
|
||||
[[ ! ${log_device} =~ ^zram ]] && echo -e "\n### No more available zram devices (${log_device})\n" >>${Log} && exit 1;
|
||||
[[ ! ${log_device} =~ ^zram ]] && printf "\n### No more available zram devices (%s)\n" "${log_device}" >> ${Log} && exit 1;
|
||||
|
||||
# read size also from /etc/default/orangepi-ramlog
|
||||
ramlogsize=$(awk -F"=" '/^SIZE/ {print $2}' /etc/default/orangepi-ramlog)
|
||||
@@ -123,14 +123,14 @@ activate_ramlog_partition() {
|
||||
|
||||
mkfs.ext4 -O ^has_journal -s 1024 -L log2ram /dev/${log_device}
|
||||
algo=$(sed 's/.*\[\([^]]*\)\].*/\1/g' </sys/block/${log_device}/comp_algorithm)
|
||||
echo -e "### Activated Orange Pi ramlog partition with ${algo} compression" >>${Log}
|
||||
printf "### Activated Orange Pi ramlog partition with %s compression\n" "${algo}" >> ${Log}
|
||||
} # activate_ramlog_partition
|
||||
|
||||
activate_compressed_tmp() {
|
||||
# create /tmp not as tmpfs but zram compressed if no fstab entry exists
|
||||
grep -q '^tmpfs /tmp' /etc/mtab && return
|
||||
tmp_device=$(zramctl -f |sed 's/\/dev\///')
|
||||
[[ ! ${tmp_device} =~ ^zram ]] && echo -e "\n### No more available zram devices (${tmp_device})\n" >>${Log} && exit 1;
|
||||
[[ ! ${tmp_device} =~ ^zram ]] && printf "\n### No more available zram devices (%s)\n" "${tmp_device}" >> ${Log} && exit 1;
|
||||
|
||||
if [[ -f /sys/block/${tmp_device}/comp_algorithm ]]; then
|
||||
if [ "X${TMP_ALGORITHM}" = "X" ]; then
|
||||
@@ -139,12 +139,12 @@ activate_compressed_tmp() {
|
||||
echo ${TMP_ALGORITHM} >/sys/block/${tmp_device}/comp_algorithm 2>/dev/null
|
||||
fi
|
||||
fi
|
||||
[[ -z ${TMP_SIZE} ]] && echo -n $(( ${memory_total} / 2 )) > /sys/block/${tmp_device}/disksize || echo -n ${TMP_SIZE} > /sys/block/${tmp_device}/disksize
|
||||
[[ -z ${TMP_SIZE} ]] && echo -n $(( memory_total / 2 )) > /sys/block/${tmp_device}/disksize || echo -n ${TMP_SIZE} > /sys/block/${tmp_device}/disksize
|
||||
mkfs.ext4 -O ^has_journal -s 1024 -L tmp /dev/${tmp_device}
|
||||
mount -o nosuid,discard /dev/${tmp_device} /tmp
|
||||
chmod 1777 /tmp
|
||||
algo=$(sed 's/.*\[\([^]]*\)\].*/\1/g' </sys/block/${tmp_device}/comp_algorithm)
|
||||
echo -e "\n### Activated ${algo} compressed /tmp" >>${Log}
|
||||
printf "\n### Activated %s compressed /tmp\n" "${algo}" >> ${Log}
|
||||
} # activate_compressed_tmp
|
||||
|
||||
case $1 in
|
||||
|
||||
Reference in New Issue
Block a user