Skip to content

Instantly share code, notes, and snippets.

@nk23x
Created April 16, 2015 17:38
Show Gist options
  • Save nk23x/7deab28a4b8f7e033cd1 to your computer and use it in GitHub Desktop.
Save nk23x/7deab28a4b8f7e033cd1 to your computer and use it in GitHub Desktop.
mount usb devices by uuid
#!/bin/bash
echo >> /etc/fstab
for d in $@; do
mkdir /mnt/usb/$(blkid ${d}|perl -pe 's/(.*)UUID=\"(.*)\" TYPE=\"(.*)\"/$2/g;')
echo "$(blkid ${d}|perl -pe 's/(.*)UUID=\"(.*)\" TYPE=\"(.*)\"/UUID=$2 \/mnt\/usb\/$2 $3 defaults,rw 1 1/g;')" >> /etc/fstab
done
mount -av
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment