LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 12-14-2008, 08:57 PM   #1
MrUmunhum
Member
 
Registered: May 2006
Location: Mt Umunhum, CA, USA
Distribution: Debian/ Fedora
Posts: 435

Rep: Reputation: 33
How to stop mounts on /media when inserting a USB device. (SD, Flash, etc.)


Hi group,

I thought I had posted this questions before but I can't find it if I did.

I need to stop my Linux system from mounting USB drives as /media/xxxn. My problem is I am attempting to create a script that I can use to build a file system on an SD card. When I use fdisk and create the partition, the kernel will use the old partition configuration until it is 'ejected' or a system reboot. I can do an 'eject' then I must re-plug the card and then the system does the mounts. I don't want it to do this!

Or is there a way to re-read the partition tables so that I don't need to eject and re-plug?

Thanks for your time.
 
Old 12-14-2008, 10:21 PM   #2
indienick
Senior Member
 
Registered: Dec 2005
Location: London, ON, Canada
Distribution: Arch, Ubuntu, Slackware, OpenBSD, FreeBSD
Posts: 1,853

Rep: Reputation: 65
Take a look at the files in /etc/udev/rules.d/.

You will probably have to configure the UDEV rules.
 
Old 12-15-2008, 07:24 AM   #3
zyrotec
LQ Newbie
 
Registered: Feb 2008
Posts: 2

Rep: Reputation: 0
instead of doing an "eject" just
Code:
umount /media/xxxn
, then you should be able to run fdisk on the device.
 
Old 12-15-2008, 08:26 AM   #4
SirYes
LQ Newbie
 
Registered: Jan 2007
Location: Lodz, POLAND
Distribution: Debian 4.0, Ubuntu 6.10, Gentoo 2006.1 (x86/amd64)
Posts: 4

Rep: Reputation: 0
You should probably use partprobe. Just install parted, it should come with it.

See:
http://www.cyberciti.biz/tips/re-rea...ux-system.html
http://linux.die.net/man/8/partprobe
 
Old 12-16-2008, 04:30 PM   #5
MrUmunhum
Member
 
Registered: May 2006
Location: Mt Umunhum, CA, USA
Distribution: Debian/ Fedora
Posts: 435

Original Poster
Rep: Reputation: 33
Must use eject and not umount

Quote:
Originally Posted by zyrotec View Post
instead of doing an "eject" just
Code:
umount /media/xxxn
, then you should be able to run fdisk on the device.
The problem is that the old partition map is still in the kernal's memory. So I need to use eject.
 
Old 12-16-2008, 05:39 PM   #6
MrUmunhum
Member
 
Registered: May 2006
Location: Mt Umunhum, CA, USA
Distribution: Debian/ Fedora
Posts: 435

Original Poster
Rep: Reputation: 33
That works

Quote:
Originally Posted by SirYes View Post
You should probably use partprobe. Just install parted, it should come with it.

See:
http://www.cyberciti.biz/tips/re-rea...ux-system.html
http://linux.die.net/man/8/partprobe
I tried using parted and that works better but it still mounts the file systems if the partition table has changed.

It does modify the kernel's partition table.

Thanks.

Last edited by MrUmunhum; 12-16-2008 at 05:41 PM.
 
Old 12-17-2008, 01:33 AM   #7
ErV
Senior Member
 
Registered: Mar 2007
Location: Russia
Distribution: Slackware 12.2
Posts: 1,202
Blog Entries: 3

Rep: Reputation: 62
Quote:
Originally Posted by MrUmunhum View Post
Hi group,

I thought I had posted this questions before but I can't find it if I did.

I need to stop my Linux system from mounting USB drives as /media/xxxn. My problem is I am attempting to create a script that I can use to build a file system on an SD card. When I use fdisk and create the partition, the kernel will use the old partition configuration until it is 'ejected' or a system reboot. I can do an 'eject' then I must re-plug the card and then the system does the mounts. I don't want it to do this!

Or is there a way to re-read the partition tables so that I don't need to eject and re-plug?

Thanks for your time.
hdparm -z allows forces kernel to re-read partition table of drive. Not sure if it can be used on usb drives.
 
Old 12-18-2008, 10:27 AM   #8
nooneknowme
Member
 
Registered: Feb 2008
Location: Bangalore, India
Posts: 66

Rep: Reputation: 4
for me a combination of umount /media/XXX and partprobe does the trick.
 
Old 12-18-2008, 02:30 PM   #9
pcallycat
LQ Newbie
 
Registered: Oct 2008
Posts: 2

Rep: Reputation: 0
This depends largely on what is performing the automount. Many distros set up the desktop environment to perform the automount, in which case, you would need to find the setting in that environment to disable automounting. Some use backend scripts to perform the mount (ie, I've use a combination of udev,pmount, and kludges to make things work my way before).

What distro and what desktop environment are you using?
 
Old 12-19-2008, 03:36 PM   #10
MrUmunhum
Member
 
Registered: May 2006
Location: Mt Umunhum, CA, USA
Distribution: Debian/ Fedora
Posts: 435

Original Poster
Rep: Reputation: 33
Quote:
Originally Posted by pcallycat View Post
This depends largely on what is performing the automount. Many distros set up the desktop environment to perform the automount, in which case, you would need to find the setting in that environment to disable automounting. Some use backend scripts to perform the mount (ie, I've use a combination of udev,pmount, and kludges to make things work my way before).

What distro and what desktop environment are you using?
Well I am currently using Fedora Core 8 and Gnome, but I am looking for a universal fix. Have not tried at init 3 level.
 
Old 12-19-2008, 03:37 PM   #11
MrUmunhum
Member
 
Registered: May 2006
Location: Mt Umunhum, CA, USA
Distribution: Debian/ Fedora
Posts: 435

Original Poster
Rep: Reputation: 33
Quote:
Originally Posted by ErV View Post
hdparm -z allows forces kernel to re-read partition table of drive. Not sure if it can be used on usb drives.
Yes, that does work. But it still does the mount.
 
Old 12-19-2008, 05:11 PM   #12
SirYes
LQ Newbie
 
Registered: Jan 2007
Location: Lodz, POLAND
Distribution: Debian 4.0, Ubuntu 6.10, Gentoo 2006.1 (x86/amd64)
Posts: 4

Rep: Reputation: 0
Quote:
Originally Posted by MrUmunhum View Post
Yes, that does work. But it still does the mount.
Do I really have to do the googling for you? ...
Anyway: http://www.google.com/search?q=ubunt...vent+automount

Here are good clues:
http://ubuntuforums.org/showthread.php?t=13692

Quote:
Originally Posted by init1
Quote:
Originally Posted by marquivon
From that page, this works for me
Quote:
There is a solution but you will have to enter your password every time you want to mount a removable device:
1. Press Alt+F2 and enter:
polkit-gnome-authorization
2. Go to Storage => Mount file systems from removable drivers
3. Press the "Edit..." button
4. Choose "Active Console: Authentication"
5. Press the "Modify..." button
And this one is good too:
Quote:
Originally Posted by super_hill
This way works for me:
gconftool-2 --type bool --set /apps/nautilus/preferences/media_automount false

You can refer: http://ubuntuforums.org/showthread.php?p=4823693
 
Old 12-20-2008, 04:21 PM   #13
MrUmunhum
Member
 
Registered: May 2006
Location: Mt Umunhum, CA, USA
Distribution: Debian/ Fedora
Posts: 435

Original Poster
Rep: Reputation: 33
[SOLVED] It is a Gnome thing on my system

Thanks for all of your responses. The one that I found useful was:
System->Preferences->Hardware->Removable Devices
Then disable the first two lines in the Stoarge sections:
Mount removable drives
Mount removable media
Thanks again for your time.
 
Old 06-16-2009, 09:38 PM   #14
MrUmunhum
Member
 
Registered: May 2006
Location: Mt Umunhum, CA, USA
Distribution: Debian/ Fedora
Posts: 435

Original Poster
Rep: Reputation: 33
I hate FC10, what a POS!

Quote:
Originally Posted by MrUmunhum View Post
Thanks for all of your responses. The one that I found useful was:
System->Preferences->Hardware->Removable Devices
Then disable the first two lines in the Stoarge sections:
Mount removable drives
Mount removable media
Thanks again for your time.
This option is not available in FC10, along with a lot of other stuff that used to be there!
 
Old 06-26-2009, 09:34 PM   #15
ehdwuld
Member
 
Registered: Jul 2003
Distribution: Currently Suse 11.1 but have RH7,8,9 / Fedora 7,8_64,9_64,&10_64
Posts: 634

Rep: Reputation: 30
durned fedora 10
 
  


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
USB flash drive (Pen drive) mounts read only prabhatsoni Linux - Hardware 24 07-02-2007 02:28 PM
USB drive mounts as media player beanbox Ubuntu 3 06-04-2007 04:35 AM
USB Flash mounts the first time but not the second arubin Slackware 3 04-04-2006 03:29 AM
USB device mounts removed unexpectedly elsabio Linux - General 0 01-02-2006 12:13 PM
Stop USB Flash drive from buffering? pandasuit Linux - Hardware 12 12-30-2003 03:00 AM


All times are GMT -5. The time now is 08:28 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration