I would like to add a new drive to my Windows Guest (Windows Server 2016). Let's say D:

I can not use network share(SAMBA,etc...). It is why I am trying to add new storage device.

add in myVM.xml

    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/Windows.qcow2'/>
      <target dev='hda' bus='ide'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <target dev='hdb' bus='ide'/>
      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
=>    <disk type='block' device='disk'>
      <driver name='qemu' type='raw' cache='none' io='native'/>
      <source dev='/dev/disk/by-uuid/e3645a19-08dd-4ad4-8b0c-24a8a7e4962d'/>
      <target dev='hdc' bus='ide'/>
      <address type='drive' controller='0' bus='1' target='0' unit='0'/>
    <controller type='usb' index='0' model='ich9-ehci1'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x7'/>
    <controller type='usb' index='0' model='ich9-uhci1'>
      <master startport='0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0' multifunction='on'/>
    <controller type='usb' index='0' model='ich9-uhci2'>
      <master startport='2'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x1'/>
    <controller type='usb' index='0' model='ich9-uhci3'>
      <master startport='4'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x2'/>
    <controller type='pci' index='0' model='pci-root'/>
    <controller type='ide' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
    <controller type='virtio-serial' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>

-restart VM

=>Nevertheless no new hard drive in my Windows server guest

NB : harddrive is SSD nvme on PCIExpress,source dev=/dev/nvme0n1p1 (NTFS partionned).

How to add a harddrive/partition on Linux host (qemu configuration file) to be able to use it from my Windows Server Guest?



You don't say whether the original pre-existing disks in the guest XML are using IDE or SCSI or VirtIO. Since you do say Windows doesn't recognise the newly added VirtIO disk though, I'm going to presume that your existing disks are IDE or SCSI, and that Windows thus does not have the VirtIO drivers installed.

If this is the case, then you can either change the <target/> to use dev="hdb" bus="ide", or instead install the Windows VirtIO Drivers (https://docs.fedoraproject.org/en-US/quick-docs/creating-windows-virtual-machines-using-virtio-drivers/index.html). Note though I'm not 100% sure if the VirtIO drivers are supported on Windows 2016 as I've not tried such a new version of Windows myself.

| improve this answer | |
  • Harddrive is SSD nvme. so my source dev=/dev/nvme0n1p1. Bus is PCI-Express. But for test purpose in the first place any generic working solution would be fine. My windows guest is a Windows Server. – akira2x3x Apr 5 '19 at 11:51
  • That is what your host harddrive is. I was asking what your original guest harddrive is in the XML – DanielB Apr 5 '19 at 13:39
  • As I wasn't sure about what you ask, I send a part of the xml in the original post. NB : My Host and My Guest (qcow2) are in RAMDisk. I am using a physical hard drive for backup purpose of my windows Guest. – akira2x3x Apr 5 '19 at 14:10
  • Your XML shows you were using IDE for the original root disk. It isn't possible to hot-plug IDE disks using "virsh attach-device", so if you need that you'll have to use virtio and install the Windows virtio drivers. – DanielB Apr 5 '19 at 14:48
  • Thanks for your help. I am not using virsh attach-device anymore.(to clarify my problem I exclude it from my original post). I stay focused on qemu xml conf file. Windows Guest works fine (only C:(my image) an D:\cdrom appears) – akira2x3x Apr 5 '19 at 15:38

You made a virtual hardware change which requires the VM to be fully shut down (not just rebooted) before it takes effect.

BTW: For reasons of performance you should install the Virtio-SCSI driver in the guest OS, add the Virtio-SCSI controller to the virtual hardware, and convert your disks to use SCSI instead of IDE. And switch your virtual CDROM to SATA. Ideally you should have done this during installation; here is a guide for doing so.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.