New udev rules simplify your life

The udev rules which come with the WALinuxAgent got modified as I had to learn. These new rules are really handy to figure out what disks are available and where they are mounted on. The rules are defined as follows

ACTION=="add|change", SUBSYSTEM=="block", ENV{ID_VENDOR}=="Msft", ENV{ID_MODEL}=="Virtual_Disk", GOTO="azure_disk"


# Root has a GUID of 0000 as the second value
# The resource/resource has GUID of 0001 as the second value
ATTRS{device_id}=="?00000000-0000-*", ENV{fabric_name}="root", GOTO="azure_names"
ATTRS{device_id}=="?00000000-0001-*", ENV{fabric_name}="resource", GOTO="azure_names"
# Wellknown SCSI controllers
ATTRS{device_id}=="{f8b3781a-1e82-4818-a1c3-63d806ec15bb}", ENV{fabric_scsi_controller}="scsi0", GOTO="azure_datadisk"
ATTRS{device_id}=="{f8b3781b-1e82-4818-a1c3-63d806ec15bb}", ENV{fabric_scsi_controller}="scsi1", GOTO="azure_datadisk"
ATTRS{device_id}=="{f8b3781c-1e82-4818-a1c3-63d806ec15bb}", ENV{fabric_scsi_controller}="scsi2", GOTO="azure_datadisk"
ATTRS{device_id}=="{f8b3781d-1e82-4818-a1c3-63d806ec15bb}", ENV{fabric_scsi_controller}="scsi3", GOTO="azure_datadisk"

# Retrieve LUN number for datadisks
ENV{DEVTYPE}=="partition", PROGRAM="/bin/sh -c 'readlink /sys/class/block/%k/../device|cut -d: -f4'", ENV{fabric_name}="$env{fabric_scsi_controller}/lun$result", GOTO="azure_names"
PROGRAM="/bin/sh -c 'readlink /sys/class/block/%k/device|cut -d: -f4'", ENV{fabric_name}="$env{fabric_scsi_controller}/lun$result", GOTO="azure_names"

# Create the symlinks
ENV{DEVTYPE}=="disk", SYMLINK+="disk/azure/$env{fabric_name}"
ENV{DEVTYPE}=="partition", SYMLINK+="disk/azure/$env{fabric_name}-part%n"


What do they do compared to what we were used to? Instead of the just having two symbolic links to the os-disk and the ephemeral-disk in /dev/disk/azure

resource -> ../../sdb
root -> ../../sda

the new rules provide you also information about the partition available on the root -disk and ephemeral-disk. And also information about attached data-disks

resource -> ../../sdb
resource-part1 -> ../../sdb1
root -> ../../sda
root-part1 -> ../../sda1
root-part2 -> ../../sda2
   lun0 -> ../../../sdc
   lun0-part1 -> ../../../sdc1

These available symbolic links in /dev/disk/azure allow you to create scripts in a more agnostic way. If you had previously referenced your /dev/sdc just as /dev/sdc, which may lead to trouble the first time you start a VM, you can simply reference it as /dev/disk/azure/scsi1/lun0 and can be sure you hit exactly the disk as intended. I encourage you therefore to update the WALinuxAgent or install at least the new rules.



Comments (0)

Skip to main content