LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-12-2012, 05:17 AM   #1
gemmajid
Member
 
Registered: Mar 2012
Location: Karachi
Distribution: Ubuntu, RedHat, CentOs,
Posts: 104

Rep: Reputation: Disabled
Block USB drives in Ubuntu 12.04


I want to block usb drives completely in my Ubuntu 12.04 machine.. Kindly let me know the procedure..
 
Old 12-12-2012, 10:29 PM   #2
malekmustaq
Senior Member
 
Registered: Dec 2008
Location: root
Distribution: Slackware & BSD
Posts: 1,665

Rep: Reputation: 487Reputation: 487Reputation: 487Reputation: 487Reputation: 487
Quote:
I want to block usb drives completely in my Ubuntu 12.04 machine..
Majid,

What do you mean by " to block"? To prevent them from getting mounted? or to prevent them from being synced into the system?

Please describe fully what you wanted to happen so that we can help you better.
 
Old 12-13-2012, 10:02 AM   #3
gemmajid
Member
 
Registered: Mar 2012
Location: Karachi
Distribution: Ubuntu, RedHat, CentOs,
Posts: 104

Original Poster
Rep: Reputation: Disabled
malekmustaq,

I don't want any user to use usb in my computer even me too.. is there any why through which usb drive doesn't mount or even doesn't appear on system..
 
Old 12-13-2012, 10:28 AM   #4
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,979

Rep: Reputation: Disabled
Normally USB drives are handled by udev rules. You'll find the rules for your system in /etc/udev/rules.d and /usr/share/udev
Find out which rule is applied when someone plugs a USB device in, remove the rule and check if it is no longer recognized.

Markus
 
Old 12-13-2012, 01:02 PM   #5
malekmustaq
Senior Member
 
Registered: Dec 2008
Location: root
Distribution: Slackware & BSD
Posts: 1,665

Rep: Reputation: 487Reputation: 487Reputation: 487Reputation: 487Reputation: 487
Quote:
Originally Posted by gemmajid View Post
malekmustaq,

I don't want any user to use usb in my computer even me too.. is there any why through which usb drive doesn't mount or even doesn't appear on system..
Since you mention "mount" I assume you only mean here the "block" usb devices, but you allow usb mouse, usb dongle, or usb keyboard. So, use the root account, and create that rule, this way:

Code:
SUBSYSTEMS=="usb", DRIVERS=="usb", ATTRS{product}=="Mass Storage Device", ACTION=="remove", OPTIONS=="last_rule"
Code:
KERNEL=="usb", SUBSYSTEM=="block", ACTION=="remove", OPTIONS=="last_rule"
Copy the two lines of the code, be sure each rule is a straight line, (new line means another rule), and save the text file as "50-usb.rules" at or copy to the folder:

Code:
/etc/udev/rules.d/
Then reload udev--

Code:
~# udevadm control --reload
Try to insert a usb pendrive and observe if it is mounted or not. Come back if there is any problem.

Hope that helps.

Good luck.

Last edited by malekmustaq; 12-13-2012 at 01:06 PM.
 
2 members found this post helpful.
Old 12-14-2012, 12:30 AM   #6
gemmajid
Member
 
Registered: Mar 2012
Location: Karachi
Distribution: Ubuntu, RedHat, CentOs,
Posts: 104

Original Poster
Rep: Reputation: Disabled
Thanks malekmustaq & markush for your replies,

i have tried by creating file 50-usb.rules but nothing happen, still when i insert my usb it's working..
 
Old 12-14-2012, 01:51 AM   #7
soupmagnet
LQ Newbie
 
Registered: Sep 2012
Posts: 27

Rep: Reputation: Disabled
Quote:
Originally Posted by malekmustaq View Post
Then reload udev--

Code:
~# udevadm control --reload
I've used that in the past on Ubuntu and it never worked.

The man page says to use:
Code:
udevadm control --reload-rules
...which worked for me.

Are there different versions 'udevadm' on other distros or should the command work either way?
 
Old 12-14-2012, 02:01 AM   #8
gemmajid
Member
 
Registered: Mar 2012
Location: Karachi
Distribution: Ubuntu, RedHat, CentOs,
Posts: 104

Original Poster
Rep: Reputation: Disabled
in my case this is not working..

Last edited by gemmajid; 12-14-2012 at 04:49 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Today in 'Latest Ubuntu Karmic fails': USB drives automount with UUID instead o LXer Syndicated Linux News 0 11-17-2009 09:50 AM
Ubuntu Feisty Automounts USB Hard Drives with Permissions for Root Only cdrom600 Ubuntu 4 05-14-2007 09:37 PM
mounting usb drives on Enlightenment 16 ubuntu Fice Linux - Hardware 3 09-03-2006 07:23 AM
LXer: Ubuntu hitches a ride on USB drives LXer Syndicated Linux News 0 01-25-2006 12:16 AM
Give user permission to mount/use cdrom drives or usb drives zwyrbla Linux - Newbie 2 08-23-2004 05:30 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:52 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration