Mining in a VM?

I have something to admit, and I shouldn’t be proud of it (according to gamers who want the graphics cards we need, of which I’m one): I’m a crytocurrency miner. I’ve done it on and off for years, but have been doing it 24/7 since December of 2017, and really got into it a year ago this month. My setup has changed a bit in that time, growing from 1 GTX 1050ti in September to 2 RX 580 GBs (plus the first card) in January, but compared to just about anything that comes up when you punch in “GPU mining” in Google it’s tiny. I’m also not going to mention the R9 390X that I blew a capacitor off of somehow, which I will hopefully fix one day. No, they haven’t made me rich, but they have paid for themselves as of this month. I don’t have a Lamborghini in the driveway, though I accept donations for one.

Anyway, the whole point of this post is to show that you don’t have to have a dedicated mining rig to make mining effective. If you happen to have an ESXi machine already setup that can handle your gpu, you can totally make it work in a few different ways.

Windows 10

Up until yesterday, the only OS I had ever used for mining was Windows. I used 7 back in college to mine a ton of still worthless Dogecoin, then 10 for the last year starting out with NiceHash then moving to Claymore. It’s easy to setup, easy to configure, free (as you don’t need to activate it for these purposes) but is far from the most stable platform to use, mainly for one reason: updates. They just don’t end. Even using O&O Shutup10, which is a fantastic tool that lets you disable damn near anything you don’t want inside Windows 10 to include tracking and automatic updates. Unfortunately for me, even after I ran this tool I was still getting stability problems with random reboots, freezing, and the occasional sneaky update which would take down the VM for a little while. It’s also a total pain to get Nvidia and AMD drivers to play nice together, compounded by the fact that they are in a virtualized environment.

This week, I finally got fed up with it and decided to move onto something a little more purpose built and flexible. There are a few different mining operating systems out there, but I decided to try Hive OS.

Hive OS

Hive OS is a dedicated, Linux-based mining operating system and includes all the video drivers you need for any relatively recent Nvidia or AMD GPU, plus almost every mining software you could need, plus a super slick online tool where you can remotely control your rigs. Plus, it’s free for up to 3 machines, which is perfect for me, as I only really need 1 VM for mining.

So, how easy is it to setup as a VM in ESXi? Not as easy as I thought, actually, but here’s what I had to do in case you want to embark on this adventure, too.

1. Create Hive OS account and download image

Go to their official website and sign up for an account. Setup 2FA if you want to be extra secure, then download the image. Since this is an .img file, we can’t directly use it with ESXi and will have to convert it. Also, make sure to setup a new rig and a wallet, of which there are a ton of good guides out there for.

2. Converting .img to .vmdk

I tried a bunch of different ways of doing this, including trying to convert the file to an .iso image, but the tool that ended up working for me was StarWind V2V Converter. It’s pretty straightforward and spits out a .vmdk file for you, which is a virtual hard disk file that ESXi uses for VMs.

3. Upload .vmdk to datastore

This part is pretty self-explanatory. Make sure you upload the correct file type, not the .img, which ESXi will not be able to use.

4. Create new VM using Hive OS .vmdk

Since we have an actual vmdk file to use instead of an .iso, the installation process is actually simpler. All we need to do is go through the process of creating a new VM, in this case I named it Hive OS, and instead of creating a new virtual hard disk we point it to the .vmdk file already on the datastore. To see these options, be sure to select Custom instead of Typical at the very beginning.

5

5. GPU Passthrough

Once you have the VM created and the .vmdk file added to it, you need to passthrough your graphics card(s) directly to the VM so you can mine. First, log into your ESXi server with vSphere and go to Configuration > Hardware > Advanced Settings > Edit.

1

You’ll see all of the devices that are available to passthrough now. Choose your GPU(s) then select OK. Note, if you only select one of the child boxes under your card, it’ll prompt you to select the parent device automatically.

2
Select the GPU(s) you want

Go ahead and power down all your VMs now, then reboot your server. You should now just have that generic warning shown in the first picture with the caution symbol. If there is something else there, look into it because I have no idea. Now go to Edit Settings for our Hive OS VM and click Add under the hardware tab.

3

Select PCI Device, which shouldn’t be grayed out and say available next to it, unlike my picture.

4
If it looks like this, it didn’t work

Now you should see the device(s) you selected in that huge drop down list earlier. Click on them again and finish out the device installer. Now you should see your GPU(s) listed under devices in your VM settings under the hardware tab.

If you are using AMD graphics cards, you’re done. If you’re using Nvidia cards, like I am in this guide, you have one more step. Go back to Edit Settings for the Hive OS VM and go to the Options tab, then click on General. When the VM is powered off, the Configuration Parameters button will be unlocked.

7

Scroll to the bottom of the list and click Add Parameter. Paste this in there, making sure to put the FALSE part in the proper column.

hypervisor.cpuid.v0 = "FALSE"

Save your changes and now you’re down setting up the hardware.

6. Configuring Hive OS

Boot up the VM and follow the prompts. It’ll ask you for your rig ID and password, both of which you get from your Hive OS account on the website. There are a bunch of commands you can run to reconfigure your miner if you mess it up or fat finger something, plus a network test utility, etc. Also, if you are unable to resolve your host name or talk to the internet like I was, make sure you actually connect a vnic to your host. Whoops.

To actually start mining, you can type miner start to get the party started, though it should get going on its own. Note, if you don’t plug in a monitor to the card(s) at some point before this, then unplug it, you won’t see any output through ESXi. Don’t panic, just check your Hive OS account and treat it like a headless machine. Luckily they give you some great tools to add custom settings like fan speeds, overclocks, power limits, and even things like a hashrate watchdog, which will automatically restart the miner after the harshrate drops below a threshold you specify.

Hive OS Any Good?

I’ve only been using this OS for about a day and a half, but it has already impressed me. It’s not crashing every 30 minutes, like my Windows 10 VM had been doing for the last week, and being able to manage it remotely through a website instead of TeamViewer sessions is amazing. Unless I run into some crazy issues in the next few weeks, I see exactly zero reason not to use this OS if it makes sense for your situation.

One thought on “Mining in a VM?

Comments are closed.