How to get llama 2 up and running , in a VM, with no GPU, and limited memory on Ubuntu

Image
OK I decided to write this up after unsuccessfully being able to find all the required info I needed in one place. In this setup we will be using Ubuntu Server 22.04.2 LTS as the OS. I have this running on a home lab ESXi server 8, on a HP Compaq Pro 6300 SFF CPU = Intel Core i7-3770 Installed Memory 16 GB I have some 10K SAS drives installed for the VM's If you have not already, navigate to  Get Ubuntu Server | Download | Ubuntu and download the 22.04.2 LTS ISO Next Lets create our VM that we are going to run this in. *Note Im using ESXi however you can probably do this in Workstation, Fusion, VirtualBox etc The main things to note on the VM creation. Set Ubuntu 64 bit as the guest OS Set your CPU relevant to the physicals CPU, I will be starting with 4 VCPU Set your Memory to as much as you can tolerate, I will be using 12 Disk Space - we are creating a 100G swap file, and the rest of the file can take up some room , so more is better if you can afford it Dont forget to add the U

VMware vSphere vCenter and ESXi Home Lab shutdown script with PowerCLI

Some times you need to shut down your lab in as efficient way as possible.

I do this quite often as I don't like leaving my home lab running during various events (thunderstorms, weekends , vacation etc). And I really dont like having to click , wait, click, wait, click.... wait some more to get every thing down.


So I wrote this script to power down my lab, Ill walk you through what it does and the completed version will be at the end of this post. (I'm also including a start-up script I use as well)


First we need to import our power CLI modules and tell the script to ignore any self-signed or Invalid certificates ( If you want more info on setting up powerCli see the beginning of this post for more info)

-------------------------------------------------------------------

Import-Module VMware.PowerCLI

Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false

-------------------------------------------------------------------



Now we need to setup our credential variables, one will be for vCenter, and the other is the host that everything will be migrated to and then eventually shut down on. We are going to use a feature in power CLI that allows us to store our password so we don't have to have it in plain text in our script.

You should do this on the computer you will always run this script on.

For the ESXi host, we will use root.

From the command prompt run the following replacing the -Host with something you can identify as your  host,  and -Password with your password


New-VICredentialStoreItem -Host AlphaHost -User root -Password "SuperSecretP@$$w0rd"


Next lets store the password for your vcenter, I will be using administrator@vsphere.local as it does not require AD to be up and running.


New-VICredentialStoreItem -Host VCSA -User administrator@vsphere.local -Password "SuperSecretP@$$w0rd"



And now the lines we put in the script are:

-------------------------------------------------------------------

$VCSAPass = get-VICredentialStoreItem -Host VCSA -User administrator@vsphere.local

$rootPass = get-VICredentialStoreItem -Host AlphaHost -User root

-------------------------------------------------------------------


And now we connect to that vCenter

-------------------------------------------------------------------

connect-VIServer vcenter.home.lab -User 'administrator@vsphere.local' -Password $VCSAPass.Password

-------------------------------------------------------------------


The next step is we are going to create the vmservers variable that gets a list of all VMs that are powered on, except for our vcenter, domain controllers and the vCLS vms, and then shutdown the guest OS of the VM's. We do this as we need the DC for DNS resolution, and the vCLS vms will be powered off in a later step by vCenter (if they are powered off now, they just get auto started back up)

-------------------------------------------------------------------

$vmservers=Get-VM | Where-Object {$_.powerstate -eq ‘PoweredOn’ -and $_.name -ne 'vcenter.home.lab' -and $_.name -ne 'dc1.home.lab' -and $_.name -ne 'dc2.home.lab' -and $_.name -cnotlike 'vCLS*' }

$vmservers| Shutdown-VMGuest -Confirm:$false

-------------------------------------------------------------------

Now I have a 3 node cluster, so I will be putting 2/3  into maintenance mode before shutting them down. Since i have DRS enabled this will move the remaining VMs to a single host (makes startup script work as well)

-------------------------------------------------------------------

Get-VMHost -Name charlie.home.lab | set-vmhost -State Maintenance

Get-VMHost -Name bravo.home.lab | set-vmhost -State Maintenance

-------------------------------------------------------------------


Now that our hosts are in maintanence mode, we are going to set retreat mode for vCLS vms, this will cause vCenter to delete them(to find your domain-c<number> see the following VMware KB to get that info and replace it in the line below https://kb.vmware.com/s/article/80472):

-------------------------------------------------------------------

Get-AdvancedSetting -Entity vcenter.home.lab -Name 'config.vcls.clusters.domain-c26.enabled' | Set-AdvancedSetting -Value 'false' -Confirm:$false

start-sleep 60

-------------------------------------------------------------------

Now lets shut down those hosts


-------------------------------------------------------------------

Get-VMHost -Name charlie.home.lab | Stop-VMHost -Confirm:$false

Get-VMHost -Name bravo.home.lab | Stop-VMHost -Confirm:$false

-------------------------------------------------------------------


Our tasks for vCenter are done, we now disconnect from the vCenter , and connect directly to the last ESXi hosts that still has VMs running by IP:


-------------------------------------------------------------------

Disconnect-VIServer vcenter.home.lab -confirm:$false

connect-VIServer 192.168.0.252 -User 'root' -Password $rootPass.Password


-------------------------------------------------------------------


Now we power off the last set of VM's(dc's and vCenter should be all thats left):

-------------------------------------------------------------------

$morevmservers=Get-VM | Where-Object {$_.powerstate -eq ‘PoweredOn’}

$morevmservers| Shutdown-VMGuest -Confirm:$false

do { $vmstatus = (get-vm $morevmservers).PowerState ; Start-Sleep -Seconds 5} while ($vmstatus -eq "PoweredOn")

-------------------------------------------------------------------


And put this host into maintenance mode,  then power it off and disconnect 

-------------------------------------------------------------------

set-vmhost -State Maintenance

start-sleep 60

Stop-VMHost -Confirm:$false
Disconnect-VIServer 192.168.0.252  -confirm:$false

-------------------------------------------------------------------


Lastly I put in a final check to verify that all the ESXi hosts are no longer ping-able (powered off)

-------------------------------------------------------------------

#Check servers are down

do{}Until (!(Test-Connection 192.168.0.250 -Quiet -Count 1))

Write-Host -ForegroundColor Black -BackgroundColor Green "Host Charlie.Home.Lab Is Down"

do{}Until (!(Test-Connection 192.168.0.251 -Quiet -Count 1))

Write-Host -ForegroundColor Black -BackgroundColor Green "Host Bravo.Home.Lab Is Down"

do{}Until (!(Test-Connection 192.168.0.252 -Quiet -Count 1))

Write-Host -ForegroundColor Black -BackgroundColor Green "Host Alpha.Home.Lab Is Down"

-------------------------------------------------------------------



That's it, so as mentioned here is the full script:


#-------------------------------------------------------------------

#-------------------------------------------------------------------

#-------------------------vSphere Lap Power Off Script------

#--------------------------------------------------------------------

#------------By Jeramy Thompson------------------------------

#-----------https://jeramythompson.blogspot.com/----------

#-------------------------------------------------------------------


Import-Module VMware.PowerCLI

Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false

$VCSAPass = get-VICredentialStoreItem -Host VCSA -User administrator@vsphere.local

$rootPass = get-VICredentialStoreItem -Host AlphaHost -User root

connect-VIServer vcenter.home.lab -User 'administrator@vsphere.local' -Password $VCSAPass.Password


$vmservers=Get-VM | Where-Object {$_.powerstate -eq ‘PoweredOn’ -and $_.name -ne 'vcenter.home.lab' -and $_.name -ne 'dc1.home.lab' -and $_.name -ne 'dc2.home.lab' -and $_.name -cnotlike 'vCLS*' }

$vmservers| Shutdown-VMGuest -Confirm:$false

Get-VMHost -Name charlie.home.lab | set-vmhost -State Maintenance

Get-VMHost -Name bravo.home.lab | set-vmhost -State Maintenance

Get-AdvancedSetting -Entity vcenter.home.lab -Name 'config.vcls.clusters.domain-c26.enabled' | Set-AdvancedSetting -Value 'false' -Confirm:$false

start-sleep 60

Get-VMHost -Name charlie.home.lab | Stop-VMHost -Confirm:$false

Get-VMHost -Name bravo.home.lab | Stop-VMHost -Confirm:$false


Disconnect-VIServer vcenter.home.lab -confirm:$false

connect-VIServer 192.168.0.252 -User 'root' -Password $rootPass.Password

$morevmservers=Get-VM | Where-Object {$_.powerstate -eq ‘PoweredOn’}

$morevmservers| Shutdown-VMGuest -Confirm:$false

do { $vmstatus = (get-vm $morevmservers).PowerState ; Start-Sleep -Seconds 5} while ($vmstatus -eq "PoweredOn")


set-vmhost -State Maintenance

start-sleep 60

Stop-VMHost -Confirm:$false
Disconnect-VIServer 192.168.0.252  -confirm:$false

do{}Until (!(Test-Connection 192.168.0.250 -Quiet -Count 1))

Write-Host -ForegroundColor Black -BackgroundColor Green "Host Charlie.Home.Lab Is Down"

do{}Until (!(Test-Connection 192.168.0.251 -Quiet -Count 1))

Write-Host -ForegroundColor Black -BackgroundColor Green "Host Bravo.Home.Lab Is Down"

do{}Until (!(Test-Connection 192.168.0.252 -Quiet -Count 1))

Write-Host -ForegroundColor Black -BackgroundColor Green "Host Alpha.Home.Lab Is Down"


#-------------------------------------------------------------------

#-------------------------------------------------------------------

#-------------------------------------------------------------------

#-------------------------------------------------------------------









As Mentioned I also have a startup scrip. At this point its should be self explanitory.





#-------------------------------------------------------------------

#-------------------------------------------------------------------

#-------------------------vSphere Lap Power ON Script------

#--------------------------------------------------------------------

#------------By Jeramy Thompson------------------------------

#-----------https://jeramythompson.blogspot.com/----------

#-------------------------------------------------------------------



Import-Module VMware.PowerCLI

Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false



$VCSAPass = get-VICredentialStoreItem -Host VCSA -User administrator@vsphere.local

$rootPass = get-VICredentialStoreItem -Host AlphaHost -User root




#Connect To Alpha

connect-VIServer 192.168.0.252 -User 'root' -Password $rootPass.Password


#If its in Maintence mode, exit it:

set-vmhost -State connected



$StartServers=Get-VM | Where-Object {$_.name -eq 'vcenter.home.lab' -or $_.name -eq 'dc1.home.lab' -or $_.name -eq 'dc2.home.lab'}

$StartServers| Start-VM -Confirm:$false

start-sleep 60

Disconnect-VIServer 192.168.0.252 -confirm:$false



Start-Sleep 600

connect-VIServer vcenter.home.lab -User 'administrator@vsphere.local' -Password $VCSAPass.Password

Get-AdvancedSetting -Entity vcenter.home.lab -Name 'config.vcls.clusters.domain-c26.enabled' | Set-AdvancedSetting -Value 'true' -Confirm:$false



Get-VMHost -Name charlie.home.lab | set-vmhost -State Connected

Get-VMHost -Name bravo.home.lab | set-vmhost -State Connected


#Start the vApp that contains other essentials 

Start-VApp -VApp Infra -Confirm:$false

Disconnect-VIServer vcenter.home.lab -confirm:$false


#-------------------------------------------------------------------

#-------------------------------------------------------------------

#-------------------------------------------------------------------

#-------------------------------------------------------------------









Comments

Popular posts from this blog

vSphere 7 - Specify a vmkernel adapter to use for NFS datastores Step By Step \ Walkthrough on a DVS

Horizon View 2-factor Authentication for Free! with Google Authenticator or others

Windows 11 Insider Preview Instant Clones Horizon 8 2103 walkthrough - Part 1 Image setup