How to Run OpenMediaVault with Pass-through Disks in VMWare ESXi

Assumptions:

1. The ESXi host in this lab is available with three (3) 1TB hard drives intended to be provisioned toward a NAS guest VM
2. There’s no data on any of the three disks referenced above – or any data on those devices have been approved for permanent deletion

Step 1: Install OpenMediaVault as a Guest VM

  • Download for the latest version of OpenMediaVault from this list: https://sourceforge.net/projects/openmediavault/files/
  • Access ESXi UI to add a new VM with Debian AMD64 as base OS type
    Install the OS/App using the wizard
  • Update the OS: sudo apt update -y && sudo apt upgrade -y
  • Note that the default credential is: admin / openmediavault
  • Change OpenMediaVault password with this command: omv-firstaid

Step 2: Remove Existing Disks (If necessary)

The following instruction is meant to work on any storage controller, regardless whether the host hardware would support “SCSI Inquiry Vital Data Product (VPD) page code 0x83” (source: https://kb.vmware.com/s/article/1017530). As long as ESXi has recognized the disks, then the ESXi OS would handle the hardware abstraction layer (HAL) to provide direct pointer access to attached disks from a guest virtual machine (VM).

# Check the list of mounted devices
[root@esx2:~] esxcli storage vmfs extent list
Volume Name  VMFS UUID                            Extent Number  Device Name                                                               Partition
-----------  -----------------------------------  -------------  ------------------------------------------------------------------------  ---------
ESX2-1TB     6009f013-14225b60-137f-309c2369d30b              0  t10.ATA_____Samsung_SSD_860_EVO_1TB_________________S3Z8NB0KB46308J_____          1
ESX2-500GB   6009f07e-d6fb7a24-a1e8-309c2369d30b              0  t10.ATA_____Samsung_SSD_850_PRO_512GB_______________S250NX0H835192J_____          1

# Remove a device
deviceId=t10.ATA_____Samsung_SSD_860_EVO_1TB_________________S3Z8NB0KB46308J_____
esxcli storage core device detached remove -d $deviceId

[root@esx2:~] esxcli storage filesystem list
Mount Point                                        Volume Name  UUID                                 Mounted  Type            Size          Free
-------------------------------------------------  -----------  -----------------------------------  -------  ------  ------------  ------------
/vmfs/volumes/6009f013-14225b60-137f-309c2369d30b  ESX2-1TB     6009f013-14225b60-137f-309c2369d30b     true  VMFS-6  999922073600  998307266560
/vmfs/volumes/6009f07e-d6fb7a24-a1e8-309c2369d30b  ESX2-500GB   6009f07e-d6fb7a24-a1e8-309c2369d30b     true  VMFS-6  511906414592  288623689728
/vmfs/volumes/bc795aee-3daf7d3d-ae7e-941f7427eeef               bc795aee-3daf7d3d-ae7e-941f7427eeef     true  vfat       261853184     105029632
/vmfs/volumes/262e2ce4-b8bb291a-491d-247b065bf27f               262e2ce4-b8bb291a-491d-247b065bf27f     true  vfat       261853184     261849088
/vmfs/volumes/601254aa-7b7f2998-78ed-309c2369d30b               601254aa-7b7f2998-78ed-309c2369d30b     true  vfat       299712512      92643328

# Unmount a volume
volumeName=ESX2-1TB
esxcli storage filesystem unmount -l $volumeName

[root@esx2:~] esxcli storage filesystem unmount -l $volumeName
Volume 'ESX2-1TB' cannot be unmounted. Reason: Busy

# Change the scratch location
# vim-cmd hostsvc/advopt/update ScratchConfig.ConfiguredScratchLocation string /tmp # use this option to place swap onto the same device as ESXi OS
newSwapDirectory=/vmfs/volumes/6009f07e-d6fb7a24-a1e8-309c2369d30b/swap
mkdir $newSwapDirectory
vim-cmd hostsvc/advopt/update ScratchConfig.ConfiguredScratchLocation string $newSwapDirectory
# Restart from cli
reboot

# Sample output
[root@esx2:~] vim-cmd hostsvc/advopt/view ScratchConfig.ConfiguredScratchLocation
(vim.option.OptionValue) [
   (vim.option.OptionValue) {
      key = "ScratchConfig.ConfiguredScratchLocation", 
      value = "/vmfs/volumes/6009f07e-d6fb7a24-a1e8-309c2369d30b/.locker"
   }
]
[root@esx2:~] vim-cmd hostsvc/advopt/update ScratchConfig.ConfiguredScratchLocation string /tmp
[root@esx2:~] vim-cmd hostsvc/advopt/view ScratchConfig.ConfiguredScratchLocation
(vim.option.OptionValue) [
   (vim.option.OptionValue) {
      key = "ScratchConfig.ConfiguredScratchLocation", 
      value = "/tmp"
   }
]

# List directories and total sizes
[root@esx2:~] df -h
Filesystem   Size   Used Available Use% Mounted on
VMFS-6     476.8G 209.0G    267.7G  44% /vmfs/volumes/ESX2-500GB
VMFS-6       0.0B   0.0B      0.0B   0% /vmfs/volumes/ESX2-1TB
vfat       249.7M 149.6M    100.2M  60% /vmfs/volumes/bc795aee-3daf7d3d-ae7e-941f7427eeef
vfat       249.7M   4.0K    249.7M   0% /vmfs/volumes/262e2ce4-b8bb291a-491d-247b065bf27f
vfat       285.8M 197.5M     88.4M  69% /vmfs/volumes/601254aa-7b7f2998-78ed-309c2369d30b
[root@esx2:~] du -sh *
4.0K	altbootbank
127.0M	bin
4.0K	bootbank
336.0K	bootpart.gz
224.0K	bootpart4kn.gz
6.0T	dev
14.0M	etc
40.4M	lib
173.5M	lib64
12.0K	local.tgz
4.0K	locker
116.0K	mbr
136.0K	opt
2.3M	proc
4.0K	productLocker
4.0K	sbin
4.0K	scratch
4.0K	store
627.2M	tardisks
4.0K	tardisks.noauto
1.7M	tmp
260.7M	usr
16.4M	var
209.4G	vmfs
12.0K	vmimages
4.0K	vmupgrade

# Unmount the same volume after reconnection
root@esx2:~] volumeName=ESX2-1TB
[root@esx2:~] esxcli storage filesystem unmount -l $volumeName
# no errors and no outputs

# Remove device
deviceId=t10.ATA_____Samsung_SSD_860_EVO_1TB_________________S3Z8NB0KB46308J_____
esxcli storage core device set --state=off -d $deviceId

# Verify that the specified Device ID is now missing from the list
[root@esx2:~] esxcli storage filesystem list
Mount Point                                        Volume Name  UUID                                 Mounted  Type            Size          Free
-------------------------------------------------  -----------  -----------------------------------  -------  ------  ------------  ------------
/vmfs/volumes/6009f07e-d6fb7a24-a1e8-309c2369d30b  ESX2-500GB   6009f07e-d6fb7a24-a1e8-309c2369d30b     true  VMFS-6  511906414592  287459770368
/vmfs/volumes/bc795aee-3daf7d3d-ae7e-941f7427eeef               bc795aee-3daf7d3d-ae7e-941f7427eeef     true  vfat       261853184     105025536
/vmfs/volumes/262e2ce4-b8bb291a-491d-247b065bf27f               262e2ce4-b8bb291a-491d-247b065bf27f     true  vfat       261853184     261849088
/vmfs/volumes/601254aa-7b7f2998-78ed-309c2369d30b               601254aa-7b7f2998-78ed-309c2369d30b     true  vfat       299712512      92643328

# Rescan all disks
esxcli storage core adapter rescan --all

# Reattach disk to storage core
deviceId=t10.ATA_____Samsung_SSD_860_EVO_1TB_________________S3Z8NB0KB46308J_____
esxcli storage core device set --state=on -d $deviceId
esxcli storage core adapter rescan --all
esxcli storage filesystem list

Step 3: Map Physical Disks to Guest VM

# Map four physical disks as vmdk files

# Check for available disks
ls -l /vmfs/devices/disks

# List existing volumes
ls -l /vmfs/volumes



# Configure the devices as an RDM's and generate the RDM pointer file at user-defined locations
# Map a device (physical disk) as a virtual disk
devicePath0=/vmfs/devices/disks/t10.ATA_____Samsung_SSD_840_EVO_1TB_________________S1D9NEAD705175N_____
targetVmdk0=/vmfs/volumes/604ef4d8-b2bcec6c-36bd-309c2369d30b/OpenMediaVault/nas_disk4.vmdk
vmkfstools -z $devicePath0 $targetVmdk0

targetVmdk1=/vmfs/volumes/604ef4d8-b2bcec6c-36bd-309c2369d30b/OpenMediaVault/nas_disk1.vmdk
deviceId1=t10.ATA_____Samsung_SSD_860_EVO_1TB_________________S3Z8NB0KB46308J_____
vmkfstools -z /vmfs/devices/disks/$deviceId1 $targetVmdk1
 
targetVmdk2=/vmfs/volumes/604ef4d8-b2bcec6c-36bd-309c2369d30b/OpenMediaVault/nas_disk2.vmdk
deviceId2=t10.ATA_____Samsung_SSD_870_QVO_1TB_________________S5VSNG0NA05357H_____
vmkfstools -z /vmfs/devices/disks/$deviceId2 $targetVmdk2
 
targetVmdk3=/vmfs/volumes/604ef4d8-b2bcec6c-36bd-309c2369d30b/OpenMediaVault/nas_disk3.vmdk
deviceId3=t10.ATA_____Samsung_SSD_870_QVO_1TB_________________S5VSNJ0NC00894D_____
vmkfstools -z /vmfs/devices/disks/$deviceId3 $targetVmdk3

[root@esx2:~] vim-cmd vmsvc/getallvms
Vmid           Name                                      File                                  Guest OS       Version   Annotation
1      OpenMediaVault         [ESX2-500GB] OpenMediaVault/OpenMediaVault.vmx               debian10_64Guest   vmx-15              
2      linux03                [ESX2-500GB] linux03/linux03.vmx                             ubuntu64Guest      vmx-15              
3      UbuntuServerTemplate   [ESX2-500GB] UbuntuServerTemplate/UbuntuServerTemplate.vmx   ubuntu64Guest      vmx-15

# Attach disk to guest VM
vmid=1
disk1=/vmfs/volumes/6009f07e-d6fb7a24-a1e8-309c2369d30b/OpenMediaVault/nas_disk1.vmdk
disk2=/vmfs/volumes/6009f07e-d6fb7a24-a1e8-309c2369d30b/OpenMediaVault/nas_disk2.vmdk
disk3=/vmfs/volumes/6009f07e-d6fb7a24-a1e8-309c2369d30b/OpenMediaVault/nas_disk3.vmdk
scsiControllerNumber=0
availableScsiSlot=1
vim-cmd vmsvc/device.diskaddexisting $vmid $disk1 0 1
vim-cmd vmsvc/device.diskaddexisting $vmid $disk1 $scsiControllerNumber $availableScsiSlot
vim-cmd vmsvc/device.diskaddexisting $vmid $disk2 $scsiControllerNumber $(($availableScsiSlot+1))
vim-cmd vmsvc/device.diskaddexisting $vmid $disk3 $scsiControllerNumber $(($availableScsiSlot+2))

# The above CLI commands don't work
[root@esx2:~] vim-cmd vmsvc/device.diskaddexisting $vmid $disk1 $scsiControllerNumber $availableScsiSlot
Reconfigure failed

# Use the GUI method to attach existing disks
Right click the virtual machine > Edit Settings > Add > Hard Disk > Use an existing virtual disk > Browse to the directory you saved the RDM pointer > select the RDM pointer file > Next > Repeat for additional pointers > click Finish to save changes

Configure Networking

# Check for network interfaces
root@MediaServer:/home/rambo# ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: ens192: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000
    link/ether 00:0c:29:20:47:32 brd ff:ff:ff:ff:ff:ff
 
# Configure networking
cat > /etc/netplan/ens192.yaml <<EOF
### Sample content ###
network:
  version: 2
  renderer: networkd
  ethernets:
    ens192:
      dhcp4: false
      addresses: [10.10.10.###/24]
      gateway4: 10.10.10.1
      nameservers:
        addresses: [8.8.8.8,1.1.1.1]
#######################
EOF
 
# Apply new network configuration
sudo netplan apply

Leave a Reply

Your email address will not be published. Required fields are marked *