自动挂载
自动挂载的原理说明:http://www.linuxsir.org/bbs/showthread.php?t=157065 RH版
http://www.lowlevel.cz/log/pivot/entry.php?id=95
gnome-mount会在/media/下自动生成.hal-mtab,如果在插入U盘前后看一下它的内容,就会发现它由原来的空白,变成类似下面的内容了。
/dev/sdb1 1000 0 vfat nosuid,nodev,shortname=mixed,uid=1000,utf8,umask=077,exec,usefree /media/HARRY__ IPO
同样,用lshal –monitor监视hal,在插入U盘后会出现类似下面的提示:
Start monitoring devicelist:
————————————————-
10:28:23.914: usb_device_5ac_1300_000A270010336C48 added
10:28:24.006: usb_device_5ac_1300_000A270010336C48_if0 added
10:28:24.016: usb_device_5ac_1300_000A270010336C48_if0 property info.linux.driver = ‘usb-storage’ (new)
10:28:24.064: usb_device_5ac_1300_000A270010336C48_usbraw added
10:28:29.078: usb_device_5ac_1300_000A270010336C48_if0_scsi_host added
10:28:29.083: usb_device_5ac_1300_000A270010336C48_if0_scsi_host_scsi_device_lun0 added
10:28:29.137: usb_device_5ac_1300_000A270010336C48_if0_scsi_host_scsi_device_lun0_scsi_generic added
10:28:29.298: storage_serial_Apple_iPod_000A270010336C48_0_0 added
10:28:29.372: volume_label_HARRY___IPO added
10:28:29.567: volume_label_HARRY___IPO property volume.mount_point = ‘/media/HARRY__ IPO’
10:28:29.571: volume_label_HARRY___IPO property volume.is_mounted = true
hal策略文件:
/usr/share/hal/fdi/policy/10osvendor下带storage的,比如我的Ubuntu是20-storage-methods.fdi。
gnome-mount用的参数来自:/usr/share/gconf/schemas/gnome-mount.schemas。
在gconf-editor中/schemas/system/storage/default_options主键下会有多个主键,比如hft、iso9660、ntfs、ntfs-3g、udf、vfat,每个下都有mount_options的键名,值为<schema>,应该是让它到schema文件去找,只有ntfs是两个主键,还有一个是fstype_override,也是<schema>。
系统有套工具,比如gcontool、gconftool-2,可以用下面的版本把该文件直接导入注册表:
export GCONF_CONFIG_SOURCE=`gconftool-2 –get-default-source`
SCHEMAS=”gnome-mount.schemas”
for S in $SCHEMAS; do
gconftool-2 –makefile-install-rule /usr/share/gconf/schemas/$S > /dev/null
done
gnome-volume-manager is a GNOME daemon that acts as a policy agent in top of the kernel, udev, d-bus and HAL. It
listens to HAL events and reacts with user-configurable actions. Currently it supports automount of new media and
hot-plugged devices, autorun, autoplay for Cd’s and DVDs, and automatic camera management. It is expected to be
simple and free of polling and other evil hacks.
gnome-volume-properties – configure the gnome-volume-manager daemon.
gnome-volume-properties allows you to configure gnome-volume-manager.
This program accepts all the standard GNOME and GTK+ options, which follow the usual GNU command line syntax,
with long options starting with two dashes (`-’).
gnome-mount - Mount drives and volumes using HAL and read settings from the GNOME desktop configuration system
gconf.
SYNOPSIS
gnome-mount [-?|--help] [-v] [-n] [-t] [-b] [-d /dev/file | -h /org/fd/Hal/udi | -p nickname] [--unmount | --eject
| --write-settings | --erase-settings | --show-settings] [--mount-point where-to-mount] [--mount-options
opt1,opt2=foo,opt3] [--extra-mount-options opt4,opt5=bar] [--fstype fstype-to-use]
DESCRIPTION
This program is used to mount and unmount file systems for GNOME desktop users. It can also be used to eject discs
from CD drives and other devices that needs to be ejected. For example, iPod’s needs this to make the “Do not dis-
connect” message go away.
Normally, this program is invoked by software in the GNOME stack (specifically gnome-vfs-daemon and gnome-volume-
manager ). End users should never have to deal with gnome-mount directly on the command line, nor should they have
to read this manual page.
Mounting a file system into the root file system involves a certain degree of configuration and as such is subject
to whatever preferences an user might have. gnome-mount allows the user to control the mount point location, the
mount options and what file system to use for mounting a file system. The settings are read from the gconf
database (which is per-user) and can also be overridden on the command line using the appropriate parameters. See
below.
PRIVILEGES
gnome-mount is intended for unprivileged users and HAL ultimately controls if the calling user is allowed to
mount, unmount or eject volumes as well as what mount options are valid. As such, requests may be denied. See the
(human readable) exception returned from HAL for details if a request fails.
Note that HAL has a notion of what mount options are valid for a given volume. They are listed in the HAL property
volume.mount.valid_options on the device object representing the volume to mount. Consult lshal(1) for details.
Also note that HAL by default appends the options nosuid and nodev to prevent privilege escalation.
In addition to using HAL as the mechanism for mounting file systems, the /etc/fstab file is also consulted as HAL
will refuse to mount any file system listed in this file as it would violate system policy. If this is the case,
gnome-mount will invoke mount(1) as the calling user rather than invoking the Mount method on the org.freedesk-
top.Hal.Device.Volume interface on the device object representing the volume / drive. This means that settings
(mount point, mount options, file system type) read by gnome-mount are not passed along as these are already spec-
ified in the /etc/fstab file and there are no mechanism to override them. When parsing the /etc/fstab file, gnome-
mount (and also HAL for that matter) resolves symbolic links and also respects the LABEL= and UUID= notations. For
example, if this line is in /etc/fstab
LABEL=MyVolume /mnt/myvolume auto user,defaults 0 0
then gnome-mount mounts the file system with the label MyVolume via mount(1) and /etc/fstab rather than using the
HAL mechanisms.
hald is a daemon that maintains a database of the devices connected to the system system in real-time. The daemon
connects to the D-Bus system message bus to provide an API that applications can use to discover, monitor and
invoke operations on devices. For more information about both the big picture and specific API details, refer to
the HAL spec which can be found in /usr/share/doc/hal-doc/spec/hal-spec.html depending on the distribution.
lisir@lisir-desktop:~$ apt-cache search ivman
ivman – daemon to auto-mount and manage media devices
thunar-volman
The Thunar Volume Manager is an extension for the Thunar file manager, which enables automatic management of removable drives and media.
The advantage of Thunar Volume Manager over other solutions (like gnome-volume-manager or ivman) is that it does not require an additional daemon to be running in the users desktop session, which means it is a very lightweight solution. In addition, the Thunar Volume Manager smoothly integrates into the Thunar file manager and the Xfce desktop.
It was designed to look and behave similar to gnome-volume-manager to get consistent removable drive and media management in Xfce and GNOME. This is to help GNOME refugees and people using both Xfce and GNOME.