On Wed, Jun 27, 2012 at 1:56 PM, Chris Mosetick <[email protected]> wrote:
> Hi,
> I'm looking for help creating a udev rule on a CentOS 5.x machine. The rule
> only needs a couple things.
>
> Imagine we have a bunch of disks, with one file system on each disk. Each
> file system has a UUID, and I know the UUID of each file system ahead of
> time.
>
> The udev rule needs to do something like:
> If a disk is connected to the system and it has a file system on it with
> UUID = xxxx.-xxxx-xxx...1
> or = UUID of xxxx-xxxx-xxxx...2
> and so forth,
> If the above happens, mount the disk at /some-mount-point
>
> Also, the disks are connected via E-SATA.
>
> This should be achievable with a udev rule calling a program, something
> like: blkid -o value -s UUID or possibly using the /dev/disk/by-uuid
> symlinks
>
> I've been doing some research but been having trouble because a lot of stuff
> I've been seeing will try to mount any disk connected, or try to use a
> partition label. I'm looking for a way to only automatically mount disks
> with specific UUID's. Other disks connected into the same E-SATA ports
> should just sit there and do nothing.

I think you'd do it just like you said...  off hand something like
KERNEL=="sd*", ENV{DEVTYPE}=="partition",
RUN="/usr/local/bin/custom_mounter.sh %k"

Will run /usr/local/bin/custom_mounter.sh for every sd device.  So now
just write /usr/local/bin/custom_mounter.sh to do what you want...

#!/bin/bash
DEBUG_LOG=`mktemp /tmp/udev.XXXXXXXXXX`
echo $DEV >> $DEBUG_LOG
echo $ID >> $DEBUG_LOG
DEV=$1  #not sure the format passed here, you might need to add a path or such
ID=`/sbin/blkid -o value -s UUID $DEV`
if [ "$ID" == "foo" ]; then #if you have several, maybe a case statement
  mount $DEV /some-mount-point >> $DEBUG_LOG
fi
_______________________________________________
Discuss mailing list
[email protected]
https://lists.lopsa.org/cgi-bin/mailman/listinfo/discuss
This list provided by the League of Professional System Administrators
 http://lopsa.org/

Reply via email to