Created
April 19, 2014 00:43
-
-
Save xlfe/11069850 to your computer and use it in GitHub Desktop.
Disable non-USB drives in linux
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 | |
for d in $(find /sys/block -type l -name "sd*") | |
do | |
if [ -z "$(readlink -f $d | grep -i usb)" ] | |
then | |
echo "$d is a non-USB device, disabling access" | |
sudo bash -c "echo 1 > $d/device/delete" | |
else | |
echo "$d is a USB device" | |
fi | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment