LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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 02-28-2010, 02:59 PM   #1
narnie
Member
 
Registered: Jan 2010
Distribution: Linux Mint, Ubuntu Netbook Edition, et al
Posts: 108

Rep: Reputation: 17
How is gnome/nautilus mounting and unmounting without root


Hello,

Gnome version 2.28.1 with kernel 2.6.31-14 on an Ubuntu 9.10 Karmic box.

I'm wondering how usb drives, etc get automounted in gnome now days. Thought it might be fusermount, but no. Gnome-mount is not installed. Perhaps it is via HAL or udev, but what commands control it? I've found posts that talk about using gnome-mount, but these are outdated as this package isn't even installed by default anymore.

I would like to unmount certain volumes via the command line, but without having root privileges as gnome is doing by clicking in nautilus. I would like to do the equivalent from the command line.

Are there any command lines commands that will allow me to do this (not talking about pmount which is not installed)?

Also, is there a way to prevent automounting of just certain devices, but not all? I have a USB with 7 different things on it (a "built-in" CD for some reason for windoz users, the original NTFS, and 5 linux partitions). I really only want one of the linux partitions (an XFS for DVD isos) to automount but not all the others. I would like not to have to disable ALL automounting as in:
Code:
$ gconftool-2 -s /apps/nautilus/preferences/media_automount --type=bool false
$ gconftool-2 -s /apps/nautilus/preferences/media_automount_open --type=bool false
With thanks,
Narnie
 
Old 02-28-2010, 07:24 PM   #2
narnie
Member
 
Registered: Jan 2010
Distribution: Linux Mint, Ubuntu Netbook Edition, et al
Posts: 108

Original Poster
Rep: Reputation: 17
1/2 solved

Problem is 1/2 solved. Did some playing around and found gvfs info leading me to gvfs-mount.
Listing the mount gives me these results:

Code:
woodnt@toshiba-laptop /dev $ gvfs-mount -l
Drive(0): CD/DVD Drive
  Type: GProxyDrive (GProxyVolumeMonitorGdu)
Drive(1): 499 GB Hard Disk
  Type: GProxyDrive (GProxyVolumeMonitorGdu)
  Volume(0): DATA
    Type: GProxyVolume (GProxyVolumeMonitorGdu)
  Volume(1): Linux3
    Type: GProxyVolume (GProxyVolumeMonitorGdu)
  Volume(2): Linux2
    Type: GProxyVolume (GProxyVolumeMonitorGdu)
  Volume(3): Linux4
    Type: GProxyVolume (GProxyVolumeMonitorGdu)
  Volume(4): Linux1
    Type: GProxyVolume (GProxyVolumeMonitorGdu)
Drive(2): CD Drive
  Type: GProxyDrive (GProxyVolumeMonitorGdu)
  Volume(0): WD SmartWare
    Type: GProxyVolume (GProxyVolumeMonitorGdu)
Drive(3): 500 GB Hard Disk
  Type: GProxyDrive (GProxyVolumeMonitorGdu)
  Volume(0): TI100343V0F
    Type: GProxyVolume (GProxyVolumeMonitorGdu)
I can mount my partition from the command line with:

Code:
woodnt@toshiba-laptop /dev $ gvfs-mount -d /dev/sdb9

(gvfs-mount:27658): GLib-GIO-CRITICAL **: g_mount_get_root: assertion `G_IS_MOUNT (mount)' failed

(gvfs-mount:27658): GLib-GIO-CRITICAL **: g_file_get_path: assertion `G_IS_FILE (file)' failed
Mounted /dev/sdb9 at (null)

(gvfs-mount:27658): GLib-GObject-CRITICAL **: g_object_unref: assertion `G_IS_OBJECT (object)' failed

(gvfs-mount:27658): GLib-GObject-CRITICAL **: g_object_unref: assertion `G_IS_OBJECT (object)' failed
Mount gives:
Code:
woodnt@toshiba-laptop /dev $ mount|grep /dev/sdb9
/dev/sdb9 on /media/DATA type xfs (rw,nosuid,nodev,uhelper=devkit)
I can also successfully unmount via:
Code:
woodnt@toshiba-laptop /dev $ gvfs-mount -u /media/DATA/
woodnt@toshiba-laptop /dev $ mount|grep /dev/sdb9
woodnt@toshiba-laptop /dev $
So, for the most current Gnome'rs out there, this is how it is done and how scripting can manage it. BTW, somehow, fuser is involves as can be seen with:

Code:
woodnt@toshiba-laptop /dev $ mount|grep fuse
none on /sys/fs/fuse/connections type fusectl (rw)
gvfs-fuse-daemon on /home/woodnt/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev,user=woodnt)
Now, how does one modify udev rules or hal policies to prevent mounting of all partitions except the one you want. Feel free to chime in, or I'll post if I find the answer for future posterity.

Narnie
 
1 members found this post helpful.
Old 02-28-2010, 08:21 PM   #3
narnie
Member
 
Registered: Jan 2010
Distribution: Linux Mint, Ubuntu Netbook Edition, et al
Posts: 108

Original Poster
Rep: Reputation: 17
don't want to use /etc/fstab

BTW, I know that I could always hardcode something like:

Code:
/dev/sda5       /media/LINUX1    ext3    defaults,user,noauto    0   0
However, I don't want to have to "assign" a mountpoint like /media/data to it.

gvfs-mount automatically creates a mountpoint, then mounts the partition to that sight. It cleans up after itself well, too. It will unmount the partition and delete the mountpoint. Otherwise, for all my drives and partitions, I have to leave mountpoints with the volume names like /media/DATA, /media/Linux1, /media/Linux2, etc for each volume label of each partition of all the USB hard drives I have (quite a fiew). That seems like a waste.

Hence, my desire to go a step (or two) deeper than just a "simple" /etc/fstab entry that commits me to have a mountpoint directory already made and static, rather than dynamic.

That, plus I just want to learn (udev rulz or HAL rulz, or whatever).

Thanks,
Narnie
 
Old 03-01-2010, 04:15 PM   #4
Wollongong
LQ Newbie
 
Registered: May 2007
Location: Australia
Distribution: Ubuntu 12.04LTS
Posts: 13

Rep: Reputation: 2
udev rules

thanks for your informative postings Narnie.

regarding udev:
the basic operation is not so difficult: suggested starting point is:
http://www.reactivated.net/writing_udev_rules.html

This is all very well for writing a rule to match a device that wasn't automatically detected, or for simple changes such as renaming a device.

However, the real complexity of udev, I think, is the number of pre-defined rules files, found in /lib/udev/rules.d/
e.g. for a hard drive, maybe 95-devkit-disks.rules is matched.

You can't edit these files directly.

Supposedly you can write a rule file in /etc/udev/rules.d/ with a higher number than one in /lib/udev/rules.d/ and it will run first, or just copy the relevant file to /etc/udev/rules.d/ and it will suppress the running of the copied file.

However, I did not find this to be the case, when trying to fix an error in 75-persistent-net-generator.rules relating to USB-ethernet adaptors.

Also, it can be difficult to understand what they are doing due to insufficient commenting.

Can anyone point to documentation on the built-in rules?
 
Old 03-02-2010, 12:25 AM   #5
narnie
Member
 
Registered: Jan 2010
Distribution: Linux Mint, Ubuntu Netbook Edition, et al
Posts: 108

Original Poster
Rep: Reputation: 17
Quote:
Originally Posted by Wollongong View Post
thanks for your informative postings Narnie.

regarding udev:
the basic operation is not so difficult: suggested starting point is:
http://www.reactivated.net/writing_udev_rules.html

This is all very well for writing a rule to match a device that wasn't automatically detected, or for simple changes such as renaming a device.

However, the real complexity of udev, I think, is the number of pre-defined rules files, found in /lib/udev/rules.d/
e.g. for a hard drive, maybe 95-devkit-disks.rules is matched.

You can't edit these files directly.

Supposedly you can write a rule file in /etc/udev/rules.d/ with a higher number than one in /lib/udev/rules.d/ and it will run first, or just copy the relevant file to /etc/udev/rules.d/ and it will suppress the running of the copied file.

However, I did not find this to be the case, when trying to fix an error in 75-persistent-net-generator.rules relating to USB-ethernet adaptors.

Also, it can be difficult to understand what they are doing due to insufficient commenting.

Can anyone point to documentation on the built-in rules?
Thanks, I'll be eager to check out the site you suggest.

I think it the answer may be found in HAL rules, rather than udev.

I found this last night, but it was getting late to test it and I have been too busy today.

If anyone tries it and it works, post back here. I'll do the same.

http://forums.fedoraforum.org/showthread.php?t=206462

The code goes in /etc/hal/fdi/policy/preferences.fdi

Here is the code:
Code:
<?xml version="1.0" encoding="UTF-8"?> 
<deviceinfo version="0.2"> 
    <device> 
        <match key="volume.label" string="[VOLUME LABEL HERE"> 
            <merge key="volume.ignore" type="bool">true</merge> 
        </match> 
    </device> 
</deviceinfo>
Regards,
Narnie
 
Old 03-02-2010, 11:13 AM   #6
narnie
Member
 
Registered: Jan 2010
Distribution: Linux Mint, Ubuntu Netbook Edition, et al
Posts: 108

Original Poster
Rep: Reputation: 17
The only little snag here is that one must be careful to give partition names that are unique if you want to be specific, per partition, because it is based on the partition (aka volume) label.

Narnie
 
  


Reply



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
mounting and unmounting zerocool22 Linux - Server 9 06-04-2008 08:00 PM
gnome mounting usb devices as root linuxmandrake Linux - General 2 12-01-2007 09:06 AM
Gnome Nautilus compile failed in [nautilus-printer.lo] chunlee Linux - Software 5 01-24-2005 04:57 PM
Mounting and unmounting in redhat. Tommi Linux - General 3 04-22-2003 07:08 AM
Mounting and unmounting Hidden Dragon Linux - General 20 09-01-2002 07:52 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:16 PM.

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
Open Source Consulting | Domain Registration