Learn how to map Linux disk to vmware disk for virtual machine hosted on vmware. This ensures you are treating correct disk on virtualization layer.
Its always an challenge to identify correct disk physically when its being used in virtualization layer. Since disk or hardware is attached to Host physically and made visible to 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 post 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 direct command to see mapping of disks. In HP, both hardware (server), OS software (HPUX) and virtualization technology (iVM) all three products is owned/developed by HP. This makes it possible to integrate task in single command. Since vmware, Linux is not single vendor configuration, I think its noot yet possible to get things done with single line command.
To map vmware disks to Linux VM, we need to check and relate 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 to get disk SCSI id identified by kernel. This will show us disk names along with 4 numbers. Every disk has 4 numbers displayed in output. scsi, channel, id and lun. We are interested here in channel and id numbers.
For example: disk sda in above output has numbers 0:0:0:0 whereas disk sdb has 0:0:1:0. Look at second and third number i.e. 0:0:0:0 or 0:0:1:0. Sometimes you have to check first and third field to match numbers.
Now match this SCSI id with 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 guest from vmware in that case above method is not sufficient to identify disks. You have to 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 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!