Skip to content

Instantly share code, notes, and snippets.

@stbuehler
Created January 17, 2018 15:06
Show Gist options
  • Save stbuehler/ba92524598f97847e5250126b133e76e to your computer and use it in GitHub Desktop.
Save stbuehler/ba92524598f97847e5250126b133e76e to your computer and use it in GitHub Desktop.
Use UUID instead of block device paths in /etc/fstab
#!/bin/sh
for bdev in $(blkid -o device); do
if [ ! -b "${bdev}" ]; then
echo >&2 "Not a block device: ${bdev}"
continue
fi
uuid=$(blkid -o value -s UUID -- "${bdev}")
# echo "Found UUID '${uuid}' for '${bdev}'"
# block device names hopefully don't contain special shit -.-
sed -i -e "s#^${bdev}\b#UUID=${uuid}#g" /etc/fstab
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment