Additional disk unaccessible in Virtual Machine

Scenario

The user is reporting that the additional disk in the exercise5 virtual machine does not show up in the lists when running the fdisk or lsblk command. The user would like to create a disk named exercise5-vol-data1 and mount it to the virtual machine named exercise5

Your task is to troubleshoot and resolve the issue so that the exercise5-vol-data1 disk is showing when the user runs the lsblk or fdisk command.

The steps to fix exercise5 are:

Console

  1. Login to OpenShift console using the assigned user account.

Username
userx
Password
{password}
  1. Go to Virtualization - VirtualMachines - Select the project for the assigned user account - look for VM called exercise5.

05 break01
  1. On exercise5 virtual machine click in ConfigurationStorage and check there’s an extra disk.

05 break02
  1. On left side menu, click HomeSearch and on Resources type DataVolume. Click on exercise5-vol-data1 DataVolume

05 break03
  1. Verify there’s an error message on Data Volume.

05 break04
  1. The storageClassName is misconfigured.

05 break05
  1. Click Actions and Delete DataVolume

05 break06
  1. Click Delete

05 break07
  1. Click on Create DataVolume button and paste the content to create a new Data Volume with the correct storageClassName

05 break08
  1. Paste the content of the new DataVolume with storageClassName fixed and click Create

apiVersion: cdi.kubevirt.io/v1beta1
kind: DataVolume
metadata:
  name: exercise5-vol-data1
spec:
  preallocation: false
  source:
    blank: {}
  storage:
    resources:
      requests:
        storage: 30Gi
    storageClassName: ocs-storagecluster-ceph-rbd
05 break09
  1. Wait for Data Volume status change to Succeeded

05 break10
  1. You can run the lab grade exercise5 command to validate the exercise.

Run grade to validate the exercise
lab grade exercise5

Command line (CLI)

  1. Login to Openshift server API using the assigned user account with oc command if not logged in.

OpenShift login command
{login_command}
  1. Go to the assigned namespace-userx

oc project namespace-userx
  1. List the virtual machines

oc get virtualmachine
  1. Check the additional data disk exercise5-vol-data1 Datavolume is empty

oc get datavolume
  1. Check the additional data disk exercise5-vol-data1 does not have no PersistentVolumeClaims associated

oc get pvc
  1. Check the configuration of exercise5-vol-data1 Datavolume and verify that there is a misconfigured defaultStorageClass

oc get datavolume exercise5-vol-data1 -n namespace-userx -o yaml
  1. Delete the the datavolume exercise5-vol-data1

oc delete datavolume exercise5-vol-data1
  1. Create again the DataVolume by using the storageClassName of ocs-storagecluster-ceph-rbd with the name exercise5-vol-data1 and using 30GiB size.

oc create -f - <<EOF
apiVersion: cdi.kubevirt.io/v1beta1
kind: DataVolume
metadata:
  name: exercise5-vol-data1
spec:
  preallocation: false
  source:
    blank: {}
  storage:
    resources:
      requests:
        storage: 30Gi
    storageClassName: ocs-storagecluster-ceph-rbd
EOF
  1. Check the status of exercise5-vol-data1 and wait for the additional disk to be provisioned

watch oc get pvc
  1. Go to virtual machine console of exercise5 and login using lab-user credential

virtctl console exercise5
  1. Check the disk availability using lsblk or fdisk -l command. The new additional disk from exercise5-vol-data1 should be there and ready to be format and mount by the user.

What you learned

In this exercise, you learned that disks are not presented to virtual machines until Persistent Volume Claims (PVCs) are created. To change the storageClassName of a data volume in OpenShift Virtualization, you need to delete the existing data volume and create a new one with the desired storage class.