LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (http://www.linuxquestions.org/questions/slackware-14/)
-   -   12.0 and HAL - READ THIS! (http://www.linuxquestions.org/questions/slackware-14/12-0-and-hal-read-this-566862/)

rworkman 07-05-2007 10:56 AM

12.0 and HAL - READ THIS!
 
NOTE: This post has been edited to place all of the thread's high points in one place.

First, this post assumes knowledge of what's in CHANGES_AND_HINTS.TXT -- if you haven't read that yet, go do that before you even bother with this thread...

Many people have figured this out by now, but there's one "gotcha" with automounting removable devices using HAL.
Console users are automatically added to the cdrom and plugdev groups at login via /etc/login.defs

Code:

# List of groups to add to the user's supplementary group set
 # when logging in on the console (as determined by the CONSOLE
 # setting).  Default is none.
 #
 # Use with caution - it is possible for users to gain permanent
 # access to these groups, even when not logged in on the console.
 # How to do it is left as an exercise for the reader...
 #
 CONSOLE_GROUPS          floppy:audio:video:cdrom:plugdev

The idea behind doing this was that it would "just work" without the need for admins to manually add users to the plugdev and cdrom groups, but due to the way dbus functions, it didn't work out that way.
When the messagebus service is started, it reads the content of /etc/group and then determines whether users have rights to mount removable devices based on that. This is why the 'reload' option was added to /etc/rc.d/rc.messagebus, as you need to make it aware of any changes to /etc/group if you happen to edit that file to add users to plugdev, cdrom, power, or video groups while dbus is running.

Long story short, you will need to manually add users to the affected groups - do not rely on the output of groups(1) to determine whether a user is in the appropriate group as it pertains to dbus and HAL.

For those interested in further reading, note that this is not a Slackware-specific problem - it's being discussed in various other distribution forums as well.
http://www.debian-administration.org.../308#comment_7
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=377689
http://www.mail-archive.com/debian-d...msg240793.html
Note that the "solutions" presented in the first two links are *ugly* - so my recommendation is to not even consider them, but of course, it's *your* system. The *best* way until/unless something changes in the dbus code (which doesn't seem to be easy to do in an effective and secure manner) is to manually add users to the needed groups in /etc/group.

---------------------------------------------------------------------

Re: hal-device-manager

/usr/bin/hal-device-manager needs PyGTK and a few things from gnome in order to work. Pat elected to leave the binary in the package due to the fact that some users will elect to install one of the third-party gnome builds, and any of those should provide the necessary dependencies for hal-device-manager to work.

--------------------------------------------------------------------

Re: entries in /etc/fstab

Okay, here's another hot topic that seems to be troubling a lot of people. From CHANGES_AND_HINTS.TXT:

Code:

Note that HAL will honor settings in /etc/fstab if a device is
present there, so you could technically have removable devices
defined in /etc/fstab, but if the fstab settings do not allow normal
users to mount them (with the "user" or "users" option), then HAL/dbus
will not allow them to be mounted either.
Also note that you will need to run "/etc/rc.d/rc.messagebus reload"
after adding any users to plugdev, power, or video groups so that it
re-reads the /etc/group file.

Put yourself in the cdrom and plugdev groups regardless, but here's an example to hopefully clarify what's written above.

Without a custom udev rule and an fstab entry, my Sandisk Cruzer Micro will be automatically assigned the next available /dev/sd* node by udev, and then I can mount it using HAL (well, actually DBUS via either KDE or XFCE, but that's inconsequential details for now) at /media/CRUZER_1024 (note that "CRUZER_1024" is the filesystem label that I put on it). The device will be mounted in /media with whatever name the filesystem label has.

Suppose I like for the device to be mounted in some other location for whatever reason. I would create a custom udev rule (how to do that is left as an exercise to the reader - there's ample documentation available on the subject) to assign a persistent /dev/cruzer1024 symlink to the device node, and then I would add the device to /etc/fstab like this:
Code:

/dev/cruzer1024 /mymountpoint vfat noauto,user,rw,dmask=0022,fmask=0133 0 0
At this point, I can mount/unmount the device from a command line *exactly* like I could in Slackware 11.0, or I can *still* use HAL (subject to same "actually" comment as above) to mount the device, and it will be mounted to the place and with the options specified in /etc/fstab.

---------------------------------------------------------------------

Re: Mounting devices in console (not in X)

For those using a desktop environment other than KDE, GNOME, or Xfce and still want to make use of HAL, have a look at http://slackbuilds.org/repository/12.0/system/ivman/ and http://slackbuilds.org/repository/12.0/system/pmount/.
I have not really messed with these much (aside from building and basic testing), so configuration is up to you. I also have binary packages on my site (see signature).

---------------------------------------------------------------------

Re: Using ntfs-3g instead of the in-kernel ntfs driver for NTFS filesystems

First, install ntfs-3g (I'll put in a plug for http://slackbuilds.org on this one) :-)

Note: policy files in /etc/hal/* override the defaults in /usr/share/hal/*
Next, create /etc/hal/fdi/policy/10-ntfs-policy.fdi with the following content:
Code:

<?xml version="1.0" encoding="UTF-8"?>
<deviceinfo version="0.2">
    <device>
        <match key="volume.fstype" string="ntfs">
            <match key="@block.storage_device:storage.hotpluggable" bool="true">
                <merge key="volume.fstype" type="string">ntfs-3g</merge>
                <merge key="volume.policy.mount_filesystem" type="string">ntfs-3g</merge>
                <append key="volume.mount.valid_options" type="strlist">locale=</append>
            </match>
        </match>
    </device>
</deviceinfo>

Next, restart the HAL service: /etc/rc.d/rc.hald restart
All should be well.
Note: this information was gleaned from http://wiki.archlinux.org/index.php/HAL

---------------------------------------------------------------------


Other Notes:

Use one of the generic kernels.
Do not report bugs until/unless you have verified that they are also present when using one of the generic kernels - otherwise, I (and presumably others) will ignore you.

Whatever user account you are using (yes, even root, if you're using that account) must be a member of the plugdev group in order to mount devices using HAL/DBUS.

---------------------------------------------------------------------

erklaerbaer 07-05-2007 11:17 AM

should be stickied

chess 07-05-2007 12:56 PM

Quote:

Originally Posted by erklaerbaer
should be stickied

Agreed. Thanks for the heads up, Robby.

XavierP 07-07-2007 11:33 AM

Quote:

Originally Posted by erklaerbaer
should be stickied

Just did it!

rworkman 07-08-2007 06:54 PM

One more thing - I meant to note this in CHANGES_AND_HINTS.TXT, but I forgot... :/

/usr/bin/hal-device-manager needs PyGTK and a few things from gnome in order to work. Pat elected to leave the binary in the package due to the fact that some users will elect to install one of the third-party gnome builds, and any of those should provide the necessary dependencies for hal-device-manager to work.

onebuck 07-08-2007 11:10 PM

Hi,

Thanks for the tips Robby! Helped.

lchxr 07-09-2007 12:53 AM

Does HAL auto-umount USB memory stick?
 
When I plug in a USB memory stick, HAL gives me an icon on the desktop. The USB stick is mounted only when I double clicked the icon. Is this correct?

One more question: Does HAL auto-umount the device when I plug out the USB stick? Or I need to umount by hand?

Regards,

rworkman 07-09-2007 02:15 AM

Quote:

Originally Posted by lchxr
When I plug in a USB memory stick, HAL gives me an icon on the desktop. The USB stick is mounted only when I double clicked the icon. Is this correct?

This is correct.

Quote:

One more question: Does HAL auto-umount the device when I plug out the USB stick? Or I need to umount by hand?
You definitely need to unmount the filesystem. If you right-click on the desktop icon, it will give you an option to unmount the filesystem. In that respect, it's no different from MS Windows - "unmount" is a rough equivalent of "safely remove."

rworkman 07-09-2007 02:58 AM

Okay, here's another hot topic that seems to be troubling a lot of people. From CHANGES_AND_HINTS.TXT:

Note that HAL will honor settings in /etc/fstab if a device is present there,
so you could technically have removable devices defined in /etc/fstab, but if
the fstab settings do not allow normal users to mount them (with the "user" or
"users" option), then HAL/dbus will not allow them to be mounted either.
Also note that you will need to run "/etc/rc.d/rc.messagebus reload" after
adding any users to plugdev, power, or video groups so that it re-reads the
/etc/group file.

Put yourself in the cdrom and plugdev groups regardless, but here's an example to hopefully clarify what's written above.

Without a custom udev rule and an fstab entry, my Sandisk Cruzer Micro will be automatically assigned the next available /dev/sd* node by udev, and then I can mount it using HAL (well, actually DBUS via either KDE or XFCE, but that's inconsequential details for now) at /media/CRUZER_1024 (note that "CRUZER_1024" is the filesystem label that I put on it). The device will be mounted in /media with whatever name the filesystem label has.

Suppose I like for the device to be mounted in some other location for whatever reason. I would create a custom udev rule (how to do that is left as an exercise to the reader - there's ample documentation available on the subject) to assign a persistent /dev/cruzer1024 symlink to the device node, and then I would add the device to /etc/fstab like this:
/dev/cruzer1024 /mymountpoint vfat noauto,user,rw,dmask=0022,fmask=0133 0 0
At this point, I can mount/unmount the device from a command line *exactly* like I could in Slackware 11.0, or I can *still* use HAL (subject to same "actually" comment as above) to mount the device, and it will be mounted to the place and with the options specified in /etc/fstab.

Did that help? :-)

helo 07-09-2007 04:05 AM

Quote:

Originally Posted by rworkman

I would create a custom udev rule (how to do that is left as an exercise to the reader - there's ample documentation available on the subject) to assign a persistent /dev/cruzer1024 symlink to the device node, and then I would add the device to /etc/fstab

Or you could use the device nodes under /dev/disk/by-label that udev already puts there, they work for me.

rworkman 07-09-2007 10:13 AM

Good point - no need to bother with custom udev rules if it's not necessary... :-)

onebuck 07-09-2007 12:16 PM

Hi,

Robby, the above statement would be for users that must have their hand held. I like it both ways. A lot of time at cli, most of the time. It's the user(s) that need the turnkey.

SJD 07-13-2007 06:17 AM

Hi there,

Apologies if I'm not meant to post on a sticky but I didn't want to start a new thread. I am very new to Linux and I want to sort out the mounting of USB drives but how do I add a user to the group in /etc/group? I've looked at the file, but I don't know which bits to change? I only have root on system and that is all I will ever have.

Thanks for your help,

Steve

adriv 07-15-2007 04:40 PM

Just add the name of the user to the group, like this:
Code:

cdrom::19:adri
BTW, it is highly recommended NOT to log in as root, unless you really need to.
So you better use adduser and add the username.

duryodhan 07-17-2007 05:24 AM

Quote:

Or you could use the device nodes under /dev/disk/by-label that udev already puts there, they work for me.
Aren't you better of using uuid? So that if anyone changes the label, it will still work!

Forgive me, I am still on Slackware11 , but Is my understanding below correct?
If I have a usb disk with specific uuid/label that I want to always mount to /mnt/usbdisk whenever I connect it, I should use fstab, add
/dev/disk/by-uuid/<id> /mnt/usbdisk 000
to it?
then whenever I connect the USB disk , HAL will detect it and automatically mount it to /mnt/usbdisk after reading the fstab? (and not to some stupid media:/ or something?)

Also, if I connect some ntfs drive, will HAL use the standard NTFS driver or can I specify ntfs-3g? I can use fstab for my drives, but what about drives that my friends bring over? Cos won't hal auto mount it as ntfs?

Some solutions are there at http://forum.linux-ntfs.org/viewtopic.php?t=456
but they have said "it is a distro specific thing , bug the distro devels" which I am doing here.


All times are GMT -5. The time now is 07:46 AM.