Udev to detect USB disk - Slackware

This is a discussion on Udev to detect USB disk - Slackware ; Hi, Is there a simple udev sample showing me how to detect a USB disk inserted/removed? The udev man page seems hard to understand, so I think a real sample will help. What I want is: 1. when a usb ...

+ Reply to Thread
Results 1 to 6 of 6

Thread: Udev to detect USB disk

  1. Udev to detect USB disk

    Hi,

    Is there a simple udev sample showing me how to detect a USB disk
    inserted/removed? The udev man page seems hard to understand, so I
    think a real sample will help.

    What I want is:
    1. when a usb disk inserted in, mount it and run a external program.
    2. when a usb disk removed, umount it and also run a external program.

    Thanks.

  2. Re: Udev to detect USB disk

    On 2008-08-14, Steven Woody wrote:

    > What I want is:
    > 1. when a usb disk inserted in, mount it and run a external program.
    > 2. when a usb disk removed, umount it and also run a external program.


    I have a default 12.1 slack installed. When I want a usb flash drive
    mounted I su- and give the command:

    #mount -t vfat /dev/sda1 /mnt/key

    I detect if the flash drive (key) is actually mounted by the df command.
    Unmounting is:

    #umount /mnt/key

    I made the mount point, /mnt/key, myself.

    I've recently discovered that If I just plug in the key, I will get a gui
    labeled '4.1 Removable Media-KDE Daemon' on my kde window that will prompt
    me for what to do with this key I just plugged in. It asks if I want to:

    1. Open a new window
    2. Download photos with digikam
    3. Do Nothing

    If I select number 1, it opens Konqueror and shows me the tree for the key,
    so it has mounted the USB flash drive for me. There is a 'configure' button
    that gives me a new gui ...Configure-KDE Control Module.... with all kinds
    of options. I don't use it, and I don't know if this is slack/kde alone, or
    if digikam is part of it, but it does show that slack/kde are capable of
    mounting a USB media without cli commands. I'm sure it can also be done
    automatically if configured to do so. Maybe someone else can take it from
    here.

    nb

  3. Re: Udev to detect USB disk

    Hallo, Steven,

    Du meintest am 13.08.08:

    > Is there a simple udev sample showing me how to detect a USB disk
    > inserted/removed? The udev man page seems hard to understand, so I
    > think a real sample will help.


    I've only read about a long way. It uses "udev", "hald" and "d-bus".

    Maybe "usbmount" helps:

    http://usbmount.alioth.debian.org/

    (it's unmaintained since more than 1 year).

    Viele Gruesse
    Helmut

    "Ubuntu" - an African word, meaning "Slackware is too hard for me".


  4. Re: Udev to detect USB disk

    Steven Woody wrote:
    > Hi,
    >
    > Is there a simple udev sample showing me how to detect a USB disk
    > inserted/removed? The udev man page seems hard to understand, so I
    > think a real sample will help.
    >
    > What I want is:
    > 1. when a usb disk inserted in, mount it and run a external program.
    > 2. when a usb disk removed, umount it and also run a external program.
    >
    > Thanks.


    Have a look at /usr/doc/udev-/*

    On a Slackware 12.1 system the file
    /usr/doc/udev-118/docs/writing_udev_rules/index.html
    will probably cover everything you want/need to know.


    Regards,

    Kees.

    --
    Kees Theunissen.

  5. Re: Udev to detect USB disk

    On Aug 14, 7:51 pm, Kees Theunissen wrote:
    > Steven Woody wrote:
    > > Hi,

    >
    > > Is there a simple udev sample showing me how to detect a USB disk
    > > inserted/removed? The udev man page seems hard to understand, so I
    > > think a real sample will help.

    >
    > > What I want is:
    > > 1. when a usb disk inserted in, mount it and run a external program.
    > > 2. when a usb disk removed, umount it and also run a external program.

    >
    > > Thanks.

    >
    > Have a look at /usr/doc/udev-/*
    >
    > On a Slackware 12.1 system the file
    > /usr/doc/udev-118/docs/writing_udev_rules/index.html
    > will probably cover everything you want/need to know.
    >
    > Regards,
    >
    > Kees.
    >
    > --
    > Kees Theunissen.


    Thank you. I am reading. One think the document don't cover: How do
    I know a device's KERNEL/SUBSYSTEM/DRIVER name before write a rule?
    Can I get it from sysfs?

    Thanks.

  6. Re: Udev to detect USB disk

    On Aug 15, 9:31 am, Steven Woody wrote:
    > On Aug 14, 7:51 pm, Kees Theunissen wrote:
    >
    >
    >
    > > Steven Woody wrote:
    > > > Hi,

    >
    > > > Is there a simple udev sample showing me how to detect a USB disk
    > > > inserted/removed? The udev man page seems hard to understand, so I
    > > > think a real sample will help.

    >
    > > > What I want is:
    > > > 1. when a usb disk inserted in, mount it and run a external program.
    > > > 2. when a usb disk removed, umount it and also run a external program.

    >
    > > > Thanks.

    >
    > > Have a look at /usr/doc/udev-/*

    >
    > > On a Slackware 12.1 system the file
    > > /usr/doc/udev-118/docs/writing_udev_rules/index.html
    > > will probably cover everything you want/need to know.

    >
    > > Regards,

    >
    > > Kees.

    >
    > > --
    > > Kees Theunissen.

    >
    > Thank you. I am reading. One think the document don't cover: How do
    > I know a device's KERNEL/SUBSYSTEM/DRIVER name before write a rule?
    > Can I get it from sysfs?
    >
    > Thanks.


    got it. please ignore my previous posting. sorry

+ Reply to Thread