[1c48007] | 1 | Purpose of rules file:
|
---|
| 2 |
|
---|
| 3 | This rules file provides nonvolatile, unique names (in the form of symlinks)
|
---|
| 4 | for various types of storage devices -- both IDE/ATA and SCSI.
|
---|
| 5 |
|
---|
| 6 |
|
---|
| 7 | Description of rules:
|
---|
| 8 |
|
---|
| 9 | First, similar to the 60-persistent-input.rules file, we skip the entire file
|
---|
| 10 | for uevents that this rules file should not apply to, as an optimization. The
|
---|
| 11 | file does not apply to removal uevents or non-block devices. It does not apply
|
---|
| 12 | to ramdisks, loopback-mount devices, floppy disks, netblock devices, or device-
|
---|
| 13 | mapper devices. It also should not apply to removable devices (that is, non-
|
---|
| 14 | partition devices with attributes named "removable" with the value "1", or
|
---|
| 15 | partition devices whose parents have "removable" set to "1" -- partition
|
---|
| 16 | kobjects don't have the "removable" attribute, only whole-disk kobjects do).
|
---|
| 17 |
|
---|
| 18 | For partition devices, we use the IMPORT{parent} option to pull in all the
|
---|
| 19 | environment variables that get set for the parent device. (The parent of a
|
---|
| 20 | partition device is the containing whole-disk device.) The IMPORT{parent}
|
---|
| 21 | option is documented in the udev(7) manpage, but basically the value that we
|
---|
| 22 | assign is used as a filter of environment variable names to import.
|
---|
| 23 |
|
---|
| 24 | Now, we start with rules to create by-ID symlinks (similar to the by-ID links
|
---|
| 25 | created for input devices). For hd* whole-disk devices (they're IDE/ATA, since
|
---|
| 26 | they start with hd), we run the ata_id program in --export mode. The ata_id
|
---|
| 27 | program requires a device node to be passed, so we also use the $tempnode Udev
|
---|
| 28 | variable -- this causes Udev to create a temporary device node somewhere and
|
---|
| 29 | substitute its name where $tempnode appears in the program command line.
|
---|
| 30 |
|
---|
| 31 | The ata_id program, in --export mode, prints several ID_* values. If we're
|
---|
| 32 | looking at a whole-disk device, and if ID_SERIAL is among those, we add a
|
---|
| 33 | symlink containing the device's ID_MODEL and ID_SERIAL values. If we're
|
---|
| 34 | looking at a partition device, we create an ID_MODEL- and ID_SERIAL-based
|
---|
| 35 | symlink also, but we add -partX to the end of the link name (where X is the
|
---|
| 36 | partition number).
|
---|
| 37 |
|
---|
| 38 | For SCSI devices, we first make some modifications to the environment. If the
|
---|
| 39 | device's kobject has a parent with a non-empty "ieee1394_id" attribute, then
|
---|
| 40 | the device is Firewire, so we set the ID_SERIAL environment variable to the
|
---|
| 41 | value of that attribute, and we set ID_BUS to "ieee1394". Now, if ID_SERIAL is
|
---|
| 42 | not set, we run usb_id, which (if this is a USB storage device) will print
|
---|
| 43 | various values. If ID_SERIAL is still unset, we run scsi_id with a set of
|
---|
| 44 | parameters designed to get an ID_SERIAL by querying the device itself. If that
|
---|
| 45 | still fails, we try running scsi_id in a mode that prints the information even
|
---|
| 46 | if the disk doesn't support so-called "vital product data" pages. If the
|
---|
| 47 | uevent is for a DASD device, we run dasd_id.
|
---|
| 48 |
|
---|
| 49 | If one of these *_id programs gave us an ID_SERIAL, then for whole-disk devices
|
---|
| 50 | we create a by-ID symlink using the ID_BUS and ID_SERIAL. For partition
|
---|
| 51 | devices, we create a by-ID symlink that has the same form except we add -partX
|
---|
| 52 | to the end (just like for IDE/ATA devices).
|
---|
| 53 |
|
---|
| 54 |
|
---|
| 55 | Now we have some rules to create by-path persistent symlinks. We start by
|
---|
| 56 | running the path_id program on the DEVPATH (%p) value. For whole-disk devices
|
---|
| 57 | and SCSI ROM type devices, we create a symlink directly, using the environment
|
---|
| 58 | variable ID_PATH, under the /dev/disk/by-path directory. But for SCSI tape
|
---|
| 59 | devices, we create a by-path symlink in the /dev/tape/by-path directory (we
|
---|
| 60 | base the symlink on the same information, though: the ID_PATH value printed by
|
---|
| 61 | path_id). Now, for both SCSI ROM and SCSI tape devices, we skip everything
|
---|
| 62 | that's left in the rules file (this is another optimization: neither SCSI ROM
|
---|
| 63 | nor SCSI tape devices have UUIDs, labels, or EDD information).
|
---|
| 64 |
|
---|
| 65 | For partition devices, we now create a by-path symlink of the same form as the
|
---|
| 66 | other partition device persistent symlinks (that is, with the same name as the
|
---|
| 67 | parent device, but with -partX added). We know that ID_PATH is set whenever it
|
---|
| 68 | applies, because we ran the path_id program on the parent device, and we did an
|
---|
| 69 | IMPORT{parent} on ID_* earlier in the rules file.
|
---|
| 70 |
|
---|
| 71 | Now we create by-label and by-uuid symlinks. These use properties of various
|
---|
| 72 | filesystems to generate a persistent name for a partition. For instance, if
|
---|
| 73 | you use the ext2 filesystem, you can use e2label to assign a label, and mke2fs
|
---|
| 74 | assigns a UUID when the filesystem is created. MS-DOS compatible filesystems
|
---|
| 75 | also assign a "UUID" (actually it's just a serial number, created based on the
|
---|
| 76 | date and time the partition was formatted, so it is not unique), which these
|
---|
| 77 | rules will also use. But for removable partitions, we skip the rules (for the
|
---|
| 78 | same reason as we skipped them above for removable disks).
|
---|
| 79 |
|
---|
| 80 | We run the vol_id program to get ID_FS_USAGE, ID_FS_UUID, and ID_FS_LABEL_SAFE
|
---|
| 81 | values. (vol_id supports other values as well, but we do not use them here.)
|
---|
| 82 | ID_FS_USAGE corresponds to the way the filesystem is supposed to be used; if it
|
---|
| 83 | gets set to "filesystem", "other", or "crypto", we create a symlink. If
|
---|
| 84 | ID_FS_UUID is set, we use it in a by-uuid symlink. If ID_FS_LABEL_SAFE is set,
|
---|
| 85 | we use it in a by-label symlink.
|
---|
| 86 |
|
---|
| 87 | Finally, we create EDD-based symlinks in the by-id directory. For whole-disk
|
---|
| 88 | devices, we run edd_id to get the EDD-generated ID string. (For partition
|
---|
| 89 | devices, we import this string from the parent.) If edd_id yields an ID_EDD
|
---|
| 90 | value, we use it in a symlink, for both whole disks and partitions.
|
---|
| 91 |
|
---|
| 92 |
|
---|
| 93 | The last rule in the file is merely a LABEL that various other rules use to
|
---|
| 94 | bypass the file (or the rest of the file) when needed.
|
---|
| 95 |
|
---|