#!/bin/bash
UNIT=/etc/systemd/system/mnt-union.mount

sources=$(grep "^What=" "$UNIT" | cut -d= -f2 | tr ':' ' ')

rows=""
for src in $sources; do
    wwn=$(basename "$src")
    dev=$(ls -l /dev/disk/by-id/ | grep "$wwn" | grep -v part | awk '{print $11}' | sed 's|\.\./\.\./||')

    if [[ -n "$dev" ]]; then
        model=$(lsblk -dno MODEL "/dev/$dev")
        size=$(lsblk -dno SIZE "/dev/$dev")
        rows+="$wwn\t/dev/$dev\t$model\t$size\t$src\n"
    fi
done

# Impression triée sur la colonne "DEVICE" (2e colonne)
echo -e "$rows" | sort -k2