Project

General

Profile

Actions

Raspi

als TimeMachine

Basis der Anleitung:

Apple unterstützt nur noch SMB, AFS ist veraltet.
Passend dazu ist netatalk in Debian bookworm nicht enthalten.

pi hat selbstvertändlich ein sicheres Passwort bekommen.
Der Raspi heißt PiMachine.local
Für backup habe ich einen User tm eingerichtet.

User und Mounts

  • bookworm-lite mit ssh, ssh-key, hostname (in Raspberry Pi Imager konfiguriert)
  • sudo update
  • sudo full-upgrade

Installation der Programme hfsutils hfsprogs

sudo apt install hfsutils hfsprogs

Konfiguration:

ls -lha /dev/disk/by-uuid
mkdir /media/tm

Benutzer, mountpoint und Rechte

adduser tm
mkdir /media/tm
chown -R tm: /media/tm

Für Samba verwenden wir ext4.

/etc/fstab:

UUID=4080b302-c0d3-3f1c-8b92-2323aa7e05f2 /media/tm hfsplus force,rw,user,noauto 0 0
LABEL=backups /media/tm2 ext4 noexec,nodev,noatime,nodiratime 0 0

Samba aufsetzen als TM-Target

sudo apt install samba avahi-daemon -y
sudo smbpasswd -a tm

Passwort ist in 1Password

in /etc/samba/smb.conf:

[backups]
   path = /media/tm2/backups 
   read only = no
   valid users = tm
   vfs objects = catia fruit streams_xattr
   fruit:aapl = yes
   fruit:time machine = yes

avahi konfigurieren:
in /etc/avahi/services/samba.service:

<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
  <name replace-wildcards="yes">%h</name>
  <service>
    <type>_smb._tcp</type>
    <port>445</port>
  </service>
  <service>
    <type>_device-info._tcp</type>
    <port>9</port>
    <txt-record>model=Xserve1,1</txt-record>
  </service>
  <service>
    <type>_adisk._tcp</type>
    <port>9</port>
    <txt-record>dk0=adVN=backups,adVF=0x82</txt-record>
    <txt-record>sys=adVF=0x100</txt-record>
  </service>
</service-group>

hd-idle

hd-idle ist inzwischen in debian Paket.

apt install hd-idle

Die HD ist sda demnach in /etc/default/hd-idle:

HD_IDLE_OPTS="-i 0 -a sda -i 180 -l /var/log/hd-idle.log" 

deprecated

Basis der Anleitung sind

pi hat selbstvertändlich ein sicheres Passwort bekommen.
Der Raspi heißt PiMachine.local

Time Machine aufsetzen

  • buster-lite auf SD-Card brennen
  • ssh (leere Datei) in boot anlegen
  • booten
  • sudo raspi-config (dort Password und Hostnoame setzten)
  • sudo update
  • sudo upgrade
Installation der Programme hfsutils hfsprogs netatalk
  • sudo apt install hfsutils hfsprogs netatalk
Konfiguration:
  • ls -lha /dev/disk/by-uuid
  • mkdir /media/tm

/etc/fstab:

UUID=b05d568d-89a3-33c3-a200-66f51cd59e3c /media/tm hfsplus force,rw,user,noauto 0 0

/etc/nsswitch.conf

# /etc/nsswitch.conf
#
# Example configuration of GNU Name Service Switch functionality.
# If you have the `glibc-doc-reference' and `info' packages installed, try:
# `info libc "Name Service Switch"' for information about this file.

passwd:         files
group:          files
shadow:         files
gshadow:        files

hosts:          files mdns4_minimal [NOTFOUND=return] dns mdns4 mdns
networks:       files

protocols:      db files
services:       db files
ethers:         db files
rpc:            db files

netgroup:       nis

/etc/netatalk/afp.conf

;
; Netatalk 3.x configuration file
;

[Global]
; Global server settings
  mimic model = TimeCapsule6,106

; [Homes]
; basedir regex = /xxxx

; [My AFP Volume]
; path = /path/to/volume

[Time Machine]
  path = /media/tm
  time machine = yes

Passwort

Der user pi braucht ein Passwort, damit sich die Macs anmelden können

sudo passwd pi

CRON

Die Dienste und die USB-Platte werden nach dem Booten verzögert gestartet, da sonst die USB-Platte manchmal R/O ist:

sudo crontab -e

und in der root-Crontab:
@reboot sleep 30 && mount /media/tm && sleep 30 && umount /media/tm && sleep 30 && mount /media/tm && sleep 30 && service avahi-daemon start && service netatalk start

Spin Down Disk

hdparm kann zwar die Platte ausschalten, aber keine Advanced Power Level setzen.
Daher kommt hd-idle zum Einsatz.
Siehe https://www.htpcguides.com/spin-down-and-manage-hard-drive-power-on-raspberry-pi/

/etc/default/hd-idle

# defaults file for hd-idle

# start hd-idle automatically?
START_HD_IDLE=true

# hd-idle command line options
# Options are:
#  -a <name>               Set device name of disks for subsequent idle-time
#                          parameters (-i). This parameter is optional in the
#                          sense that there's a default entry for all disks
#                          which are not named otherwise by using this
#                          parameter. This can also be a symlink
#                          (e.g. /dev/disk/by-uuid/...)
#  -i <idle_time>          Idle time in seconds.
#  -l <logfile>            Name of logfile (written only after a disk has spun
#                          up). Please note that this option might cause the
#                          disk which holds the logfile to spin up just because
#                          another disk had some activity. This option should
#                          not be used on systems with more than one disk
#                          except for tuning purposes. On single-disk systems,
#                          this option should not cause any additional spinups.
#
# Options not exactly useful here:
#  -t <disk>               Spin-down the specfified disk immediately and exit.
#  -d                      Debug mode. This will prevent hd-idle from
#                          becoming a daemon and print debugging info to
#                          stdout/stderr
#  -h                      Print usage information.
HD_IDLE_OPTS="-i 0 -a sda -i 180 -l /var/log/hd-idle.log" 

Updated by Martin Meier 9 months ago · 9 revisions