Using udevil to automatically mount usb drives by UUID?

  • Comment has been marked as spam. 

    You can see all pending comments posted by this user  here

    Anonymous - 2014-04-09

    I'd like to know if udevil can automount (via devmon?) USB hard drives
    (mostly formatted NTFS) using their UUIDs.

    example: if the hd on /dev/sda1 has UUID="FA134BF3", udevil automatically
    mounts it in /media/FA134BF3.

    This behavior is what I've now using udisks but I'd love to use udevil
    because I can configure the mount defaults parameters in the .conf file
    (big_writes, for an instance).

    This should happen automatically every time I attach/detach any usb hd:
    udevil reads the hd UUID (no matter what it is) and then mount in

    If this is possible please let me know how to do :)

    Cheers, A B.

  • IgnorantGuru

    IgnorantGuru - 2014-04-09

    One way to do this would be to pass the --no-mount option to devmon, and use an --exec-on-drive option to run a custom script to perform the mount.

    Your script can get the uuid, then tell udevil to use that as a mount point. For example, run devmon as:

        devmon --no-mount --exec-on-drive "/usr/local/bin/mymount %d"

    Then the mymount script would contain:

        uuid=`udevil info $1 | grep '^  uuid:' | sed 's/^  uuid: *\(.*\)/\1/'`
        udevil mount $1 /media/$uuid

    udevil will create the specified mount point for you (since you don't have permission to do so).

    You can even do it all as a single devmon command, but might be clearer to use a script. And some checking to be sure the uuid was retrieved, etc would be helpful.



Cancel  Add attachments

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks