This script provides an interface similar to e2label to set the labels
on vfat-formatted disks.
It's basically a pretty thin wrapper around mtools, which mitigates
mtools' awkward syntax.
--- /dev/null
+#!/bin/bash -x
+
+usage() {
+ cat <<EOF
+vfat-label.sh: shows or sets the label on a vfat disk.
+Similar to e2label.
+
+To show the label:
+vfat-label.sh <dev-name>
+
+To set the label:
+vfat-label.sh <dev-name> <label-name>
+EOF
+ exit 1
+}
+
+die() {
+ echo "$@"
+ exit 1
+}
+
+which mlabel 1>/dev/null 2>/dev/null || \
+ die "You need to install mtools for this to work."
+
+if [ "x${1}" == "x-h" ]; then
+ usage
+fi
+
+if [ $# -eq 1 ]; then
+ mlabel -i "${1}" -s ::
+elif [ $# -eq 2 ]; then
+ mlabel -i "${1}" ::${2}
+else
+ usage
+fi