raspi: change hostname

do the following:

  1. sudo vim /etc/hosts
    1. change last line: XYZ
    2. where XYZ should be the new name you want
  2. sudo vim /etc/hostname
    1. replace the name in this file with the new name
  3. sudo /etc/init.d/hostname.sh
  4. sudo reboot

src: howtogeek.com


raspi: mount usb drives on bootup

to auto mount usb drives on bootup one can simply add some lines to the /etc/fstab file:

UUID=e0a4c8da-67d1-423d-939c-4dc8249079f0 /mnt/small btrfs rw,defaults,nofail 0 0

you need to change the following:

  • the UUID you can find out through: ls -l /dev/disk/by-uuid/
  • change the mount point
  • change the file system
  • pay attention: the nofail option will mount the drive only if it is plugged in

raspi: log network traffic (vnstat)

to monitor the network traffic one can use the tool vnstat

  1. install vnstat
  2. setup database for interface: vnstat -u -i eth0
  3. start/enable service
  4. usage: update database: vnstat -u
  5. usage: query database: vnstat -q

troubleshooting: when systemctl status shows that database couldnt be created, just do this:

sudo chown -R vnstat:vnstat /var/lib/vnstat

source: wiki.archlinux.org

raspi: automatically spin external hdd down

the raspberry pi cannot spin external hard drives down. the program hdparm worked perfectly for me.

i followed this guide (htpcguides.com). just some slight little twitch i found on some other website: the device path in the /etc/hdparm.conf file should rather be the one from /dev/disk/by-uuid/… as the raspi might mount the external drive to different /dev/sdX paths. furthermore, the drive shouldnt be spun down more than need be. dont choose any spindown times lower than 15min.

$ cat /etc/hdparm.conf
/dev/disk/by-uuid/ffd9b0a1-931f-4795-85ba-28c58719a938 {
	spindown_time = 180
	write_cache = on

Note: The spindown_time value is multiplied by 5 and you have the total time in seconds. So a value of 120 yields 10 minutes (120*5=600).

the power managment (should the drive even be spun down) is set via the “advanced power managment” (-B) flag.

From ArchWiki: Set the Advanced Power Management feature. Possible values are between 1 and 255, low values mean more aggressive power management and higher values mean better performance. Values from 1 to 127 permit spin-down, whereas values from 128 to 254 do not. A value of 255 completely disables the feature.

for example: $ sudo hdparm -B 127 /dev/sda

raspi: install torrent server

the raspberry pi is a perfect device for a 24/7 torrent server. one can install the torrent server: deluge.

i followed this guide (howtogeek.com) to install the deluge server, accessible via deluge-console and deluge thin-client (remote).

in short:

sudo apt install deluged deluge-console
sudo pkill deluged
nano ~/.config/deluge/auth
deluge-console: {
config -s allow_remote True
config allow_remote
exit }
sudo pkill deluged

Start deluge daemon at bootup (follow this guide: link):

  1. remove script from /etc/init.d/deluge…
  2. create systemctl unit
  3. enable unit file

raspi: time via ntp

the ntpserver is just a waist of memory for a raspi and its enough to synchro the time every couple hours.

follow this:

  1. right time zone:
    $ sudo dpkg-reconfigure tzdata
  2. deinstall ntp server:
    $ sudo apt-get purge ntp
  3. install ntpdate:
    $ sudo apt install ntpdate
  4. add cron entry:
    $ sudo crontab -e
    @reboot ntpdate -s 0.de.pool.ntp.org
    0 */6 * * * ntpdate -s 0.de.pool.ntp.org

source: from german pageĀ aufschnur.de