Free purgeable space on MacOS Mojave

I’ve recently deleted a large preview database file for Lightroom and was happy about the 80GB won free space. However, the MacOS disk utility as well as the terminal command “df -h” did not show the free space. I’ve also checked the trash and cleared it, but there was no change in the available disk space.

I’ve taken a closer look at the free space column in the disk utility and found a new variable behind the available disk space: GB purgeable.

However, there is nowhere an option to purge this space. Upon further searching I’ve found this tip on stack overflow:

It looks like TimeMachine takes up a lot of free space in APFS snapshots which needs manual cleaning using this command:

tmutil thinlocalsnapshots / $((100 * 1024 * 1204 * 1024)) 4

This command tries to free 100GB space from the local snapshots. It’s using the highest priority (4) to speed up the cleaning.

After I’ve executed that command, the available free disk space was shown correctly again.

Disable macOS Catalina update notification in Mojave

macOS Catalina was released and is ready to install. If you’re using the previous macOS version called Mojave, you’ll get a notification badge on the system settings.

This little red notification badge is really annoying.

The following two commands were taken from the Apple support forum:

sudo softwareupdate --ignore "macOS Catalina"

If you want to install Catalina via the software update, you can reset the ignored updates with this command:

sudo softwareupdate --reset-ignored

This will hide successfully the Catalina update from the list of available updates in Software Update. However, it won’t remove the notification badge.

But fortunately you can even disable the badge by using these commands:

defaults write com.apple.systempreferences AttentionPrefBundleIDs 0
killall Dock

This will hide the badge until the next time you’ll scan for available software updates.

DIY HomeKit with Raspberry Pi and Xiaomi Robot Vacuum

Inspired by tweets of Steven Troughten-Smith, people started to experiment with Raspberry Pi’s as DIY HomeBridge devices. One of them is Wojtek Pietrusiewicz. He wrote a nice article which I used as base for this post.

Introduction

I own a Xiaomi Robot Vacuum. This robot can be controlled by the Xiaomi app, however, I don’t like it very much. The idea is to control this robot over HomeKit. To use HomeKit, I use an old Raspberry Pi 1B. The software will be HomeBridge.

Setting up the Pi

Installation and Configuration of Raspbian

Use Etcher to write the image to the SD card. Remount that SD card and add a file called “ssh” in the root of the mounted partition. This will enable SSH from the beginning so that you can login directly to the Pi. I don’t want to attach a screen or keyboard to that machine so it will only be reachable over the network. Now boot your Pi from this SD card.

Identify the Pi’s IP (e.g. by looking at the network overview in your router). Now connect to that IP with user “pi”. The default password is “raspberry”. Please change the password now with passwd and assign a new user password.

Update everything with apt:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
sudo apt-get clean
sudo reboot

 

Install nodejs 8.9.4

According to Wojtek only this version works currently with HomeBridge. I did not test any other version so I’m just describing what I did on my machine:

  1. Download nodejs for the PI into your users homefolder, e.g. with wget https://nodejs.org/dist/v8.9.4/node-v8.9.4-linux-armv6l.tar.xz
  2. Unpack the file with tar -xvf node-v8.9.4-linux-armv6l.tar.xz
  3. cd node-v8.9.4-linux-armv61
  4. sudo cp -R * /usr/local/
  5. add export PATH=$PATH:/usr/local/bin to e.g. ~/.bashrc
  6. node should be now available

Install HomeBridge

  1. Install the necessary libraries: sudo apt-get install libavahi-compat-libdnssd-dev
  2. Install HomeBridge with npm: sudo npm install -g --unsafe-perm homebridge
  3. open /etc/default/homebridge and safe it with this content:
    # Defaults / Configuration options for homebridge
    # The following settings tells homebridge where to find the config.json file and where to persist the data (i.e. pairing and others)
    HOMEBRIDGE_OPTS=-U /var/homebridge
     
    # If you uncomment the following line, homebridge will log more 
    # You can display this via systemd's journalctl: journalctl -f -u homebridge
    # DEBUG=*
  4. open /etc/systemd/system/homebridge.service and safe it with this content:
    [Unit]
    Description=Node.js HomeKit Server 
    After=syslog.target network-online.target
     
    [Service]
    Type=simple
    User=homebridge
    EnvironmentFile=/etc/default/homebridge
    ExecStart=/usr/local/bin/homebridge $HOMEBRIDGE_OPTS
    Restart=on-failure
    RestartSec=10
    KillMode=process
     
    [Install]
    WantedBy=multi-user.target
  5. sudo useradd --system homebridge
    sudo mkdir /var/homebridge
    cp /usr/local/lib/node_modules/homebridge/config-sample.json ~/.homebridge/config.json

Setting up HomeBridge with Xiaomi Robot Vacuum

  1. sudo npm install -g homebridge-xiaomi-mi-robot-vacuum miio
  2. open ~/.homebridge/config.json and safe it with this content:
    {
     "bridge": {
     "name": "Homebridge",
     "username": "XX:XX:XX:XX:XX:XX",
     "port": 51826,
     "pin": "031-45-154"
     },
     
     "description": "HomePi Homebridge.",
     
     "accessories": [
     {
     "accessory": "MiRobotVacuum",
     "name": "Vacuum Cleaner",
     "ip": "IP_ADDRESS_OF_THE_ROBOT",
     "token": "TOKEN_RECOVERED_FROM_APP",
     "pause": true
     }
     ]
    }

    Generate a new MAC address separated by : using this website. You’ll need the IP address of your Xiaomi robot as well as the token. There are several ways to get the token. I’ve extracted mine from the iOS backup. Instead of uploading the token I’ve used this command on the token taken from the sqlite database:

    echo '0: <YOUR HEXADECIMAL STRING>' | xxd -r -p | openssl enc -d -aes-128-ecb -nopad -nosalt -K 00000000000000000000000000000000
    
  3. Check if everything is working by starting homebridge for the first time. It should show a QR code. If it does, cancel the process with ctrl+c

Automate HomeBridge startup

cp ~/.homebridge/config.json /var/homebridge
sudo cp -r ~/.homebridge/persist /var/homebridge
sudo chmod -R 0777 /var/homebridge
sudo systemctl daemon-reload
sudo systemctl enable homebridge
sudo systemctl start homebridge
sudo systemctl status homebridge

Adding the HomeBridge to iOS devices

  1. Install the Home app, if you’ve removed it from your device. You can reinstall it from the App store.
  2. Open the Home app and add a new device
  3. If you’ve give the app access to your camera, you can scan the QR code you’ve seen earlier. However, HomeBridge is now running as a daemon in the background so you won’t see that QR code. You can add the bridge manually by using the PIN you’ve set in the config.

Slow SMB transfers in Mac OS 10.12.2

I’m using a 802.11ac WLAN to connect to my Synology NAS. With the last Mac OS 10.12.2 update the network performance was catastrophic when I tried to access the NAS via SMB. At first I thought this might have been caused by the WLAN connection but even with a Gigabit LAN connection my transfer rates were around 3-5MB/s.

After a short search online, I’ve a few hits describing the actual problem:

Apple uses their own version of SMB and enabled client signing to mitigate against Man in the middel attacks. Therefore all connections underly this signing process and are way slower.

Therefore I’ve disabled client-signing on my mac using this command:

printf "[default]\nsigning_required=no\n" | sudo tee /etc/nsmb.conf >/dev/null

This will write this content

[default]
signing_required=no

 

to the file /etc/nsmb.conf. After you’ve set this value you need to unmount all samba shares. If you’ll reconnect now, you’ll witness a much better performance, starting with faster loading of network shares.

You can revert this change with

sudo rm /etc/nsmb.conf