Fix broken automount mounts on macOS Catalina

I’ve moved my iTunes music library content to my NAS. I’m using automount to keep iTunes happy without losing the connection to the files. After upgrading to macOS Catalina, automount did not work as it used to.

Reason is the changed structure in the APFS container. If you have a look at the disk utility, it will show you a system container and a user container. The system contains macOS and is write protected, while the user container contains all your apps, data and so on.

You’ll just have to prepend your existing automount paths with /System/Volumes/Data. Now you’ll just have to run

sudo automount -vc

and the automounts are working again.

I had to change the iTunes settings back to my automount folder, as the upgrade to Catalina reset it to its default location in your users folder.

Fixing Xcode command line tools after upgrade to macOS Catalina 10.15

Today I’ve updated to macOS Catalina 10.15. I’ve tried to setup zsh instead of bash and ran intro troubles with Xcode command line tools.

If I run

xcode-select -p
/Library/Developer/CommandLineTools

I’m seeing my previous installation in /Library/Developer/CommandLineTools. However, if I run

xcode-select --install

I’m seeing the installer which tries to fetch the latest Xcode command line tools. However, it always fails with

Unable to Download App. "Xcode" could not be installed. Please try again later.

I don’t intend to install the large Xcode from the appstore. So I’ve tried to delete the existing installation of the command line tools with

sudo rm -rf /Library/Developer

but the problem is still present.

Many people suggest to go to the developer.apple.com page and to search manually for the Xcode command line tools. I thought this wouldn’t work, because I’m only seeing the Xcode command line tools for Xcode 12.

However, we’re already at Xcode 12.1, so I thought this is the wrong download and is already outdated. But after I’ve installed the tools from this dmg, its working again and

xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates

shows a suitable error message.

So lessons learned: using the latest major version of the command line tools installer seems to be sufficient.

Setup WireGuard VPN on Raspbian

I’m already using OpenVPN but heard only good things about WireGuard VPN. For my current project, I need a VPN connection to my home network. I do not want to mess with my currently working OpenVPN setup, so I tried to setup WireGuard VPN on Raspbian.

Start with updating your installed packages. Its especially important to install the raspberrypi-kernel-headers before the WireGuard installation.:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install raspberrypi-kernel-headers

I’ll use pivpn as setup script. You can install it with curl piping the script to bash like this:

curl -L https://install.pivpn.io | bash

However, if you don’t trust that source and doesn’t want to execute it unseen, you can also check the script content first or download the script separately to your machine first.

I’ve followed now the installation steps which are already pretty good explained by others:

What’s nice about this script is, that it will also detect installations of pi-hole running on the same machine.

I’ve used the script to setup WireGuard (as it also supports OpenVPN). I’ve selected the default port 51820 and created a port forwarding rule in my FritzBox router. After the installation completed, you’re asked to do a reboot.

Now we’ll create a new WireGuard profile using

sudo pivpn add

The script just asks for a profile name and will place the generated profiles in the users home under the config folder.

Setup on the client machine is similar. But instead of using the script for installation, we’ll use the version provided by the Debian repo. I’ve followed these instructions:

sudo apt-get install dirmngr
echo "deb http://deb.debian.org/debian/ unstable main" | sudo tee --append /etc/apt/sources.list
sudo apt-key adv --keyserver   keyserver.ubuntu.com --recv-keys 04EE7237B7D453EC
sudo apt-key adv --keyserver   keyserver.ubuntu.com --recv-keys 648ACFD622F3D138
sudo sh -c 'printf "Package: *\nPin: release a=unstable\nPin-Priority: 90\n" > /etc/apt/preferences.d/limit-unstable'
sudo apt-get update
sudo apt install wireguard

I’ve transferred the created config from the WireGuard host to the WireGuard client and ran

sudo wg-quick up <ProfileName>

And it established really fast a connection. However, my problem was now that the SSH connection broke because all of the traffic to and from the client was going through the WireGuard VPN (like you would have used it for your phone when you’re in an unsecured WiFi and want to redirect all traffic through the VPN).

Luckily I was able to stop the connection by SSHing from the WireGuard VPN to the assigned IP of the WireGuard client and by using

sudo wg-quick down <ProfileName>

The question is now, how can I configure WireGuard Client to just know the route through the VPN to resources in the host network or vice versa how I can configure the WireGuard Host to provide other machines in the network a route to the connected client…

Setup external USB disk as NTFS volume on Raspbian

I intend to use an external 2.5″ USB disk formatted as NTFS volume on my Raspberry Pi. Since its rather larger (5TB) I don’t want to use MBR but GPT instead. Here’s a short list of commands I’ve used to setup the disk.

Start by identifying the connected disk:

> lsblk
NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda           8:0    0  4.6T  0 disk
└─sda1        8:1    0  4.6T  0 part
mmcblk0     179:0    0 14.9G  0 disk
├─mmcblk0p1 179:1    0  1.5G  0 part
├─mmcblk0p2 179:2    0    1K  0 part
├─mmcblk0p5 179:5    0   32M  0 part
├─mmcblk0p6 179:6    0   69M  0 part /boot
├─mmcblk0p7 179:7    0  8.2G  0 part /
├─mmcblk0p8 179:8    0  512M  0 part
└─mmcblk0p9 179:9    0  4.5G  0 part

My disk is sda.

I now usually used fdisk as a partitioning tool. However, there’s a tool I can highly recommend. Its called parted and can be installed using:

sudo apt-get install parted

Since I’ll want to use ntfs as file system, I’ll need to install the ntfs drivers:

sudo apt-get install ntfs-3g

Now create a new GPT partition table:

> sudo parted /dev/sda mklabel gpt
Warning: The existing disk label on /dev/sda will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? yes
Information: You may need to update /etc/fstab.

Now create a new partition with ntfs. I’ll use all of the available space, so its from 0 to 100%:

> sudo parted -a opt /dev/sda mkpart primary ntfs 0% 100%
Information: You may need to update /etc/fstab.

Now format the disk in quick format with ntfs. It will label the partition as “SynoBackups”:

> sudo mkfs.ntfs -L SynoBackups -Q /dev/sda1
Cluster size has been automatically set to 4096 bytes.
Creating NTFS volume structures.
mkntfs completed successfully. Have a nice day.

This label is very helpful in identifying the partition, even when it is connected to a different USB port. Using a device like sda might point to a different drive, so its better to use the label. This is one of the big advantages of using gpt in comparison to mbr.

Let’s see the label in action:

sudo lsblk --fs
NAME        FSTYPE LABEL       UUID                                 MOUNTPOINT
sda
└─sda1      ntfs   SynoBackups 4EE12D1B5321171F
mmcblk0
├─mmcblk0p1 vfat   RECOVERY    525E-19E4
├─mmcblk0p2
├─mmcblk0p5 ext4   SETTINGS    ceb0ae64-8675-406b-8eed-2244c26814c8
├─mmcblk0p6 vfat   boot        8454-E385                            /boot
├─mmcblk0p7 ext4   root0       65678398-7f53-48ec-8452-c277500fb4e8 /
├─mmcblk0p8 vfat               AC0D-3FB1
└─mmcblk0p9 ext4               ff645116-fe34-43bf-a580-b89fa963085d

Note that there’s also a more specific id, the UUID. We will use this UUID later when we configure a default mount point in /etc/fstab.

Now we’ll try to mount the new partition. Create a folder to mount the partition and mount it manually:

sudo mkdir /mnt/backups
sudo mount -o defaults /dev/sda1 /mnt/backups

Verify that the disk is mounted and try to write some stuff to it:

> df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/root       8.0G  2.7G  4.9G  36% /
devtmpfs        457M     0  457M   0% /dev
tmpfs           462M     0  462M   0% /dev/shm
tmpfs           462M  6.2M  455M   2% /run
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           462M     0  462M   0% /sys/fs/cgroup
/dev/mmcblk0p6   68M   23M   46M  33% /boot
/dev/sda1       4.6T  210M  4.6T   1% /mnt/backups

> sudo lsblk --fs
NAME        FSTYPE LABEL       UUID                                 MOUNTPOINT
sda
└─sda1      ntfs   SynoBackups 4EE12D1B5321171F                     /mnt/backups
mmcblk0
├─mmcblk0p1 vfat   RECOVERY    525E-19E4
├─mmcblk0p2
├─mmcblk0p5 ext4   SETTINGS    ceb0ae64-8675-406b-8eed-2244c26814c8
├─mmcblk0p6 vfat   boot        8454-E385                            /boot
├─mmcblk0p7 ext4   root0       65678398-7f53-48ec-8452-c277500fb4e8 /
├─mmcblk0p8 vfat               AC0D-3FB1
└─mmcblk0p9 ext4               ff645116-fe34-43bf-a580-b89fa963085d

> echo "success" | sudo tee /mnt/backups/file
success
> cat /mnt/backups/file
success
> rm /mnt/backups/file
> sudo umount /mnt/backups

Now we’ll add the partition to /etc/fstab so that it can be mounted automatically:

UUID=4EE12D1B5321171F   /mnt/backups    ntfs    defaults        0       2

See that I’m now using the UUID instead of /dev/sda to mount the ntfs volume to /mnt/backups. We can test the new setting:

> sudo mount -a
> df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/root       8.0G  2.7G  4.9G  36% /
devtmpfs        457M     0  457M   0% /dev
tmpfs           462M     0  462M   0% /dev/shm
tmpfs           462M  6.2M  455M   2% /run
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           462M     0  462M   0% /sys/fs/cgroup
/dev/mmcblk0p6   68M   23M   46M  33% /boot
/dev/sda1       4.6T  210M  4.6T   1% /mnt/backups

I think this is a really nice change in mounting the volumes and will create a more stable configuration, regardless which USB port you’ve used to connect your drive.