Skip to content

Instantly share code, notes, and snippets.

@acobaugh
Created April 24, 2019 15:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save acobaugh/88d0f2d26cb2b1e3aeef291828c72ff4 to your computer and use it in GitHub Desktop.
Save acobaugh/88d0f2d26cb2b1e3aeef291828c72ff4 to your computer and use it in GitHub Desktop.
A silly little script to potentially rebuild an fstab file based on the contents of mtab.
#!/usr/bin/env bash
while read line ; do
if [ "$(echo $line | egrep '^\/dev\/sd')" != "" ] ; then
dev="$(echo $line | awk '{ print $1 }')"
id="$(blkid $dev | awk '{ print $2 }')"
echo $line | sed -e "s|$dev|$id|"
else
echo $line
fi
done < /etc/mtab
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment