I'm running a Docker container based on Alpine (specifically the balenalib/armv7hf-alpine image). Within the container I want to mount a USB drive by its label, but the Alpine mount command doesn't appear to support the --label option.
I'm an Alpine newbie, but under Raspbian/Debian, I'd just use, e.g.:
mount --label USBDRIVE /mnt/usbdrive
Under Alpine I can successfully mount the drive, but I have to use its device name instead of its label, e.g.:
mount /dev/sda1 /mnt/usbdrive
Is there an approach I can use to achieve mount by label under Alpine? E.g.: a different version of mount? Or a way of finding the volume name by iterating through the labels on all available volumes?
Edit: OK, here's a solution that works (with apologies for my Bash scripting):
VOLUME=$(for VOL in $(fdisk -l | grep ^/dev/sd | awk '{print $1}'); \
do blkid $VOL; done | grep USBDRIVE | awk -F: '{print $1}')
mount $VOLUME /mnt/usbdrive
This lists all disks using fdisk, isolates all the /dev/sd* entries, uses blkid to find the volume labels, identifies the label required and grabs its volume name. (Exceptions ignored for ease of presentation).