====== Information ====== * Raspbian ((https://www.raspbian.org)) ===== Prerequisites ===== * [[Devices:Raspberry Pi]] ====== Download ====== ===== Web ===== * https://www.raspberrypi.org/downloads/raspbian ===== wget ===== ==== Full ==== **** wget 'https://downloads.raspberrypi.org/raspbian_latest' -O ~/'Downloads/raspbian.zip' ==== Lite ==== **** wget 'https://downloads.raspberrypi.org/raspbian_lite_latest' -O ~/'Downloads/raspbian-lite.zip' ====== Expand Filesystem ====== * This **must** be done before anything else sudo raspi-config ====== Software ====== ===== Update ===== **** sudo apt update && sudo apt full-upgrade -y && sudo apt autoremove -y && sudo apt clean && sync ===== General ===== **** sudo apt install htop -y && sync ====== Settings ====== ===== raspi-config ===== **** sudo raspi-config ===== GNU nano ===== * Sets ''nowrap'' and ''nonewlines'' for current user echo -e "set nowrap\nset nonewlines" | tee ~/'.nanorc' > '/dev/null' && cat ~/'.nanorc' ===== Kernel Options ===== * Enables ''kernel.dmesg_restrict'', ''kernel.kptr_restrict'', and ''kernel.sysrq'' * Sets ''vm.swappiness'' to ''10'' and ''vm.vfs_cache_pressure'' to ''50'' echo -e "kernel.dmesg_restrict = 1\nkernel.kptr_restrict = 1\nkernel.sysrq = 1\nvm.swappiness = 10\nvm.vfs_cache_pressure = 50" | sudo tee '/etc/sysctl.d/99-custom.conf' > '/dev/null' && cat '/etc/sysctl.d/99-custom.conf' ===== Static IP ===== * Append to bottom of file and change as-needed sudo -e '/etc/dhcpcd.conf' interface eth0 static ip_address=192.168.1.158/24 static routers=192.168.1.1 static domain_name_servers=1.1.1.1 1.0.0.1 ===== systemd Journal ===== * Max log file sizes of ''50MB'' sudo mkdir -p '/etc/systemd/journald.conf.d' && echo -e "[Journal]\nSystemMaxUse=50M\nRuntimeMaxUse=50M" | sudo tee '/etc/systemd/journald.conf.d/logging.conf' > '/dev/null' && cat '/etc/systemd/journald.conf.d/logging.conf' ===== TRIM ===== ==== Service ==== * Taken from Fedora Workstation with slight modifications sudo -e '/etc/systemd/system/fstrim.service' [Unit] Description=Discard unused blocks [Service] Type=oneshot ExecStartPre=/bin/sync ExecStart=/sbin/fstrim -a ExecStartPost=/bin/sync ==== Timer ==== * Taken from Fedora Workstation sudo -e '/etc/systemd/system/fstrim.timer' && sudo systemctl daemon-reload && sudo systemctl enable 'fstrim.timer' && sudo systemctl start 'fstrim.timer' 'fstrim' && sudo systemctl status 'fstrim' -l [Unit] Description=Discard unused blocks once a week Documentation=man:fstrim [Timer] OnCalendar=weekly AccuracySec=1h Persistent=true [Install] WantedBy=timers.target ===== Secure Shell ===== * https://wiki.archlinux.org/index.php/Secure_Shell#Daemon_management sudo systemctl disable 'ssh' && sudo systemctl enable 'ssh.socket' ===== Environment Variables ===== ==== Timezone ==== * https://blog.packagecloud.io/eng/2017/02/21/set-environment-variable-save-thousands-of-system-calls echo 'export TZ=:/etc/localtime' | sudo tee '/etc/profile.d/tz.sh' > '/dev/null' && cat '/etc/profile.d/tz.sh' | grep -e 'export TZ=:/etc/localtime' ====== Automatic Updates ====== ===== Service ===== sudo -e '/etc/systemd/system/raspbian-up.service' [Service] Type=oneshot ExecStartPre='/usr/bin/apt' clean ExecStart='/usr/bin/apt' update ExecStart='/usr/bin/apt' full-upgrade -y ExecStart='/usr/bin/apt' autoremove -y ExecStartPost='/bin/sync' ExecStartPost='/bin/systemctl' reboot ===== Timer ===== sudo -e '/etc/systemd/system/raspbian-up.timer' && sudo systemctl daemon-reload && sudo systemctl enable 'raspbian-up.timer' --now [Unit] Description=Software Package Maintenance and Updater After=network-online.target Wants=network-online.target [Timer] OnCalendar=*-*-* 05:40:00 Persistent=true [Install] WantedBy=timers.target https://dakboard.com/app/screenPredefined?p=c14c5944d8ed6a1433ae43c9e96b07d5