On Mon, Mar 25 2019, Liwei Song wrote: > On 03/25/2019 07:43 AM, NeilBrown wrote: >> On Tue, Mar 19 2019, Liwei Song wrote: >> >>> This rules will create link under /dev/disk/by-partuuid/ for >>> MD devices partition, with which will support specify >>> root=PARTUUID=XXX to boot rootfs. >>> >>> Signed-off-by: Liwei Song <liwei.song@xxxxxxxxxxxxx> >>> --- >>> udev-md-raid-arrays.rules | 1 + >>> 1 file changed, 1 insertion(+) >>> >>> diff --git a/udev-md-raid-arrays.rules b/udev-md-raid-arrays.rules >>> index c95ec7b1e4a9..5b99d5873ade 100644 >>> --- a/udev-md-raid-arrays.rules >>> +++ b/udev-md-raid-arrays.rules >>> @@ -30,6 +30,7 @@ IMPORT{builtin}="blkid" >>> OPTIONS+="link_priority=100" >>> OPTIONS+="watch" >>> ENV{ID_FS_USAGE}=="filesystem|other|crypto", ENV{ID_FS_UUID_ENC}=="?*", SYMLINK+="disk/by-uuid/$env{ID_FS_UUID_ENC}" >>> +ENV{ID_FS_USAGE}=="filesystem|other", ENV{ID_PART_ENTRY_UUID}=="?*", SYMLINK+="disk/by-partuuid/$env{ID_PART_ENTRY_UUID}" >>> ENV{ID_FS_USAGE}=="filesystem|other", ENV{ID_FS_LABEL_ENC}=="?*", SYMLINK+="disk/by-label/$env{ID_FS_LABEL_ENC}" >>> >>> ENV{MD_LEVEL}=="raid[1-9]*", ENV{SYSTEMD_WANTS}+="mdmonitor.service" >>> -- >>> 2.7.4 >> >> This doesn't make any sense to me. >> Presumably you want the by-partuuid link to point to a partition in the >> array? > > Yes, That is what I want. > >> But this code will create a link pointing to the array. > > Because there is no ID_PART_ENTRY_UUID for the array, only partition in the array have > such attribute,So in my case it will only create by-partuuid for a partition. > > For example, there is an md126 raid array, > > Disk /dev/md126: 44.2 GiB, 47501541376 bytes, 92776448 sectors > Units: sectors of 1 * 512 = 512 bytes > Sector size (logical/physical): 512 bytes / 512 bytes > I/O size (minimum/optimal): 512 bytes / 512 bytes > Disklabel type: gpt > Disk identifier: 622CA1DE-A938-4704-98B0-5EAB0D3A7AAC > > Device Start End Sectors Size Type > /dev/md126p1 2048 2000895 1998848 976M EFI System > /dev/md126p2 2000896 88138671 86137776 41.1G Linux filesystem > /dev/md126p3 88138672 92776414 4637743 2.2G Linux swap > > > > # udevadm info /dev/md126 |grep ID_PART_ENTRY_UUID > this will get nothing since array do not have ID_PART_ENTRY_UUID. > > # udevadm info /dev/md126p1 |grep ID_PART_ENTRY_UUID > E: ID_PART_ENTRY_UUID=018496b3-84e1-4c9f-864e-81650b21402f > # udevadm info /dev/md126p2 |grep ID_PART_ENTRY_UUID > E: ID_PART_ENTRY_UUID=2c1df1c5-41c8-42b4-a874-95dbf07820d5 > # udevadm info /dev/md126p3 |grep ID_PART_ENTRY_UUID > E: ID_PART_ENTRY_UUID=bccde74f-efee-4b99-860c-998493d549a9 > > it will create by-partuuid under /dev/disk/ for the partition in array > > # ls /dev/disk/by-partuuid/ -all > lrwxrwxrwx 1 root root 13 Mar 22 03:33 018496b3-84e1-4c9f-864e-81650b21402f -> ../../md126p1 > lrwxrwxrwx 1 root root 13 Mar 22 03:33 2c1df1c5-41c8-42b4-a874-95dbf07820d5 -> ../../md126p2 > lrwxrwxrwx 1 root root 13 Mar 22 03:33 bccde74f-efee-4b99-860c-998493d549a9 -> ../../md126p3 > > if my rootfs store in /dev/md126p2, then I can specify root=PARTUUID=2c1df1c5-41c8-42b4-a874-95dbf07820d5 > through command line to boot it. > Thanks. I was thinking that udev-md-raid-arrays.rule only dealt with the whole array and that other files like 60-persistent-storage.rules dealt with parititons, but I was wrong. 60-persistent-storage.rules has KERNEL!="loop*|mmcblk*[0-9]|msblk*[0-9]|mspblk*[0-9]|nvme*|sd*|sr*|vd*|xvd*|bcache*|cciss*|dasd*|ubd*|scm*|pmem*|nb> so it doesn't touch md array. And udev-md-raid-arrays.rules already has ENV{DEVTYPE}=="partition", ENV{MD_NAME}=="?*", SYMLINK+="disk/by-id/md-name-$env{MD_NAME}-part%n", OPTIONS+="string_escape=replace" ENV{DEVTYPE}=="partition", ENV{MD_UUID}=="?*", SYMLINK+="disk/by-id/md-uuid-$env{MD_UUID}-part%n" ENV{DEVTYPE}=="partition", ENV{MD_DEVNAME}=="*[^0-9]", SYMLINK+="md/$env{MD_DEVNAME}%n" ENV{DEVTYPE}=="partition", ENV{MD_DEVNAME}=="*[0-9]", SYMLINK+="md/$env{MD_DEVNAME}p%n" so it does handle partitions of md array. So yes, your patch does make sense. Reviewed-by: NeilBrown <neilb@xxxxxxxx> Thanks, NeilBrown
Attachment:
signature.asc
Description: PGP signature