Automatic Device Mappings for Partitions and File Systems

Device mappings are handled automatically on Oracle Linux, by the kernel and the udev service. In the case of disk devices, the kernel automatically creates device mappings for disks and their partitions using a non persistent naming scheme in the form of /dev/sdxy, for example /dev/sda1. A problem with this approach is that the device naming scheme depends on the order in which devices are detected, which means that device names can change easily. Typically, device names change when changes to the boot process exist or when storage devices or their related controllers fail.

Avoid using the non persistent disk or partition names when configuring mount points in /etc/fstab.

Udev is a subsystem that works with the kernel to monitor hardware or device changes and manages events related to changes. Storage devices, partitions, and file systems are all allocated unique identifiers that the udev subsystem can read and use to automatically configure device mappings that you can use to identify the device or partition that you intend to work use. Device mappings for storage devices managed by udev are stored in /dev/disks and you can identify a device by various identifiers, including the unique partition UUID, file system UUID, or the partition label. For instructions about obtaining UUID information, see Listing Device Mapping Information.

When configuring mount points in /etc/fstab, use the file system UUID or, if set, the partition label, for example:

UUID=8980b45b-a2ce-4df6-93d8-d1e72f3664a0 /boot   xfs     defaults        0 0
LABEL=home  /home  xfs  defaults 0 0

Note that because file systems can span multiple devices, defining mount points against the file system UUID is preferable to using a partition UUID or label. File system UUIDs are assigned when the file system is created and is stored as part of the file system itself. If you copy the file system to a different device, the file system retains the same file system UUID. However, if you reformat a device by using the mkfs command, the device loses the file system UUID and a new UUID is generated.

Listing Device Mapping Information

You can use the lsblk command to list device information for any block device attached to the system:

Tip:

Use the -o +UUID option to display the UUIDs for each device and partition listed, or use the -f option to get a display of important file system information.
lsblk -f

Output might appear as follows, indicating a tree of file system mappings:

NAME               FSTYPE      FSVER    LABEL UUID                                   FSAVAIL FSUSE% MOUNTPOINTS
sda                                                                                                 
├─sda1             vfat        FAT16          DDD4-C455                                94.5M     5% /boot/efi
├─sda2             xfs                        8980b45b-a2ce-4df6-93d8-d1e72f3664a0      1.5G    26% /boot
└─sda3             LVM2_member LVM2 001       LzsEPR-Mnbk-kQZY-eV3n-9u1T-lFXZ-x7ANgD                
  ├─ocivolume-root xfs                        26029274-0a04-4dc5-b794-2576b9a16884     28.6G    25% /
  └─ocivolume-oled xfs                        3cbc8301-6f0e-4947-bbe6-f3669b9e6985      9.9G     1% /var/oled

You can also use the udevadm info command to obtain information about any udev mappings on the system. For example:

sudo udevadm info /dev/sda3

Output might appear as follows, listing all the device links that udev has created for the device and any other information that udev has on the device:

P: /devices/pci0000:00/0000:00:04.0/virtio1/host2/target2:0:0/2:0:0:1/block/sda/sda3
N: sda3
L: 0
S: disk/by-partuuid/18b918a1-16ca-4a07-91c6-455c6dc59fac
S: oracleoci/oraclevda3
S: disk/by-id/wwn-0x60170f5736a64bd7accb6a5e66fe70ee-part3
S: disk/by-path/pci-0000:00:04.0-scsi-0:0:0:1-part3
S: disk/by-id/scsi-360170f5736a64bd7accb6a5e66fe70ee-part3
S: disk/by-id/lvm-pv-uuid-LzsEPR-Mnbk-kQZY-eV3n-9u1T-lFXZ-x7ANgD
E: DEVPATH=/devices/pci0000:00/0000:00:04.0/virtio1/host2/target2:0:0/2:0:0:1/block/sda/sda3
E: DEVNAME=/dev/sda3
E: DEVTYPE=partition
E: DISKSEQ=9
E: PARTN=3
E: MAJOR=8
E: MINOR=3
E: SUBSYSTEM=block
E: USEC_INITIALIZED=20248855
E: ID_SCSI=1
E: ID_VENDOR=ORACLE
E: ID_VENDOR_ENC=ORACLE\x20\x20
E: ID_MODEL=BlockVolume
E: ID_MODEL_ENC=BlockVolume\x20\x20\x20\x20\x20
E: ID_REVISION=1.0
E: ID_TYPE=disk
E: ID_SERIAL=360170f5736a64bd7accb6a5e66fe70ee
E: ID_SERIAL_SHORT=60170f5736a64bd7accb6a5e66fe70ee
E: ID_WWN=0x60170f5736a64bd7
E: ID_WWN_VENDOR_EXTENSION=0xaccb6a5e66fe70ee
E: ID_WWN_WITH_EXTENSION=0x60170f5736a64bd7accb6a5e66fe70ee
E: ID_BUS=scsi
E: ID_PATH=pci-0000:00:04.0-scsi-0:0:0:1
E: ID_PATH_TAG=pci-0000_00_04_0-scsi-0_0_0_1
E: ID_PART_TABLE_UUID=a0b1f7d8-e84b-461f-a016-c3fcfed369c3
E: ID_PART_TABLE_TYPE=gpt
E: ID_SCSI_INQUIRY=1
E: ID_FS_UUID=LzsEPR-Mnbk-kQZY-eV3n-9u1T-lFXZ-x7ANgD
E: ID_FS_UUID_ENC=LzsEPR-Mnbk-kQZY-eV3n-9u1T-lFXZ-x7ANgD
E: ID_FS_VERSION=LVM2 001
E: ID_FS_TYPE=LVM2_member
E: ID_FS_USAGE=raid
E: ID_PART_ENTRY_SCHEME=gpt
E: ID_PART_ENTRY_UUID=18b918a1-16ca-4a07-91c6-455c6dc59fac
E: ID_PART_ENTRY_TYPE=e6d6d379-f507-44c2-a23c-238f2a3df928
E: ID_PART_ENTRY_NUMBER=3
E: ID_PART_ENTRY_OFFSET=4401152
E: ID_PART_ENTRY_SIZE=100456415
E: ID_PART_ENTRY_DISK=8:0
E: SCSI_TPGS=0
E: SCSI_TYPE=disk
E: SCSI_VENDOR=ORACLE
E: SCSI_VENDOR_ENC=ORACLE\x20\x20
E: SCSI_MODEL=BlockVolume
E: SCSI_MODEL_ENC=BlockVolume\x20\x20\x20\x20\x20
E: SCSI_REVISION=1.0
E: SCSI_IDENT_LUN_NAA_REGEXT=60170f5736a64bd7accb6a5e66fe70ee
E: UDISKS_IGNORE=1
E: DEVLINKS=/dev/disk/by-partuuid/18b918a1-16ca-4a07-91c6-455c6dc59fac 
   /dev/oracleoci/oraclevda3
   /dev/disk/by-id/wwn-0x60170f5736a64bd7accb6a5e66fe70ee-part3 
   /dev/disk/by-path/pci-0000:00:04.0-scsi-0:0:0:1-part3
   /dev/disk/by-id/scsi-360170f5736a64bd7accb6a5e66fe70ee-part3
   /dev/disk/by-id/lvm-pv-uuid-LzsEPR-Mnbk-kQZY-eV3n-9u1T-lFXZ-x7ANgD
E: TAGS=:systemd:
E: CURRENT_TAGS=:systemd: