From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ryan Harper Date: Fri, 25 Jun 2010 13:59:23 +0000 Subject: [PATCH 2/2] Add virtio-blk by-id rules based on 'serial' attribute Message-Id: <1277474363-6534-3-git-send-email-ryanh@us.ibm.com> List-Id: References: <1277474363-6534-1-git-send-email-ryanh@us.ibm.com> In-Reply-To: <1277474363-6534-1-git-send-email-ryanh@us.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: linux-hotplug@vger.kernel.org Cc: john cooper , Rusty Russell , qemu-devel@nongnu.org, Ryan Harper Using virtio-blk serial attributes add rules to extract drive serial numbers and generate by-id links for the block device and partitions. With these rules added, we now see the following symlinks in disk/by-id % ls -al /dev/disk/by-id | grep vdb lrwxrwxrwx. 1 root root 9 Jun 1 22:09 virtio-QM00001 -> ../../vda lrwxrwxrwx. 1 root root 10 Jun 1 22:09 virtio-QM00001-part1 -> ../../vda1 Signed-off-by: Ryan Harper --- rules/rules.d/60-persistent-storage.rules | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/rules/rules.d/60-persistent-storage.rules b/rules/rules.d/60-persistent-storage.rules index 1f46041..6449e07 100644 --- a/rules/rules.d/60-persistent-storage.rules +++ b/rules/rules.d/60-persistent-storage.rules @@ -18,6 +18,10 @@ TEST="whole_disk", GOTO="persistent_storage_end" # for partitions import parent information ENV{DEVTYPE}="partition", IMPORT{parent}="ID_*" +# virtio-blk +KERNEL="vd*[!0-9]", ATTRS{serial}="?*", ENV{ID_SERIAL}="$attr{serial}", SYMLINK+="disk/by-id/virtio-$env{ID_SERIAL}" +KERNEL="vd*[0-9]", ATTRS{serial}="?*", ENV{ID_SERIAL}="$attr{serial}", SYMLINK+="disk/by-id/virtio-$env{ID_SERIAL}-part%n" + # USB devices use their own serial number KERNEL="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", SUBSYSTEMS="usb", IMPORT{program}="usb_id --export %p" # ATA devices with their own "ata" kernel subsystem -- 1.6.3.3