Skip to content

Instantly share code, notes, and snippets.

@rockinglama
Last active October 22, 2023 13:08
Show Gist options
  • Save rockinglama/50d35917a5d6aa4f2c0cc25fb12d7f71 to your computer and use it in GitHub Desktop.
Save rockinglama/50d35917a5d6aa4f2c0cc25fb12d7f71 to your computer and use it in GitHub Desktop.
Homeserver

Homeserver 👷 work in progress 🚧

Hardware

Mainboard: ASUS ROG Strix H470-I (mITX) // User Manual (DE)
CPU: Intel Core i3-10100T
CPU FAN: BE QUIET DARK ROCK SLIM
RAM: Crucial DIMM 16 GB DDR4-3200 (CT16G4DFRA32A)
Power Supply: Corsair CX450M
Case: Thermaltake Core V1
Disks:

  • 2x shucking WD My Book 12 TB (WD120EDAZ)
  • 2x Samsung 840, 840 Pro SSDs

Software

  • Proxmox/Debian

    • Home Assistant
    • Nextcloud
    • Xpenology
    • tvheadend
    • unifi controller
    • audioserver (snapclient)
  • Docker

    • Portainer
    • Snapserver (custom image)
    • oscam

Proxmox

Network card driver

Install Realtek RTL8111H network card driver

sed -i '/^deb.*debian*$/ ! s/$/ non-free/' /etc/apt/sources.list
apt -y install pve-headers
apt -y install r8168-dkms

swapiness

Set swapiness level to minimum, on the fly:

echo 1 > /proc/sys/vm/swappiness

and permanently:

echo "vm.swappiness = 1" >> /etc/sysctl.conf

MD Raid

https://www.dlford.io/install-proxmox-on-raid-array/

Source list

Edit source.list to user pve-no-subscription

sed -i 's/^deb/#deb/g' /etc/apt/sources.list.d/pve-enterprise.list
echo "deb http://download.proxmox.com/debian buster pve-no-subscription" > /etc/apt/sources.list.d/pve-no-subscription.list
apt-get update && apt-get dist-upgrade -y

CPU Powersave

#!/bin/bash

if [[ $1 == "--check" || $1 == "-c" ]]
then
	cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
elif [[ $1 == "--standby" || $1 == "-s" || -z $1 ]]
then
	echo "powersave" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
	cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
fi
exit 0


#echo "performance" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
echo "powersave" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor

cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor

HDD Standby

Ignore RAID

Ignore HDD Raid /etc/mdadm/mdadm.conf

add lines

AUTO -all
ARRAY <ignore>  metadata=1.2 UUID=ef3473b5:e3a39e90:2f8796d1:cf0d35cd name=DS:2

manually spin down HDD
Don't use -Y or smartd will wake disks every time it checks for its power state

hdparm -y /dev/disk/by-id/ata-WDC_WD120EDAZ-xyz

To allow HDDs to spin down edit global_filter in /etc/lvm/lvm.conf

, "r|/dev/sdb|", "r|/dev/sdc|"

full line:

global_filter = [ "r|/dev/zd.*|", "r|/dev/mapper/pve-.*|" "r|/dev/mapper/.*-(vm|base)--[0-9]+--disk--[0-9]+|", "r|/dev/sdb.*|", "r|/dev/sdc.*|" ]

Edit /etc/hdparm.conf and append config for each hdd, example:

/dev/disk/by-id/ata-WDC_WD120EDAZ-xyz {
        apm = 127
        spindown_time = 240
}

apm 1-128 support spindown

Value Time
1-240 value * 5sec
241 30min
242 1hr

https://www.freeminded.org/index.php/2012/04/hdparm-power-down-drives-when-not-in-use/

proxmox hook script

hookscript put's hdds in standby after vm shutdown

proxmox config: hookscript: local:snippets/hdd_sleep.sh

/var/lib/vz/snippets/hdd_sleep.sh

#!/bin/bash

hdd_sleep() {
	echo "post-stop"
	sleep 30
	hdparm -y /dev/disk/by-id/ata-WDC_WD120EDAZ-11F3RA0_5PJB1MXD > /dev/null 2>&1
	hdparm -y /dev/disk/by-id/ata-WDC_WD120EDAZ-11F3RA0_5PJLXLBF > /dev/null 2>&1
}

hook() {
  local phase="$1"

  case "$phase" in
    post-stop)
	hdd_sleep
	exit 0
	;;
    *)
      exit 0
      ;;
  esac
}

hook "$@"

PCI passtrough

nano /etc/default/grub GRUB_CMDLINE_LINUX_DEFAULT="quiet intel_iommu=on" update-grub

nano /etc/kernel/cmdline quiet intel_iommu=on pve-efiboot-tool refresh

reboot

Source: https://pve.proxmox.com/wiki/Pci_passthrough

Proxmox disk passtrough

https://dannyda.com/2020/08/26/how-to-passthrough-hdd-ssd-physical-disks-to-vm-on-proxmox-vepve/

Misc

Remove subscription message:

sed -Ezi.bak "s/(Ext.Msg.show\(\{\s+title: gettext\('No valid sub)/void\(\{ \/\/\1/g" /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js && systemctl restart pveproxy.service

Source: https://johnscs.com/remove-proxmox51-subscription-notice/

Docker

apt-get update && apt-get dist-upgrade -y
apt-get -y install apt-transport-https ca-certificates curl gnupg-agent software-properties-common

Add Docker’s official GPG key:

curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"
apt-get update && apt-get -y install docker-ce docker-ce-cli containerd.io
docker run -d -p 9000:9000 --restart unless-stopped -v /root/portainer/data:/data -v /var/run/docker.sock:/var/run/docker.sock portainer/portainer

OSCAM

docker run -d --name=oscam -e PUID=1000 -e PGID=1000 -e TZ=Europe/Berlin -p 8888:8888 -p 8889:8889 -v /opt/oscam:/config --restart unless-stopped ghcr.io/linuxserver/oscam

Snapserver

Nextcloud

docker run -d --restart unless-stopped -p 2080:80 nextcloud
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment