Jump to content

Stuck - passing through disk


El Gabito

Recommended Posts

Alright - I'm stuck and can't figure this out. I have an Ubuntu VM that I'm trying to pass through a 2TB drive to. I have the "Unassigned Devices" plugin installed, I've mounted the drive, and added it to the VM. But where does it go? I don't see it mounted anywhere.

 

My Linux skills are pretty rusty so I could be doing something wrong. XML is below - I"m guessing something needs to be changed in there. This is what the GUI generated.

 

    <disk type='file' device='disk'>
      <driver name='qemu' type='raw' cache='writeback'/>
      <source file='/mnt/disks/WDC_WD20EFRX_68AX9N0_WD_WMC1T1957452/unifi-ubuntu/vdisk2.img'/>
      <backingStore/>
      <target dev='hdd' bus='virtio'/>
      <alias name='virtio-disk3'/>
      <address type='pci' domain='0x0000' bus='0x02' slot='0x04' function='0x0'/>
    </disk>

 

Link to comment

And here's the full XML just in case that's needed.

 

<domain type='kvm' id='2'>
  <name>unifi-ubuntu</name>
  <uuid>ba070313-d44f-a78b-c23f-2cfaacb41b4b</uuid>
  <metadata>
    <vmtemplate xmlns="unraid" name="Linux" icon="linux.png" os="linux"/>
  </metadata>
  <memory unit='KiB'>4194304</memory>
  <currentMemory unit='KiB'>4194304</currentMemory>
  <memoryBacking>
    <nosharepages/>
  </memoryBacking>
  <vcpu placement='static'>2</vcpu>
  <cputune>
    <vcpupin vcpu='0' cpuset='0'/>
    <vcpupin vcpu='1' cpuset='1'/>
  </cputune>
  <resource>
    <partition>/machine</partition>
  </resource>
  <os>
    <type arch='x86_64' machine='pc-q35-2.7'>hvm</type>
    <loader readonly='yes' type='pflash'>/usr/share/qemu/ovmf-x64/OVMF_CODE-pure-efi.fd</loader>
    <nvram>/etc/libvirt/qemu/nvram/ba070313-d44f-a78b-c23f-2cfaacb41b4b_VARS-pure-efi.fd</nvram>
  </os>
  <features>
    <acpi/>
    <apic/>
  </features>
  <cpu mode='host-passthrough'>
    <topology sockets='1' cores='2' threads='1'/>
  </cpu>
  <clock offset='utc'>
    <timer name='rtc' tickpolicy='catchup'/>
    <timer name='pit' tickpolicy='delay'/>
    <timer name='hpet' present='no'/>
  </clock>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>restart</on_crash>
  <devices>
    <emulator>/usr/local/sbin/qemu</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='raw' cache='writeback'/>
      <source file='/mnt/user/domains/unifi-ubuntu/vdisk1.img'/>
      <backingStore/>
      <target dev='hdc' bus='virtio'/>
      <boot order='1'/>
      <alias name='virtio-disk2'/>
      <address type='pci' domain='0x0000' bus='0x02' slot='0x03' function='0x0'/>
    </disk>
    <disk type='file' device='disk'>
      <driver name='qemu' type='raw' cache='writeback'/>
      <source file='/mnt/disks/WDC_WD20EFRX_68AX9N0_WD_WMC1T1957452/unifi-ubuntu/vdisk2.img'/>
      <backingStore/>
      <target dev='hdd' bus='virtio'/>
      <alias name='virtio-disk3'/>
      <address type='pci' domain='0x0000' bus='0x02' slot='0x04' function='0x0'/>
    </disk>
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/mnt/user/ISOs/ubuntu-16.04.2-server-amd64.iso'/>
      <backingStore/>
      <target dev='hda' bus='sata'/>
      <readonly/>
      <boot order='2'/>
      <alias name='sata0-0-0'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>
    <controller type='usb' index='0' model='ich9-ehci1'>
      <alias name='usb'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x7'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci1'>
      <alias name='usb'/>
      <master startport='0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0' multifunction='on'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci2'>
      <alias name='usb'/>
      <master startport='2'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x1'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci3'>
      <alias name='usb'/>
      <master startport='4'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x2'/>
    </controller>
    <controller type='sata' index='0'>
      <alias name='ide'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x1f' function='0x2'/>
    </controller>
    <controller type='pci' index='0' model='pcie-root'>
      <alias name='pcie.0'/>
    </controller>
    <controller type='pci' index='1' model='dmi-to-pci-bridge'>
      <model name='i82801b11-bridge'/>
      <alias name='pci.1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x1e' function='0x0'/>
    </controller>
    <controller type='virtio-serial' index='0'>
      <alias name='virtio-serial0'/>
      <address type='pci' domain='0x0000' bus='0x02' slot='0x02' function='0x0'/>
    </controller>
    <controller type='pci' index='2' model='pci-bridge'>
      <model name='pci-bridge'/>
      <target chassisNr='2'/>
      <alias name='pci.2'/>
      <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
    </controller>
    <interface type='bridge'>
      <mac address='52:54:00:44:62:58'/>
      <source bridge='br0'/>
      <target dev='vnet0'/>
      <model type='virtio'/>
      <alias name='net0'/>
      <address type='pci' domain='0x0000' bus='0x02' slot='0x01' function='0x0'/>
    </interface>
    <serial type='pty'>
      <source path='/dev/pts/0'/>
      <target port='0'/>
      <alias name='serial0'/>
    </serial>
    <console type='pty' tty='/dev/pts/0'>
      <source path='/dev/pts/0'/>
      <target type='serial' port='0'/>
      <alias name='serial0'/>
    </console>
    <channel type='unix'>
      <source mode='bind' path='/var/lib/libvirt/qemu/channel/target/domain-2-unifi-ubuntu/org.qemu.guest_agent.0'/>
      <target type='virtio' name='org.qemu.guest_agent.0' state='disconnected'/>
      <alias name='channel0'/>
      <address type='virtio-serial' controller='0' bus='0' port='1'/>
    </channel>
    <input type='tablet' bus='usb'>
      <alias name='input0'/>
      <address type='usb' bus='0' port='2'/>
    </input>
    <input type='mouse' bus='ps2'>
      <alias name='input1'/>
    </input>
    <input type='keyboard' bus='ps2'>
      <alias name='input2'/>
    </input>
    <graphics type='vnc' port='5900' autoport='yes' websocket='5700' listen='0.0.0.0' keymap='en-us'>
      <listen type='address' address='0.0.0.0'/>
    </graphics>
    <video>
      <model type='qxl' ram='65536' vram='65536' vgamem='16384' heads='1' primary='yes'/>
      <alias name='video0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
    </video>
    <hostdev mode='subsystem' type='usb' managed='no'>
      <source>
        <vendor id='0x13d3'/>
        <product id='0x3393'/>
        <address bus='4' device='3'/>
      </source>
      <alias name='hostdev0'/>
      <address type='usb' bus='0' port='1'/>
    </hostdev>
    <memballoon model='virtio'>
      <alias name='balloon0'/>
      <address type='pci' domain='0x0000' bus='0x02' slot='0x05' function='0x0'/>
    </memballoon>
  </devices>
  <seclabel type='none' model='none'/>
  <seclabel type='dynamic' model='dac' relabel='yes'>
    <label>+0:+100</label>
    <imagelabel>+0:+100</imagelabel>
  </seclabel>
</domain>

 

Link to comment
root@unifi-ubuntu:/# fdisk -l /dev/hdd
fdisk: cannot open /dev/hdd: No such file or directory

root@unifi-ubuntu:/# df
Filesystem                         1K-blocks    Used Available Use% Mounted on
udev                                 2001368       0   2001368   0% /dev
tmpfs                                 404308    5776    398532   2% /run
/dev/mapper/unifi--ubuntu--vg-root  15350768 9858932   4689020  68% /
tmpfs                                2021524       0   2021524   0% /dev/shm
tmpfs                                   5120       0      5120   0% /run/lock
tmpfs                                2021524       0   2021524   0% /sys/fs/cgroup
/dev/vda2                             483946  122537    336424  27% /boot
/dev/vda1                             523248    3472    519776   1% /boot/efi
tmpfs                                 606460       0    606460   0% /var/cache/unifi-video
tmpfs                                 404308       0    404308   0% /run/user/1000

 

Link to comment

To be honest, its not clear what you are trying to achieve here. Can you explain?

 

From your original post, you say you want to pass a 2TB drive through to the VM, but the XML suggests you are trying to use a image file as a disk for your VM and that image file is what resides on the 2tb disk; these are two different concepts...

 

Are you trying to setup a UniFi controller?

If so, you could always just use the docker version; works great when installed from the community apps plugin...

 

Link to comment
On 6/4/2017 at 7:02 AM, DeeGee said:

To be honest, its not clear what you are trying to achieve here. Can you explain?

 

From your original post, you say you want to pass a 2TB drive through to the VM, but the XML suggests you are trying to use a image file as a disk for your VM and that image file is what resides on the 2tb disk; these are two different concepts...

 

Are you trying to setup a UniFi controller?

If so, you could always just use the docker version; works great when installed from the community apps plugin...

 

I'm setting up a Unifi Video controller, which I'm not sure there's a container for. 

 

But yes, the problem is I can't figure out to pass the raw disk through which is all I want. The paths that show "by-id" I could never get to work. If you have any insight into the correct way to do it, that'd be great.

 

Thanks!

Link to comment

I'm not at home right now, but try this (from memory, so backup your XML first :) )

 

you need to unmount the disk in unassigned-devices plugin first.

 

<disk type='block' device='disk'>

        <source dev='/dev/disk/by-id/ WDC_WD20EFRX_68AX9N0_WD_WMC1T1957452' />

        <target dev='hdd' bus='virtio' />

</disk>

 

Link to comment
  • 3 months later...
On 6/5/2017 at 11:59 AM, DeeGee said:

I'm not at home right now, but try this (from memory, so backup your XML first :) )

 

you need to unmount the disk in unassigned-devices plugin first.

 

<disk type='block' device='disk'>

        <source dev='/dev/disk/by-id/ WDC_WD20EFRX_68AX9N0_WD_WMC1T1957452' />

        <target dev='hdd' bus='virtio' />

</disk>

 

 

 

Ok, I'm FINALLY getting back to this. I edited the XML to reflect this, but I get the following error:

 

Cannot access storage file '/dev/disk/by-id/WDC_WD20EFRX-68AX9N0_WD-WMC1T1957452' (as uid:0, gid:100): No such file or directory

 

Any thoughts? 

Link to comment

Nevermind - I THINK I have this working!

 

I found this post which led me to this command to get the id:

 

ls /dev/disk/by-id

I was getting the previously mentioned drive label from the GUI, when I run this command it is prefixed by "ata-" 

 

Once I corrected that, it seems to be working!

 

Thanks for sending me down the right track.

Link to comment
  • 2 months later...

Bumping this again - it worked Sept 23, the day I posted, then stopped working. Somehow the device is becoming unmounted. When I edit fstab to try to auto-mount it at boot, it causes the VM to not boot and I have to remove it. Do I have something wrong with my syntax here?

 

/dev/sda1    /data   ext3    defaults     0        2

 

How can I get it to auto-mount at boot? 

 

Is /dev/sda1 wrong maybe? 

 

~$sudo lsblk -o NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL
NAME                         FSTYPE       SIZE MOUNTPOINT LABEL
sr0                          iso9660      829M            Ubuntu-Server 16.04.2 LTS amd64
vda                                        40G
├─vda1                       vfat         512M /boot/efi
├─vda2                       ext2         488M /boot
└─vda3                       LVM2_member   19G
  ├─unifi--ubuntu--vg-root   ext4          15G /
  └─unifi--ubuntu--vg-swap_1 swap           4G [SWAP]
vdb                                       1.8T
└─vdb1                       xfs          1.8T

Should I be using /vdb/vdb1 instead?

 

If it's not clear - I'm sort of a noob when it comes to this stuff...

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...