13.3.2. Adding Hard Drives and Other Block Devices to a Guest

Latest response

I've read this:

Important
Guest virtual machines should not be given write access to whole disks or block devices (for example, /dev/sdb). Guest virtual machines with access to whole block devices may be able to modify volume labels, which can be used to compromise the host physical machine system. Use partitions (for example, /dev/sdb1) or LVM volumes to prevent this issue.

and I've read a view posts from:
KVM Pass through disk Partition - By Label or UUID
Hard drive passthrough
Add physical disk to KVM virtual machine

and did this,

<disk type="block" device="disk">
  <driver name="qemu" type="raw"/>
  <source dev="/dev/disk/by-uuid/92E8-A359"/>
  <target dev="sdf" bus="sata"/>
  <boot order="2"/>
  <alias name="sata0-0-1"/>
  <address type="drive" controller="0" bus="0" target="0" unit="1"/>
</disk>

and added a secondary drive:

<disk type="file" device="disk">
  <driver name="qemu" type="qcow2"/>
  <source file="/home/administrator/StorageVolII/images/sle15sp2OfficeHD2.qcow2"/>
  <target dev="sdc" bus="sata"/>
  <boot order="3"/>
  <address type="drive" controller="0" bus="0" target="0" unit="2"/>
</disk>

However I get this error when trying to start:

Error starting domain: Cannot access storage file '/dev/disk/by-uuid/92E8-A359': No such file or directory

Traceback (most recent call last):
  File "/usr/share/virt-manager/virtManager/asyncjob.py", line 75, in cb_wrapper
    callback(asyncjob, *args, **kwargs)
  File "/usr/share/virt-manager/virtManager/asyncjob.py", line 111, in tmpcb
    callback(*args, **kwargs)
  File "/usr/share/virt-manager/virtManager/object/libvirtobject.py", line 66, in newfn
    ret = fn(self, *args, **kwargs)
  File "/usr/share/virt-manager/virtManager/object/domain.py", line 1279, in startup
    self._backend.create()
  File "/usr/lib64/python3.6/site-packages/libvirt.py", line 1234, in create
    if ret == -1: raise libvirtError ('virDomainCreate() failed', dom=self)
libvirt.libvirtError: Cannot access storage file '/dev/disk/by-uuid/92E8-A359': No such file or directory

and checking the disk information with Disks, the information is no longer valid. So, how do you set this up correctly?

Responses

92E8-A359 isn't the sort of UUID normally in /dev/disk/by-uuid/. Perhaps you have used the partition ID which is a different thing.

Look in /dev/disk/by-uuid/ at the IDs there.

You can tie a disk to its UUID with ls -l /dev/disk/by-uuid/ or blkid. eg:

$ sudo ls -l /dev/disk/by-uuid/
aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee -> ../../sda1

$ sudo blkid
/dev/sda1: UUID="aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee" TYPE="ext4" PARTUUID="abcdefgh-01"

Thanks Jamie, after reformatting the drive and using by-label, completing the installation I get the same error:

Error starting domain: Cannot access storage file '/dev/disk/by-label/SLE-15': No such file or directory

Traceback (most recent call last):
  File "/usr/share/virt-manager/virtManager/asyncjob.py", line 75, in cb_wrapper
    callback(asyncjob, *args, **kwargs)
  File "/usr/share/virt-manager/virtManager/asyncjob.py", line 111, in tmpcb
    callback(*args, **kwargs)
  File "/usr/share/virt-manager/virtManager/object/libvirtobject.py", line 66, in newfn
    ret = fn(self, *args, **kwargs)
  File "/usr/share/virt-manager/virtManager/object/domain.py", line 1279, in startup
    self._backend.create()
  File "/usr/lib64/python3.6/site-packages/libvirt.py", line 1234, in create
    if ret == -1: raise libvirtError ('virDomainCreate() failed', dom=self)
libvirt.libvirtError: Cannot access storage file '/dev/disk/by-label/SLE-15': No such file or directory

[administrator@rhelserver disk]$ sudo ls -l by-id

.
..
...
lrwxrwxrwx. 1 root root 10 Feb 16 18:42 ata-ST2000DM008-2FR102_ZFL2KJV6-part1 -> ../../sdf1
lrwxrwxrwx. 1 root root 10 Feb 16 18:42 scsi-0ATA_ST2000DM008-2FR1_ZFL2KJV6-part1 -> ../../sdf1
lrwxrwxrwx. 1 root root 10 Feb 16 18:42 scsi-1ATA_ST2000DM008-2FR102_ZFL2KJV6-part1 -> ../../sdf1
lrwxrwxrwx. 1 root root 10 Feb 16 18:42 scsi-35000c500c6a58c2b-part1 -> ../../sdf1
lrwxrwxrwx. 1 root root 10 Feb 16 18:42 wwn-0x5000c500c6a58c2b-part1 -> ../../sdf1

[administrator@rhelserver disk]$ sudo ls -l by-label

.
..
...
lrwxrwxrwx. 1 root root 10 Feb 16 18:42 SLE-15 -> ../../sdf1

[administrator@rhelserver disk]$ sudo ls -l by-path

.
..
...
lrwxrwxrwx. 1 root root  9 Feb 16 18:37 pci-0000:00:17.0-ata-6 -> ../../sdf
lrwxrwxrwx. 1 root root 10 Feb 16 18:42 pci-0000:00:17.0-ata-6-part1 -> ../../sdf1

[administrator@rhelserver disk]$ sudo ls -l by-uuid

.
..
...
lrwxrwxrwx. 1 root root 10 Feb 16 18:42 3F3A-A69E -> ../../sdf1

This was the id it gave me after formatting but, after installation the uuid is missing according to Disks.

[administrator@rhelserver disk]$ sudo ls -l by-partuuid

.
..
...
lrwxrwxrwx. 1 root root 10 Feb 16 18:42 dd2a3efb-01 -> ../../sdf1

[administrator@rhelserver disk]$ sudo fdisk -l

.
..
...
Disk /dev/sdf: 1.8 TiB, 2000398934016 bytes, 3907029168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0xdd2a3efb

Device     Boot Start        End    Sectors  Size Id Type
/dev/sdf1        2048 3907028991 3907026944  1.8T  c W95 FAT32 (LBA)

[administrator@rhelserver disk]$ sudo sfdisk -l

.
..
...
Disk /dev/sdf: 1.8 TiB, 2000398934016 bytes, 3907029168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0xdd2a3efb

Device     Boot Start        End    Sectors  Size Id Type
/dev/sdf1        2048 3907028991 3907026944  1.8T  c W95 FAT32 (LBA)

[administrator@rhelserver disk]$ lsblk

NAME                                          MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
.
..
...
sdf                                             8:80   0   1.8T  0 disk  
└─sdf1                                          8:81   0   1.8T  0 part

So, where was the installation performed and no success in getting this done? According to above its still a FAT32 w/1.8T of disk space, this should have been wiped out and made into a XFS. I install SLE15 as XFS not BTFS.

Could this be problem:

<address type="drive" controller="0" bus="0" target="0" unit="5"/>

<controller type="sata" index="0">
  <address type="pci" domain="0x0000" bus="0x00" slot="0x1f" function="0x2"/>
</controller>

It looks like you've formatted sdf1 as FAT32 with FAT label SLE-15, then you've passed that partition through to the VM and used the partition as an installation disk.

The VM installation has destroyed the FAT32 filesystem along with its label, but the host has not rescanned partitions so it still has a view of the "old" state of the filesystem.

If you want to pass through a partition, you might be better doing by-id such as <source dev='/dev/disk/by-id/ata-ST2000DM008-2FR102_ZFL2KJV6-part1'/>.

Really I'm not sure there's much value in passing the entire disk through like this. You might find it easier to create a regular XFS filesystem on sdf1, then mount it permanently somewhere on your hypervisor, then use that mount location as a dir storage pool in libvirt. The VM disk would then be a file in that directory. That would certainly make it easier to manage the VM disk if you ever need to move the VM off to shared storage or migrate to RHV or OpenStack.

That was my original intent; I have a drive setup that way with multiple VMs, but in attempting to install SLE-15-SP2-Full, it keeps taking 99% of 400GM (I increased it from 200GB). I'm not sure its its installing everything. Since it will be a Development VM (Visual Studio, KDevelope, Blender, Kdenlive, Gimp, etc.), I wanted to give it as much space as possible, so I decided to give its own 1.8TB drive.

I'll try the "by-id"......, but any suggestion for this type of setup?

It seems unlikely that any OS install with a few development tools would consume hundreds of gigabytes of disk space.

Depending on where you're viewing that space used, it could be that the VM filesystem writes across whatever disk size you give it, which is the expected behaviour when formatting a filesystem.

I expect sort of directory pool setup you already have would work fine with a 200G or 400G VM disk.

Hi Jamie,

A RH Satellite with a lot of Red Hat product can consume over a TB of disk space.

To get lesser disk latency a passthrough disk might be a solution.

Personally I have not tested this, still using Virtual IO disks.

Regards,

Jan Gerrit

A few things I needed to make adjustments on in order to successfully install SUSE WS, the default partitions; 1) /boot wasn't large enough; installing additional software I get a low space warning, 2) the separate home partition was only getting around 35GB 3) everything else was getting install in /run and etc. 4) I didn't need additional space for swap for suspending.

Therefor, partition was /, /boot, /swap. Mow its working normally and I was reading the disk usage wrong. The 99% was the free space available, but I needed more space for /home.