Installing a disk image with netcat!

Proxmox has this bizarre idea that the only possible way to install a Virtual Machine is from an ISO file. This completely eliminates disk images, such as are provided by OpenWRT or Volumio. So I really wanted to install Volumio, and I came up with a solution: upload a Knoppix image, boot that as the installer disc, and use dd on Knoppix to write the Volumio image file to the VM HD. This proved trickier than expected, as I had nowhere locally after booting Knoppix to store the downloaded image (couldn't use the VM HD ... going to over-write that ...). It occurred to me that I could use netcat - but I'd never used it before, and didn't even know where to start. I was encouraged and assisted by my friend Scott, and the method we used follows.

  • check the IP of the receiving machine (the VM):
  • check the HD to be written to: /dev/sda (then double-check if there's more than one possible target!)
  • choose an arbitrary port that's not in use on the receiving machine: 1234
  • check the name of the image file on your source machine: volumio-2.004-2016-10-14-x86.img
  • set up the VM to receive: nc -l -p 1234 > /dev/sda (run this first)
  • transmit the file from the source machine: nc -w 3 1234 < volumio-2.004-2016-10-14-x86.img (run this second)

Most of the settings should be clear from the context, but some that aren't (man netcat is your friend): -l means "listen," or "I'm waiting for data to be sent to me." -w sets a timeout, in this case three seconds. Sadly netcat gives no progress indicators at all on either end: we just had to wait a couple minutes until it completed transfer and writing of a 3.5G file. I asked "but don't we need to send this through dd?" Nope: /dev/sda is a file - even though it's a device. That's Unix for you: just write the file straight to the device. One gotcha to consider is that transmission is unencrypted - not a big problem when streaming widely available disc images, but this probably isn't a good way to transmit private information (which would include VMs containing personal passwords).

But at this point, all that was required was a reboot and I had a working (mostly ... Proxmox doesn't provide its VMs with sound cards, and Volumio isn't much use without one - debugging session here) Volumio installation. So amazingly easy once you know how.