OS Setup Extras - LathDevers/RasPi-OMV-Setup GitHub Wiki

How to enable AFP on OMV

⚠️ Update: SMB is preferred over AFP for Time Machine. Source

AFP is the native file and printer sharing protocol for Macs and it supports many unique Mac attributes that are not supported by other protocols. So for the best performance, and 100% compatibility, AFP should be used. (Source)

I tried it out, but SMB was faster...

First install netatalk:

sudo apt install netatalk
nano /etc/netatalk/afp.conf

Paste this into the config file:

;
; Netatalk 3.x configuration file
;

[Global]
; Global server settings

; [Homes]
; basedir regex = /home

[dusty]
path = /srv/dev-disk-by-uuid-10C4B9617AABC62B/dusty

[backup]
path = /srv/dev-disk-by-uuid-2a24ad88-d8e0-489b-9d1f-be706f81f4b4/backup
time machine = yes

Source: https://forum.openmediavault.org/index.php?thread/43750-afp-on-omv-6/

Restart netatalk:

sudo systemctl restart netatalk

Source: https://chicagodist.com/blogs/news/using-netatalk-to-share-files-between-a-raspberry-pi-and-mac

SMB
AFP

Create partition on Linux

I will use GNU parted.

sudo parted /dev/sdb
mkpart primary ext4 0% 50%
mkpart primary ntfs 50% 100%
sudo mkfs.ext4 /dev/sdb1
sudo mkntfs -f /dev/sdb2

⚠️ The parted mkpart command does not make file system, even if you specify ext4 and ntfs or other in the same line! Don't let it fool you!

May need to unmount disk

sudo umount -fl /dev/sdb1

Useful commands

lsblk # prints disks
sudo fdisk -l /dev/sdb # prints start-end sectors for partitions

Useful links

https://linuxhint.com/parted_linux/
http://woshub.com/parted-create-manage-disk-partitions-linux/
https://www.sciencedirect.com/topics/computer-science/primary-partition

This is how to update Linux packages

sudo apt update && sudo apt upgrade && sudo apt autoremove

Create a custom command

Create a new .sh script in an IDE of your choice. (You could e. g. create it in VS Code on you computer, then copy it to an SMB shared folder, if already set up)

#!/bin/bash

# Define an associative array with folder information
declare -A folders=(
    ["/"]="root"
    ["/boot"]="boot"
    ["/srv/dev-disk-by-uuid-10C4B9617AABC62B"]="dusty"
    ["/srv/dev-disk-by-uuid-34F5EE1202469FF7"]="nasty"
    ["/srv/dev-disk-by-uuid-32d98a4f-5c30-4c00-8057-9efd214e56d6"]="backup"
)

# Print header
printf "%-6s  %8s  %9s  %3s  %-20s\n" "Name" "Capacity" "Available" "Use" "Mounted on"
echo "--------------------------------------------------------------------------------------------"

# Iterate through folders and print information
for folder in "${!folders[@]}"; do
    name="${folders[$folder]}"
    full=$(df -h "$folder" | awk 'NR==2 {print $2}')
    available=$(df -h "$folder" | awk 'NR==2 {print $4}')
    usage=$(df -h "$folder" | awk 'NR==2 {print $5}')
    mounted=$(df -h "$folder" | awk 'NR==2 {print $6}')
    printf "%-6s  %8s  %9s  %3s  %-20s\n" "$name" "$full" "$available" "$usage" "$mounted"
done

Name it for example to custom_disk_usage.sh.

Give it execute permission.

chmod +x custom_disk_usage.sh

Move the script to a directory that's in your system's PATH, such as /usr/local/bin/

sudo mv custom_disk_usage.sh /usr/local/bin/

You can execute the script, by running the following command. (In any folder)

custom_disk_usage.sh

You can create a custom command by creating a symbolic link (symlink) to your script without the .sh extension and placing it in a directory that's in your system's PATH. This will allow you to run your script using a shorter command.

Rename the script:

sudo mv /usr/local/bin/custom_disk_usage.sh /usr/local/bin/diskusage

Make sure the renamed script file has execute permission.

sudo chmod +x /usr/local/bin/diskusage

Now, you should be able to run your script using the new command:

diskusage
⚠️ **GitHub.com Fallback** ⚠️