Getting A CentOS6 VM On VMware ESXi Platform To Recognize A New Disk Device

Home » CentOS » Getting A CentOS6 VM On VMware ESXi Platform To Recognize A New Disk Device
CentOS 23 Comments

Hello all,

Is there a way to recognize a hot-plugged disk (i.e., to get the system to recognize it and build the appropriate /dev/sd* device for the new device)
without a reboot?

Thanks.

Boris.

23 thoughts on - Getting A CentOS6 VM On VMware ESXi Platform To Recognize A New Disk Device

  • Hi Boris, Just rescan the scsi host.
    #scsi-rescan #if you have sg3_utils package
    #lsscsi Or
    #echo “- – -” > /sys/class/scsi_host/host[n]/scan

    Julius

  • Hello Julius,

    Thanks – but it doesn’t seem to work.

    I installed sg3_utils and ran
    #scsi-rescan

    but that seemed to have done nothing for some reason.

    Cheers,

    Boris.

  • possibly dumb question, possibly unintentionally insulting your intelligence… you know that when he said “run # scsi-rescan” that meant ‘type in
    “scsi-rescan” as the root user’, right? and not ‘#scsi-rescan’?
    #anything will always appear to do nothing as the shell thinks you’re typing in a comment. I only ask because I’ve never seen anyone respond with “I ran #command”.

  • Zep,

    Thanks – nothing insulting about asking questions.

    I did run this command as root as I would never run stuff like this as any other user (or, perhaps, I’d use sudo if so forced).

    dmesg did not seem to detect the device addition, no.

    Cheers,

    Boris.

  • While I believe that this URL has technically correct advice, it’s basically doing a subset of the commands in the scsi-rescan script in the sg3_utils package.

    I wonder if you need to be running the vmware tools for the kernel to detect new devices?

  • It should work fine. What esxi version you are using?

    Eero
    4.11.2015 6.27 ip. “Boris Epstein” kirjoitti:

  • @Boris:
    If you have CentOS 6 + ESXi5.5, it should normally work fine. Have you retry the operation by adding another vDisk? monitor
    /var/log/messages

    Julius

    2015-11-04 17:34 GMT+01:00 Boris Epstein :

  • Am 04.11.2015 um 17:26 schrieb Boris Epstein:

    It usually works very nice here, Have you added only the disk or by accident another scsi controller?
    This happens (you probably know) if you select another bus while creating the disc.

    VG Rainer

  • Rainer,

    Thanks.

    It looks like I just created another disk on the same controller as I
    intended – and once I rebooted the VM it worked just fine – I got my disks
    (/dev/sda through /dev/sdd) accessible and functional.

    Cheers,

    Boris.

  • Boris Epstein wrote:
    My turn for a dumb question: from not paying a lot of attention to this thread, the answer isn’t clear to me: has the *host* recognized the disk?
    If not, the guest’s not going to see it.

    mark

  • Mark,

    IMO your question is not dumb at all. Unfortunately, I don’t have an answer to it.

    All I know is, you reboot the VM and it all works as expected.

    Cheers,

    Boris.

  • Boris Epstein wrote:

    Ok, if rebooting the VM, and *only* the VM, fixes it in the VM, then the host – the system the VM’s running on – knows about the drive. You see where I was going with that….

    mark

  • Mark,

    Absolutely, I see your point. This was the starting point – you add the device on the ESXi server, you reboot the VM, the VM sees the device, no problem. Now, I ask – do I have to reboot the VM? Logically I hope there ought to be a way for me not to have to do that – but I have yet to figure out how to get there.

    Boris.

  • vmware esxi 5.5.0 (free, using vsphere client to manage), vm is minimal CentOS 7 64bit. I added a 16gb vdisk and immediately see this in dmesg…

    [155484.386792] vmw_pvscsi: msg type: 0x0 – MSG RING: 1/0 (5)
    [155484.386796] vmw_pvscsi: msg: device added at scsi0:1:0
    [155484.388250] scsi 0:0:1:0: Direct-Access VMware Virtual disk 1.0 PQ: 0 ANSI: 2
    [155484.391275] sd 0:0:1:0: [sdb] 33554432 512-byte logical blocks:
    (17.1 GB/16.0 GiB)
    [155484.391552] sd 0:0:1:0: [sdb] Write Protect is off
    [155484.391556] sd 0:0:1:0: [sdb] Mode Sense: 61 00 00 00
    [155484.391593] sd 0:0:1:0: [sdb] Cache data unavailable
    [155484.391595] sd 0:0:1:0: [sdb] Assuming drive cache: write through
    [155484.396148] sdb: unknown partition table
    [155484.396356] sd 0:0:1:0: [sdb] Attached SCSI disk

    and lsblk shows…

    # lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
    sda 8:0 0 32G 0 disk
    …. sdb 8:16 0 16G 0 disk

    so I can immediately…

    # mkfs.xfs /dev/sdb meta-data=/dev/sdb isize=256 agcount=4, agsize=1048576 blks
    …..
    # mount /dev/sdb /mnt
    #

    (normally, I’d partition and lvm it, this is just for demo)
    I’m using a paravirtual scsi controller, and have previously installed open-vm-tools via yum.

    I then umounted it, and in vsphere deleted the vdisk and dmesg immediately shows…

    [155820.730477] vmw_pvscsi: msg type: 0x1 – MSG RING: 2/1 (5)
    [155820.730481] vmw_pvscsi: msg: device removed at scsi0:1:0
    [155820.754176] sd 0:0:0:0: Attached scsi generic sg0 type 0
    [155820.754247] sr 2:0:0:0: Attached scsi generic sg1 type 5

    I also did much the same with a CentOS 6.7 VM, also using a ‘paravirtual SCSI’ vm on the same esxi host, when I added the vdisk, it immediately shows…

    # dmesg
    ….. vmw_pvscsi: msg type: 0x0 – MSG RING: 1/0 (5)
    vmw_pvscsi: msg: device added at scsi0:1:0
    scsi 2:0:1:0: Direct-Access VMware Virtual disk 1.0 PQ: 0 ANSI: 2
    sd 2:0:1:0: Attached scsi generic sg2 type 0
    sd 2:0:1:0: [sdb] 33554432 512-byte logical blocks: (17.1 GB/16.0 GiB)
    sd 2:0:1:0: [sdb] Write Protect is off sd 2:0:1:0: [sdb] Mode Sense: 61 00 00 00
    sd 2:0:1:0: [sdb] Cache data unavailable sd 2:0:1:0: [sdb] Assuming drive cache: write through sd 2:0:1:0: [sdb] Cache data unavailable sd 2:0:1:0: [sdb] Assuming drive cache: write through
    sdb: unknown partition table sd 2:0:1:0: [sdb] Cache data unavailable sd 2:0:1:0: [sdb] Assuming drive cache: write through sd 2:0:1:0: [sdb] Attached SCSI disk

    # lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
    sr0 11:0 1 1024M 0 rom sda 8:0 0 16G 0 disk
    ├─sda1 8:1 0 500M 0 part /boot
    └─sda2 8:2 0 15.5G 0 part
    ├─vg_svfisc6test5-lv_root (dm-0) 253:0 0 9.6G 0 lvm /
    └─vg_svfisc6test5-lv_swap (dm-1) 253:1 0 5.9G 0 lvm [SWAP]
    sdb 8:16 0 16G 0 disk

    and I note this VM is *not* running vmware tools

    NEITHER of these two VMs required rebooting or any echo “- – -”
    >/sys/scsi/.. stuffs.


    john r pierce, recycling bits in santa cruz

  • Also, what guest OS and VM hardware version is the guest running as?

    Tris

    *************************************************************
    This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify postmaster@bgfl.org

    The views expressed within this email are those of the individual, and not necessarily those of the organisation
    *************************************************************

  • Tris, John,

    Thanks!

    I blew away the original VM I was using for testing as it came time to do the things for real in production – and, as much as I hated it, I just added the disk and rebooted the production machine to make it “see” that disk.

    However, I have then decided to investigate the matter further. So I
    created a new one. It is running on an ESXi 5.5 server, VM Version 10, VMware Paravirtual SCSI controller, configured for RedHat 6/64-bit OS, running CentOS 6/64 bit. And it worked perfectly when it came to “seeing” a hotplugged disk drive.

    So I am not sure what to make of all of it – but it looks like freshly created VM’s are OK and it was indeed something to do with the VM settings.

    Cheers,

    Boris.

  • Hello all,

    OK, looks like I have figured it out. It seems to be a matter of the SCSI
    bus emulation: things work fine with the Paravirtual but do not with the LSI Parallel.

    Good to know:)

    Thanks for all your help, everybody.

    Cheers,

    Boris.