From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 7C3A313800E for ; Thu, 2 Aug 2012 17:01:39 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id D8D79E076B; Thu, 2 Aug 2012 17:01:19 +0000 (UTC) Received: from ironport2-out.teksavvy.com (ironport2-out.teksavvy.com [206.248.154.182]) by pigeon.gentoo.org (Postfix) with ESMTP id 50415E0733 for ; Thu, 2 Aug 2012 16:59:50 +0000 (UTC) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgsKAG6Zu09MCouF/2dsb2JhbABEsnYDgRiBCIIVAQEEATocKAsLNBIUJTeICQULuX6LCBpAgUSCPGIDjT6HXIVfiDqBWIMF X-IronPort-AV: E=Sophos;i="4.75,637,1330923600"; d="scan'208";a="194755901" Received: from 76-10-139-133.dsl.teksavvy.com (HELO waltdnes.org) ([76.10.139.133]) by ironport2-out.teksavvy.com with SMTP; 02 Aug 2012 12:59:48 -0400 Received: by waltdnes.org (sSMTP sendmail emulation); Thu, 02 Aug 2012 12:59:19 -0400 From: "Walter Dnes" Date: Thu, 2 Aug 2012 12:59:19 -0400 To: gentoo-user@lists.gentoo.org Subject: Re: [gentoo-user] Udev rules for identical hard drives Message-ID: <20120802165919.GA25423@waltdnes.org> References: <20120802013404.3c67615a@weird.wonkology.org> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-user@lists.gentoo.org Reply-to: gentoo-user@lists.gentoo.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20120802013404.3c67615a@weird.wonkology.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-Archives-Salt: f4152d37-0d57-4f68-b2f5-908216b8fac5 X-Archives-Hash: 371b273536f31ef633fd877db1c2775d On Thu, Aug 02, 2012 at 01:34:04AM +0200, Alex Schuster wrote > So I made some udev rules like this, and my drives are called /dev/hd1, > hd2 and hd3: > > SUBSYSTEMS=="scsi", KERNEL=="sd?", ATTRS{model}=="SAMSUNG HD154UI", > SYMLINK="hd1" > > This works fine, and this way I can address them in scripts, smartd and > hdparm config files and such. But now I have two identical drives. I had > this before with the drive above, but while being identical models, the > two drives differed a little in size, so I just had to add ATTR{size}. > This does not help with my current drives, and I find nothing > in /sys/block/sd?/device/ that differs. Could there be another way to > distinguish the drives, like looking at the partition scheme or something? You can get the ATTRS{serial} (i.e. serial number). See the printer example at http://www.reactivated.net/writing_udev_rules.html and adapt to your hard drive. Serial numbers should be unique, even amongst otherwise identical drives... ====================================================================== I power on my printer, and it is assigned device node /dev/lp0. Not satisfied with such a bland name, I decide to use udevinfo to aid me in writing a rule which will provide an alternative name: # udevinfo -a -p $(udevinfo -q path -n /dev/lp0) looking at device '/class/usb/lp0': KERNEL=="lp0" SUBSYSTEM=="usb" DRIVER=="" ATTR{dev}=="180:0" looking at parent device '/devices/pci0000:00/0000:00:1d.0/usb1/1-1': SUBSYSTEMS=="usb" ATTRS{manufacturer}=="EPSON" ATTRS{product}=="USB Printer" ATTRS{serial}=="L72010011070626380" My rule becomes: SUBSYSTEM=="usb", ATTRS{serial}=="L72010011070626380", SYMLINK+="epson_680" ====================================================================== -- Walter Dnes