Learn how to map Linux disk to VMware disk for virtual machines hosted on VMware. This ensures you are treating the correct disk on the virtualization layer.
It’s always a challenge to identify the correct disk physically when it’s being used in the virtualization layer. Since disk or hardware is attached to the Host physically and made visible to the guest server. Any activity related to physical attribute which is to be done on guest machine seeks perfect mapping of hardware from guest to host. In other posts, we already explained mapping iVM disks to host disks in HPUX (HPUX virtualization). In this post, we will be seeing how to map Linux disk to VMware disk (VMware virtualization).
Like HPUX, we do not have a direct command to see the mapping of disks. In HP, both hardware (server), OS software (HPUX), and virtualization technology (iVM) all three products are owned/developed by HP. This makes it possible to integrate tasks into a single command. Since VMware, Linux is not a single vendor configuration, I think it’s not yet possible to get things done with single-line command.
To map VMware disks to Linux VM, we need to check and relate the SCSI id of disks.
In vmware :
Check VM settings and identify disk SCSI id.
As highlighted in above screenshot, identify your SCSI id. Here its 0:0
In Linux VM:
Now login to Linux VM and execute below command :
# dmesg | grep -i 'Attached SCSI disk'
Attached scsi disk sda at scsi0, channel 0, id 0, lun 0
Attached scsi disk sdb at scsi0, channel 0, id 1, lun 0
We are filtering disk messages from syslog at the boot, to get disk SCSI id identified by the kernel. This will show us disk names along with 4 numbers. Every disk has 4 numbers displayed in the output. SCSI, channel, id, and lun. We are interested here in channel and id numbers.
For example, disk sda
in the above output has numbers 0:0:0:0
whereas disk sdb
has 0:0:1:0
. Look at the second and third number i.e. 0:0:0:0
or 0:0:1:0
. Sometimes you have to check first and third fields to match numbers.
Now match this SCSI id with the id you got from VMware console (VM settings panel). 0:0
is matching that means disk sda
in Linux is what we are looking at in VMware Hard Disk 1.
Sometimes RDM disks are assigned to guests from VMware in that case above method is not sufficient to identify disks. You have another approach.
Get sg number from Linux VM :
# dmesg|grep sg |grep Attached
sr 0:0:0:0: Attached scsi generic sg0 type 5
sd 2:0:0:0: Attached scsi generic sg1 type 0
sd 2:0:1:0: Attached scsi generic sg2 type 0
This sgX
number is always less than one from VMware “Hard Disk X” number. So sgX+1=Hard Disk X. This means in Linux disk sg
starts with sg0
but in VMware it starts with Hard Disk 1. In the above example, sg1
will be Hard Disk 2 in VMware.
Match numbers accordingly and you will be able to map guest disk with vmware disk!
If you have any other method to get this task done, please drop us in comments!