PDA

View Full Version : How to mount usb storage devices as read-only



ankushgrover
28th July 2015, 12:55 PM
Hi Friends,

On earlier fedora versions I was able to successfully mount the usb storage devices in read-only mode through udev rules. Now the below rules are no longer working on Fedora 21, in-fact with the below rules the usb drives no longer gets automounted. Can someone share the fix for Fedora 21 for mounting usb drives a read-only.

/etc/udev/rules.d/99-mine.rules

SUBSYSTEMS=="usb|firewire", KERNEL=="sd?*[0-9]*", ACTION=="add" RUN+="/usr/local/sbin/usb_remount %k"

/usr/local/sbin/usb_remount
#!/bin/bash

if [ -z "$2" ];then
$0 $1 foo &disown
exit
fi

while [ -z "$(grep -e "^/dev/$1 " /etc/mtab)" ] ;do


sleep 0.1
done

/bin/mount -o remount,ro /dev/$1

Do let me know if you need any further information.

Thanks & Regards

Ankush Grover