UDEV rules create links named /dev/usbtosata and /dev/usbtosata1

Clean old stuff and create new partition table (GPT)

# Erase first 128Mbytes
blkdiscard -l $(( 128 * 1024 * 1024 )) -z /dev/usbtosata

# Create new partition table
parted -s /dev/usbtosata mklabel gpt
parted -s /dev/usbtosata mkpart primary ext4 1MiB 100%

# Unplug/plug disk if needed

# Create filesystem and folder structure and add tapes to amanda using a script
create-vtape.sh disk01

create-vtape.sh

#!/bin/sh

if [ $# -ne 1 ]; then
    echo "Usage: $0 <disklabel>"
    exit 1
fi

confname=dflt
disklabel=$1

# Format partition
mkfs.ext4 -m 0 -L dflt-$disklabel /dev/usbtosata1

mkdir /vtapes/$confname
chown backup:backup /vtapes/$confname
chmod 750 /vtapes/$confname
(
    cd /vtapes/$confname
    for i in $(seq 1 8); do mkdir slot$i; done
    chown backup:backup *
    chmod 750 *
    for i in $(seq 1 8); do runuser -u backup -- amlabel $confname $confname-$disklabel-vtape$i slot $i; done
    runuser -u backup -- amcheck -s $confname
)