Saturday, November 20, 2021

Installing Proxmox on Poweredge R320 and TrueNAS as virtual machine

I recently got myself a used Dell Poweredge R320 rack server. I was thinking of installing Ubuntu Server on it, then running virtual machines on top of that. But after a bit of research, I realised that it is best to have a hypervisor, and run several virtual machines on it. The hypervisor I chose was Proxmox, which can be downloaded and used without having to pay for a subscription.

It is actually quite straightforward to install. Download the ISO image from Proxmox's website, burn it onto a USB thumbdrive, then boot up the rack server using the thumbdrive. I chose to install it onto a 500GB SSD which I had. This will also be the disk that I use to store my virtual machines.

Once Proxmox has been installed, I decided to install TrueNAS to manage the storage disks. This is actually quite straightforward too. Download the ISO from TrueNAS's website, and then upload the ISO onto Proxmox (under the Storage section of the "local" disk). This will then allow you to choose the ISO when creating a virtual machine. I allocated 50GB for TrueNAS. The tricky part was to pass the harddisks to the virtual machine. At first, I tried to pass the entire RAID controller, but this just ended up in a lot of disk corruption since my SSD is also connected to the RAID controller. In the end, I found out that I had to to pass each disk individually. I did this by using the following command, after creating the VM (but not starting it yet):

qm set 100 -virtio1 /dev/disk/by-id/scsi-xxxxxx
 
Here, "100" is for the VM number of TrueNAS, which, if the first VM installed on Proxmox, is usually given the number 100. "scsi-xxxxxx" is whatever the number assigned to the harddisk you want to pass through. You can actually see the list of attached harddisks under the "Disks" tab of the main Proxmox environment. There should be serial numbers listed which conforms to those you find under "/dev/disk/by-id". This allowed me to see my two storage HDD (2TB each) in TrueNAS, which I then used to set up a pool in mirror mode.

To install QEMU guest agent on a TrueNAS VM, follow the instructions here. First, on the "History" tab of the page, there should be a ZIP file to download. After downloading and expanding the ZIP file, copy its contents into the VM. What I did was the TrueNAS VM was already serving a SMB share, so I copied the contents there. After that, it is a matter of using the console to move the files to the right places and executing the required steps in the instructions.
Instructions replicated below.
  1. Make the required files executable by chmod +c qemu-ga and chmod +x qemu-guest-agent .
  2. Place virtio_console.ko in /boot/modules.
  3. Run kldload virtio_console.ko.
  4. Place qemu-ga in /usr/local/bin.
  5. Place qemu-guest-agent in /usr/local/etc/rc.d.
  6. Place qemu-guest-agent in another location of your choice. This will be a copy that is re-added to the rc.d directory each time TrueNAS boots.
  7. Create Tunables in the TrueNAS web UI. System -> Tunables.
    1. Variable=qemu_guest_agent_enable Value=YES Type=RC Enabled=yes
    2. Variable=qemu_guest_agent_flags Value=-d -v -l /var/log/qemu-ga.log Type=RC Enabled=yes
    3. Variable=virtio_console_load Value=YES Type=LOADER Enabled=yes
  8. Create Init/Shutdown Scripts in the TrueNAS web UI. Tasks -> Init/Shutdown Scripts.
    1. Type=Command Command=service qemu-guest-agent start When=POSTINIT Enabled=yes Timeout=10
    2. Type=Command Command=cp /[path to a local copy of qemu-guest-agent file] /usr/local/etc/rc.d When=PREINIT Enabled=yes Timeout=10
  9. Reboot TrueNAS.
Within TrueNAS, I also installed the Plex Media Server plugin. This allows me to stream videos from the storage HDDs. However, without a dedicated GPU, video transcoding uses CPU power, which can cause the fans to rev up and create a bit of noise. And 1U servers are not the quietest of rack servers...
 
Oh, I also managed to install Windows 11 as a virtual machine, but unfortunately, it is not possible to run Windows Subsystem for Linux (WSL) or Windows Subsystem for Android (WSA) inside a Win11 virtual machine. To activate Windows 11, you can follow this guide. I will get myself a proper key if I intend to use Windows 11; this is just a temporary solution for me to test to see if I want to move to Windows 11.

The rack server was originally sitting on top of a low shelf, but I used my Ender-3 to print some feet for it, and now, it is standing upright beside my main work desk.


Now to get myself a tower server... eyeing the T420 next. If I can get my hands on a cheap used one, then I will probably expand it with some RAM and run dual CPUs on it. Plus a couple of 4TB HDDs.

Note: To install Proxmox and run it from a PCIe SSD (or anything connected via PCIe, I guess), follow this guide or this guide.

No comments: