Last active
March 10, 2020 22:30
-
-
Save dalehamel/782cbbb9f343c48a112f to your computer and use it in GitHub Desktop.
Convert /etc/fstab to use UUID's for any matching /dev/sd* device.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
cp /etc/fstab /etc/fstab.bak | |
while read line; do | |
drive=$(echo $line | awk '{print $1}') | |
if [[ $drive =~ /dev/sd.* ]];then | |
uuid=$(blkid | grep $drive | sed 's/.*\sUUID="\([a-zA-Z0-9-]*\)".*/\1/g') | |
sed -i "s:$drive:UUID=$uuid:g" /etc/fstab | |
fi | |
done < /etc/fstab |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment