Skip to content

Instantly share code, notes, and snippets.

@Thermionix
Last active April 6, 2025 06:37
Show Gist options
  • Save Thermionix/8588489 to your computer and use it in GitHub Desktop.
Save Thermionix/8588489 to your computer and use it in GitHub Desktop.
opensuse 13.1 NAS server
# install opensuse, 'server minimal selection', enable ssh
# disable firewall (and on boot) under security in yast
zypper install btrfsprogs nano smartmontools msmtp-mta mailx samba tmux
######## network interface bonding ##########
# yast > network devices > network settings
# Overview > Add > Device type = bond
# Next, set ip etc
# add spare adapter
# bond driver options = mode=balance-rr miimon=100
# save settings
# ssh in on new ip
# delete original adatper, then add adapter as slave to bond
######## reduce writes to DOM disk ##########
# noatime appended to DOM mounts in /etc/fstab
awk -i inplace '!/^#/ && ($2 != "swap") { if(!match($4, /noatime/)) $4=$4",noatime" } 1' /etc/fstab
nano /etc/fstab
## setup /tmp on TMPFS
mkdir -p /etc/systemd/system/local-fs.target.wants
cat <<-'EOF' | tee /etc/systemd/system/tmp.mount
[Unit]
Description=Temporary Directory
Documentation=man:hier(7)
Before=local-fs.target
[Mount]
What=tmpfs
Where=/tmp
Type=tmpfs
Options=mode=1777,strictatime
EOF
ln -s /etc/systemd/system/tmp.mount /etc/systemd/system/local-fs.target.wants/
cat <<-'EOF' | tee /etc/udev/rules.d/60-sched.rules
#set noop scheduler for non-rotating disks
ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/rotational}=="0", ATTR{queue/scheduler}="deadline"
# set cfq scheduler for rotating disks
ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/rotational}=="1", ATTR{queue/scheduler}="cfq"
EOF
sed -i -e "s/#Storage=auto/Storage=volatile/" /etc/systemd/journald.conf
cat <<-'EOF' | tee /etc/sysctl.d/99-sysctl.conf
vm.swappiness=1
vm.vfs_cache_pressure=50
EOF
######## setup services ##########
cat <<-'EOF' | tee /etc/msmtprc
account default
host mail.example.com
tls off
from [email protected]
aliases /etc/aliases
syslog LOG_MAIL
EOF
cat <<-'EOF' | tee /etc/aliases
root: [email protected]
EOF
cat <<-'EOF' | tee /etc/smartd.conf
DEVICESCAN -a -m root
EOF
mkfs.btrfs -f -L pool -m raid10 -d raid10 /dev/sd[b-i]
mkdir -p /pool
echo "/dev/disk/by-label/pool /pool btrfs defaults 0 2" >> /etc/fstab
systemctl enable smartd.service
systemctl start smartd.service
for x in {b..i}; do smartctl -t long /dev/sd$x; done
btrfs filesystem show /dev/disk/by-label/pool
cat <<-'EOF' | tee /etc/cron.weekly/btrfs-scrub
#!/bin/sh
awk '/btrfs/ {print $2}' /proc/mounts | while read dn; do
echo $dn
btrfs scrub start -B $dn
done
EOF
systemctl start smb
systemctl start nmb
systemctl start winbind
systemctl enable smb
systemctl enable nmb
systemctl enable winbind
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment