LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   How to stop mounts on /media when inserting a USB device. (SD, Flash, etc.) (https://www.linuxquestions.org/questions/linux-general-1/how-to-stop-mounts-on-media-when-inserting-a-usb-device-sd-flash-etc-690598/)

MrUmunhum 12-14-2008 07:57 PM

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.

indienick 12-14-2008 09:21 PM

Take a look at the files in /etc/udev/rules.d/.

You will probably have to configure the UDEV rules.

zyrotec 12-15-2008 06:24 AM

instead of doing an "eject" just
Code:

umount /media/xxxn
, then you should be able to run fdisk on the device.

SirYes 12-15-2008 07:26 AM

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

MrUmunhum 12-16-2008 03:30 PM

Must use eject and not umount
 
Quote:

Originally Posted by zyrotec (Post 3376010)
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.

MrUmunhum 12-16-2008 04:39 PM

That works
 
Quote:

Originally Posted by SirYes (Post 3376078)
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.

ErV 12-17-2008 12:33 AM

Quote:

Originally Posted by MrUmunhum (Post 3375616)
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.

nooneknowme 12-18-2008 09:27 AM

for me a combination of umount /media/XXX and partprobe does the trick.

pcallycat 12-18-2008 01:30 PM

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?

MrUmunhum 12-19-2008 02:36 PM

Quote:

Originally Posted by pcallycat (Post 3380273)
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.

MrUmunhum 12-19-2008 02:37 PM

Quote:

Originally Posted by ErV (Post 3378172)
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.

SirYes 12-19-2008 04:11 PM

Quote:

Originally Posted by MrUmunhum (Post 3381501)
Yes, that does work. But it still does the mount.

Do I really have to do the googling for you? ... :tisk:
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


MrUmunhum 12-20-2008 03:21 PM

[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.

MrUmunhum 06-16-2009 08:38 PM

I hate FC10, what a POS!
 
Quote:

Originally Posted by MrUmunhum (Post 3382396)
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!

ehdwuld 06-26-2009 08:34 PM

durned fedora 10


All times are GMT -5. The time now is 01:37 PM.