By default, disks can be managed by using various names such as by-ID, by-partLabel, by-parttypeuUID, by-partuUID, by-path, and by-uUID. In CEPH, however, if there are too many disks, In addition, to better distinguish the disk partition usage (for example, Filestore or Journal) of each OSD node, and ensure that the name of a physical disk does not change after a faulty disk is replaced, new management requirements are put forward for naming the disk device corresponding to the OSD node.

For example, /dev/osd5_filestore_1 indicates the first filestore partition of OSD5. /dev/osd5_journal_5 indicates the first journal partition of OSD5, for example, /dev/sdd

1. View device information

root@demo:~# udevadm info --query=all --name=/dev/sdd
 P: /devices/pci0000:00/0000:00:0d. 0/ata6/host5/target5:0:0/5:0:0:0/block/sdd
 N: sdd
 S: disk/by-id/ata-VBOX_HARDDISK_VB98806c01-1fe3494a
 S: disk/by-id/scsi-SATA_VBOX_HARDDISK_VB98806c01-1fe3494a
 S: disk/by-path/pci-0000:00:0d. 0-scsi-0:0:0:0
 S: osd5data
 E: DEVLINKS=/dev/disk/by-id/ata-VBOX_HARDDISK_VB98806c01-1fe3494a /dev/disk/by-id/scsi-SATA_VBOX_HARDDISK_VB98806c01-1fe3494a /dev/disk/by-path/pci-0000:00:0d. 0-scsi-0:0:0:0 /dev/osd5data
 E: DEVNAME=/dev/sdd
 E:DEVPATH=/devices/pci0000:00/0000:00:0d. 0/ata6/host5/target5:0:0/5:0:0:0/block/ SDD # this represents the system ID of the physical device...Copy the code

2. Select device identifier, the sample is used in the DEVPATH (DEVPATH = / devices/pci0000:00/0000:00:0 d. 0 / ata6 host5 / target)

3. Compile the udev rules file

root@demo:~# cat /etc/udev/rules.d/20-persistent-disk.rules
 KERNEL=="sd?", SUBSYSTEM=="block", DEVPATH=="*/devices/pci0000:00/0000:00:0d.0/ata6/host5/target5:0:0/5:0:0:0*", SYMLINK+="osd5", GOTO="END_20_PERSISTENT_DISK"
 KERNEL=="sd? *", ATTR{partition}=="1", SUBSYSTEM=="block", DEVPATH=="*/devices/pci0000:00/0000:00:0d.0/ata6/host5/target5:0:0/5:0:0:0*", SYMLINK+="osd5_filestore_%n"
 KERNEL=="sd? *", ATTR{partition}=="2", SUBSYSTEM=="block", DEVPATH=="*/devices/pci0000:00/0000:00:0d.0/ata6/host5/target5:0:0/5:0:0:0*", SYMLINK+="osd5_journal_%n"
 LABEL="END_20_PERSISTENT_DISK"

Copy the code

4. Run the following command to send the event event to the kernel to trigger the execution of udev Rules (similar to simulating the hot swap of block devices) :

udevadm trigger --subsystem-match=block --action=add

5. Check the end result