Skip to content

Running Lion

  • Change default login
  • Enable PiFan
  • Set disks to spindown after 20 mins idle with hd-idle

GPIO

Physical Pin GPIO Func Connected Device
4 5V Fan 5V
6 GND Fan GND
12 PWM0 PWM Fan Control
3 GPIO Input Door Sensor In
9 GND Door Sensor GND
5 GPIO Output Buzzer Out
14 GND Buzzer Ground

Test Script

Not working

Buzzes properly but doesn't print when door opens and closes

from gpiozero import OutputDevice, Button
from time import sleep
from multiprocessing import Process
from signal import pause
try:
    door = Button("BOARD3")
    buzz = OutputDevice("BOARD5")

    def buzz_loop():
        while True:
            buzz.on()
            sleep(1)
            buzz.off()
            sleep(1)

    def door_open():
        print("Door open")

    def door_close():
        print("Door close")

    def contact_state_loop():
        door.when_pressed = door_open
        door.when_released = door_close
        pause()
    Process(target=buzz_loop).start()
    Process(target=contact_state_loop).start()
finally:
    buzz.off()

HomeAssistant

Runs as a docker-compose instance with home at /home/britton-charlie/homeassistant. Remote access configured through ha.chza.me, which is a reverse proxy on the VPN server connecting to the running-lion VPN IP. Currently configured as a VPN on the 10.0.0.0/8 range.

Plex

This server hosts Plex, also within a Docker container. This is detailed in my blog post.

Plex can run very slowly as the storage is via NFS and the SQLite database doesn't like that very much. Need to see if there's a way to offload the database to local storage, e.g., on a hard drive or SD card but then it won't be redundant.

SMB Tuning

Write of an 8GB file from a MacOS device was very slow. Tried with rsync and copied okay. Might be to do with a cache of some credential somewhere but need to possibly look at creating a bootable MacOS to verify this on my own device.

Performance Tests

Write performance from SSH session directly:

britton-charlie@running-lion:/mnt/rl-hdd0/britton-charlie $ fio   --name=seqwrite --rw=write --bs=4k --size=256m --runtime=60 --time_based
seqwrite: (g=0): rw=write, bs=(R) 4096B-4096B, (W) 4096B-4096B, (T) 4096B-4096B, ioengine=psync, iodepth=1
fio-3.33
Starting 1 process
seqwrite: Laying out IO file (1 file / 256MiB)
Jobs: 1 (f=1): [W(1)][100.0%][eta 00m:00s]
seqwrite: (groupid=0, jobs=1): err= 0: pid=25576: Mon Jul 15 19:45:27 2024
  write: IOPS=103k, BW=401MiB/s (420MB/s)(24.2GiB/61900msec); 0 zone resets
    clat (usec): min=2, max=6360.9k, avg= 8.17, stdev=3632.77
     lat (usec): min=2, max=6360.9k, avg= 8.35, stdev=3632.77
    clat percentiles (usec):
     |  1.00th=[    4],  5.00th=[    5], 10.00th=[    5], 20.00th=[    5],
     | 30.00th=[    5], 40.00th=[    5], 50.00th=[    5], 60.00th=[    5],
     | 70.00th=[    5], 80.00th=[    5], 90.00th=[    6], 95.00th=[    6],
     | 99.00th=[    8], 99.50th=[   10], 99.90th=[   37], 99.95th=[   57],
     | 99.99th=[  359]
   bw (  KiB/s): min=38484, max=672096, per=100.00%, avg=563978.23, stdev=136832.57, samples=90
   iops        : min= 9621, max=168024, avg=140994.53, stdev=34208.14, samples=90
  lat (usec)   : 4=4.66%, 10=94.89%, 20=0.16%, 50=0.24%, 100=0.04%
  lat (usec)   : 250=0.01%, 500=0.01%, 750=0.01%, 1000=0.01%
  lat (msec)   : 2=0.01%, 4=0.01%, 10=0.01%, 20=0.01%, >=2000=0.01%
  cpu          : usr=17.00%, sys=47.87%, ctx=3287, majf=0, minf=44
  IO depths    : 1=100.0%, 2=0.0%, 4=0.0%, 8=0.0%, 16=0.0%, 32=0.0%, >=64=0.0%
     submit    : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
     complete  : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
     issued rwts: total=0,6351652,0,0 short=0,0,0,0 dropped=0,0,0,0
     latency   : target=0, window=0, percentile=100.00%, depth=1

Run status group 0 (all jobs):
  WRITE: bw=401MiB/s (420MB/s), 401MiB/s-401MiB/s (420MB/s-420MB/s), io=24.2GiB (26.0GB), run=61900-61900msec

Disk stats (read/write):
    dm-2: ios=1/1846, merge=0/0, ticks=24/12928828, in_queue=12928852, util=99.01%, aggrios=1/3537, aggrmerge=0/19, aggrticks=1/3461990, aggrin_queue=3472294, aggrutil=98.50%
  sdb: ios=1/3537, merge=0/19, ticks=1/3461990, in_queue=3472294, util=98.50%

Write performance from mounted SMB share ethernet Linux to Linux box through a single switch:

[charlie@chza ~mn/running-lion/charlie]$ fio   --name=seqwrite --rw=write --bs=4k --size=256m --runtime=60 --time_based
seqwrite: (g=0): rw=write, bs=(R) 4096B-4096B, (W) 4096B-4096B, (T) 4096B-4096B, ioengine=psync, iodepth=1
fio-3.37
Starting 1 process
Jobs: 1 (f=1): [W(1)][100.0%][eta 00m:00s]
seqwrite: (groupid=0, jobs=1): err= 0: pid=206000: Mon Jul 15 19:47:24 2024
  write: IOPS=31.7k, BW=124MiB/s (130MB/s)(7680MiB/61985msec); 0 zone resets
    clat (nsec): min=1760, max=380399, avg=2909.10, stdev=2027.11
     lat (nsec): min=1810, max=380439, avg=2956.38, stdev=2028.95
    clat percentiles (nsec):
     |  1.00th=[  1864],  5.00th=[  1912], 10.00th=[  1944], 20.00th=[  2256],
     | 30.00th=[  2832], 40.00th=[  2864], 50.00th=[  2896], 60.00th=[  2928],
     | 70.00th=[  2960], 80.00th=[  3024], 90.00th=[  3280], 95.00th=[  3824],
     | 99.00th=[  6624], 99.50th=[  6816], 99.90th=[  9920], 99.95th=[ 13760],
     | 99.99th=[109056]
   bw (  KiB/s): min=20664, max=1744320, per=100.00%, avg=403298.46, stdev=347943.09, samples=39
   iops        : min= 5166, max=436078, avg=100824.62, stdev=86985.76, samples=39
  lat (usec)   : 2=14.23%, 4=80.97%, 10=4.70%, 20=0.06%, 50=0.02%
  lat (usec)   : 100=0.01%, 250=0.01%, 500=0.01%
  cpu          : usr=1.46%, sys=14.63%, ctx=7103, majf=15, minf=7
  IO depths    : 1=100.0%, 2=0.0%, 4=0.0%, 8=0.0%, 16=0.0%, 32=0.0%, >=64=0.0%
     submit    : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
     complete  : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
     issued rwts: total=0,1966081,0,0 short=0,0,0,0 dropped=0,0,0,0
     latency   : target=0, window=0, percentile=100.00%, depth=1

Run status group 0 (all jobs):
  WRITE: bw=124MiB/s (130MB/s), 124MiB/s-124MiB/s (130MB/s-130MB/s), io=7680MiB (8053MB), run=61985-61985msec
This shows that the network link is the bottleneck as max throughput limited by the link speed.

Now a job from a wireless client, and iperf results running Linux

(base) [charlie@charlie-laptop /mnt/running-lion/charlie]$ fio --name seqwrite --rw=write --bs=4k --size=256m --runtime=60 --time_based
seqwrite: (g=0): rw=write, bs=(R) 4096B-4096B, (W) 4096B-4096B, (T) 4096B-4096B, ioengine=psync, iodepth=1
fio-3.35
Starting 1 process
Jobs: 1 (f=1): [f(1)][100.0%][eta 00m:00s]
seqwrite: (groupid=0, jobs=1): err= 0: pid=21699: Mon Jul 15 19:55:08 2024
  write: IOPS=1926, BW=7705KiB/s (7890kB/s)(451MiB/60001msec); 0 zone resets
    clat (usec): min=2, max=3271.8k, avg=127.41, stdev=9873.14
     lat (usec): min=2, max=3271.8k, avg=127.51, stdev=9873.14
    clat percentiles (usec):
     |  1.00th=[     3],  5.00th=[     3], 10.00th=[     3], 20.00th=[     3],
     | 30.00th=[     3], 40.00th=[     3], 50.00th=[     4], 60.00th=[     5],
     | 70.00th=[     6], 80.00th=[     9], 90.00th=[    10], 95.00th=[    14],
     | 99.00th=[    32], 99.50th=[    66], 99.90th=[ 23462], 99.95th=[ 31589],
     | 99.99th=[111674]
   bw (  KiB/s): min= 2144, max=330632, per=100.00%, avg=37337.67, stdev=87504.38, samples=24
   iops        : min=  536, max=82658, avg=9334.42, stdev=21876.10, samples=24
  lat (usec)   : 4=54.82%, 10=36.93%, 20=6.58%, 50=0.98%, 100=0.23%
  lat (usec)   : 250=0.03%, 500=0.01%, 750=0.01%, 1000=0.01%
  lat (msec)   : 2=0.01%, 10=0.01%, 20=0.29%, 50=0.09%, 100=0.01%
  lat (msec)   : 250=0.01%, >=2000=0.01%
  cpu          : usr=0.25%, sys=1.33%, ctx=870, majf=1, minf=13
  IO depths    : 1=100.0%, 2=0.0%, 4=0.0%, 8=0.0%, 16=0.0%, 32=0.0%, >=64=0.0%
     submit    : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
     complete  : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
     issued rwts: total=0,115574,0,0 short=0,0,0,0 dropped=0,0,0,0
     latency   : target=0, window=0, percentile=100.00%, depth=1

Affected MacOS 7.3MB/s average entire transfer. Bottleneck established as the 2.4GHz wireless network.

Comments