I have 8 hard disks on a home server. Sometimes I plug and unplug one or two, and if I restart the system all the drive letters are messed up. I would like to assign a block to each hard drive based on its serial number or other attributes that may identify each hard drive. The problem is that using udevadm info --attribute-walk --path /sys/block/sda
I can't find any unique attribute that a udev
rule can match!
This is the output for udevadm info --attribute-walk --path /sys/block/sda
:
looking at device '/devices/pci0000:00/0000:00:1c.6/0000:08:00.0/0000:09:00.0/host4/target4:0:0/4:0:0:0/block/sda':
KERNEL=="sda"
SUBSYSTEM=="block"
DRIVER==""
ATTR{range}=="16"
ATTR{ext_range}=="256"
ATTR{removable}=="0"
ATTR{ro}=="0"
ATTR{size}=="976773168"
ATTR{alignment_offset}=="0"
ATTR{discard_alignment}=="0"
ATTR{capability}=="50"
ATTR{stat}==" 303039 9092221 74569992 3246580 12765 996 11288 1415644 0 3250052 4661800"
ATTR{inflight}==" 0 0"
ATTR{events}==""
ATTR{events_async}==""
ATTR{events_poll_msecs}=="-1"
looking at parent device '/devices/pci0000:00/0000:00:1c.6/0000:08:00.0/0000:09:00.0/host4/target4:0:0/4:0:0:0':
KERNELS=="4:0:0:0"
SUBSYSTEMS=="scsi"
DRIVERS=="sd"
ATTRS{device_blocked}=="0"
ATTRS{type}=="0"
ATTRS{scsi_level}=="6"
ATTRS{vendor}=="ATA "
ATTRS{model}=="ST3500630A "
ATTRS{rev}=="3.AA"
ATTRS{state}=="running"
ATTRS{timeout}=="30"
ATTRS{iocounterbits}=="32"
ATTRS{iorequest_cnt}=="0xa39aa"
ATTRS{iodone_cnt}=="0xa39aa"
ATTRS{ioerr_cnt}=="0xfa0d"
ATTRS{evt_media_change}=="0"
ATTRS{queue_depth}=="1"
ATTRS{queue_type}=="none"
All the other hard drives have similar output, there isn't a way to identify them. ATTRS{model} is not suitable because I have 3 hard disks that are the same model.