In Azure, every VM has a persistent OS Disk that is used for booting the VM and contains the operating system. In addition to an OS disk, each VM also has a temporary disk that is present on the compute cluster hosting your VM.
Why is my OS disk not @ /dev/sda?
In most cases the OS disk is
/dev/sda but in some odd cases it is not. This is not an Azure specific issue but a default Linux behavior. The ordering in which Linux enumerates SCSI devices is nondeterministic. It scans SCSI devices in the order they appear on the PCI Bus. Therefore, whichever disk is enumerated first is
OK, so how to identify my disks?
To resolve this problem, use persistent naming. There are four ways to use persistent naming in Linux:
- filesystem label
Generally, it is recommend to use the filesystem label or UUID for Azure Linux VMs.
Let there be disks!
OS and temporary disks
When the Azure Linux agent is installed on a VM, the agent uses udev rules to construct a set of symbolic links under the
/dev/disk/azure path. There,
/dev/disk/azure is the first place you should look. Using this path, we can identify the different disk types attached to the VM as well the LUNs for data disks.
We can take a look at these symbolic links to identify the disks.
[email protected]:~$ ls -l /dev/disk/azure total 0 lrwxrwxrwx 1 root root 9 Apr 30 17:48 resource -> ../../sdb lrwxrwxrwx 1 root root 10 Apr 30 17:48 resource-part1 -> ../../sdb1 lrwxrwxrwx 1 root root 9 Apr 30 17:48 root -> ../../sda lrwxrwxrwx 1 root root 10 Apr 30 17:48 root-part1 -> ../../sda1 lrwxrwxrwx 1 root root 11 Apr 30 17:48 root-part14 -> ../../sda14 lrwxrwxrwx 1 root root 11 Apr 30 17:48 root-part15 -> ../../sda15 drwxr-xr-x 2 root root 120 Apr 30 22:24 scsi1
Based on the above output, we can identify the following disks and their paths:
/dev/disk/azure/root-part1- OS Disk
/dev/disk/azure-resource-part1- Temporary/Resource Disk
For data disks, we can use the tree command like shown below. Using this command, we can also identify the LUN numbers for the data disks
[email protected]:~$ tree /dev/disk/azure /dev/disk/azure ├── resource -> ../../sdb ├── resource-part1 -> ../../sdb1 ├── root -> ../../sda ├── root-part1 -> ../../sda1 ├── root-part14 -> ../../sda14 ├── root-part15 -> ../../sda15 └── scsi1 ├── lun0 -> ../../../sdc ├── lun0-part1 -> ../../../sdc1 ├── lun9 -> ../../../sdd └── lun9-part1 -> ../../../sdd1
Based on the above output, we can identify the following data disks and their LUNs
lun0-part1– Data Disk 1 mounted at LUN 0
lun9-part2– Data Disk 2 mounted at LUN 9
In Azure, the VM disks properties page looks like below
A disk by any other name
Now, we need to find how to refer to these disks in our scripts and applications. For that, we’ll run the following command
[email protected]:~$ sudo blkid -s UUID /dev/sdb1: UUID="420dd50e-9a61-4e26-9d24-5d399065ec52" /dev/sda1: UUID="eb5f4234-4e60-46a9-a0dc-76fd1a593cdd" /dev/sda15: UUID="D183-43BF" /dev/sdc1: UUID="27230452-56a6-4aba-9c90-77071488ece5" /dev/sdd1: UUID="28372da4-8adc-4be0-b1a8-7f51248f91ab"
With the above information, we can refer to our boot disk in the
ls command as follows
[email protected]:~$ ls -l /dev/disk/by-uuid/eb5f4234-4e60-46a9-a0dc-76fd1a593cdd lrwxrwxrwx 1 root root 10 Apr 30 17:48 /dev/disk/by-uuid/eb5f4234-4e60-46a9-a0dc-76fd1a593cdd -> ../../sda1
Reach out if you have any questions! Feel free to follow me on