• Home
  • Disclaimer
  • Contact
  • Archives
  • About
  • Subscribe
  • Support
  • Advertise

Kernel Talks

Unix, Linux, & Cloud!

  • How-to guides
    • Howto
    • Disk management
    • Configurations
    • Troubleshooting
  • OS
    • HPUX
    • Linux
  • Miscellaneous
    • Software & Tools
    • Cloud Services
    • System services
    • Virtualization
  • Certification Preparations
    • AWS Certified Solutions Architect – Associate
    • AWS Certified Solutions Architect – Professional
    • AWS Certified SysOps Administrator – Associate
    • AWS Certified Cloud Practitioner
    • Certified Kubernetes Administrator
    • Hashicorp Certified Terraform Associate
    • Oracle Cloud Infrastructure Foundations 2020 – Associate
  • Tips & Tricks
  • Linux commands
You are here: Home / Howto

How to map Linux disk to vmware disk

Published: January 13, 2017 | Modified: June 20, 2020



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.

How to map linux vm disk to vmware disk

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!

⇠ Previous article
Ulimit value : All you need to know
Next article ⇢
How to establish passwordless ssh between two servers

Related stuff:

  • Root disk mirroring in itanium HPUX
  • How to disable direct root login on Linux & HPUX
  • How to list YUM repositories in RHEL / CentOS
  • How to find the process using high memory in Linux
  • How to convert JKS file to KEY file for Apache
  • Everything you need to know about the zombie process
  • Howto get CPU details in HPUX
  • How to install sar in SUSE Linux
  • 4 steps guide for SMTP configuration in HPUX
  • Highest size files in mount point
  • How to change timezone in Linux server (RedHat, CentOS, Ubuntu)
  • How to boot SPYRUS WorkSafe Pro Linux2Go drive

Filed Under: Howto Tagged With: how to identify linux vm disk, How to map linux vm disk to vmware, how to map vmware disk in linux VM, MAp linux VM disk to vmware, vmware disks and linux VM disks

If you like my tutorials and if they helped you in any way, then

  • Consider buying me a cup of coffee via paypal!
  • Subscribe to our newsletter here!
  • Like KernelTalks Facebook page.
  • Follow us on Twitter.
  • Add our RSS feed to your feed reader.

Comments

  1. Tadls says

    May 16, 2019 at 2:19 pm

    [quote]
    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.
    [/quote]

    If X = 1 then sg1+1 = Hard Disk 1 so, sg2 = HD1.
    BUT it seems to be not correct…
    I have 15 disks, one is 2.7TB, it is /dev/sdk (guest side),
    [code]
    sd 2:0:3:0: [sdk] Attached SCSI disk
    [code]
    [code]
    sd 2:0:3:0: Attached scsi generic sg10 type 0
    [code]
    So it should be VMware Hard Disk 11 (or 9 😉
    In fact, it is Hard Disk 3 (SCSI controller 1:3).

    Reply
  2. Richard Remington says

    May 22, 2019 at 10:38 pm

    There is also the lsscsi -g command available in CentOS7 but also installable in earlier versions.

    Reply
  3. Andre says

    May 26, 2020 at 12:44 am

    Linux “sg” devices start at “0” while VMWare hard disks start at “1”. So the formula would be sgX=Hard Dusk X+1.

    However, you cannot always rely on that either. On one of our Linux guests sg0 is a virtual CDROM and sg1 is HD1. So on that guest OS, the formula is sgX=Hard DiskX.

    The SCSI ID mapping descibed in the example indicates that a hard disk with SCSI 0:1 matches hardware address 0:0:1:0. This true, but “0” is the first number (not second) and “1” is the third. The first part of the SCSI ID is the SCSI controller number, which needs to be mapped to the guest OS “host number”. The way to determine this is to look at the contents of “/sys/class/scsi_host/host/unique_id”. If the SCSI ID is “2:5”, then find which “host” has unique_id equal to “2” (let’s say it is host4).

    So, the hard disk with SCSI ID “2:5” on the guest where the unique_id of host4 is “2” whihc have the hardware address “4:0:5:0”. That’s the way it works on RHEL6 at least.

    Reply

Share Your Comments & Feedback: Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Get fresh content from KernelTalks

  • Email
  • Facebook
  • RSS
  • Twitter

Get Linux & Unix stuff right into your mailbox. Subscribe now!

* indicates required

This work is licensed under a CC-BY-NC license · Privacy Policy
© Copyright 2016-2023 KernelTalks · All Rights Reserved.
The content is copyrighted to Shrikant Lavhate & can not be reproduced either online or offline without prior permission.