Load VM from Command Line?


Recommended Posts

OK...if I have unRAID console on one monitor and boot a VM on another.... and want to switch to a different VM. I cannot do so from the web interface as I'd need to shut down my VM first and then I lose the web interface...

 

So, can I start/stop VMs easily from command line? Ideally without LOTs of command-line-fu, maybe a batch file to make it less typing?

 

Something like Win10 stop, Linux start, Linux stop, Win10 start

Can't see anyone else asking this but if I can it will make life a lot easier (and cheaper!)

 

EDIT:

 

Seems I can with "virsh shutdown Win10" and "virsh start Linux"

 

SO.... I guess now (for minimal typing!) the question changes to IS there a way to alias "shut" to "virsh shutdown" and "start" to "virsh start" ?  Sorry... Not really used to Linux !!

 

 

Link to comment
  • 1 year later...

If those commands really are all you need, you can either make little scripts, store them on your flash drive, then set your run script to automatically move them to your home folder, or you can try setting a shell alias. You'd put a line in your run script to append a a line to either your .bashrc or .bash_profile (or .profile? I'm a little rusty)

google the bash alias thing because I'm not sure what the restrictions are on that

Link to comment

Idk about OP, but my plan is to build a raspberry pi with some buttons into a sort of physical KVM switch. I pass all of my IO and my only video output through to my VMs, so I would have my little raspi ssh into the server and start or stop my VMs. Command line!

 

I noticed in the log section of the webui it logs a big long command with a bunch of arguments that encase everything defined in the XML, would these shorter virsh commands have any downsides? If I use the commands, would it pull the system "out of sync" with the web UI?

Link to comment

Hello all.

 

I had exactly the same question, and was wondering if I needed to build another computer to turn on the VM's I had created to replace the other computer in the first place? ? I had been considering a Raspberry Pi in fact!

 

So, the console to GUI mode seems the ideal answer, but, didn't I read somewhere that this can cause problems with the graphics on the VM's? ☹️

 

Another quick (but stupid) question. Am I correct in assuming that I must have a different GPU assigned to each VM I run if I want them to run at the same time, In other words, if I want to run a Win10 VM and a Linux VM at the same time?

 

Finally, where could I find a video tutorial on installing Linux Mint Cinnamon as a VM. I'm unsure of which template to use, is it the Linux template, or the Ubuntu template? I've had a go but there are a couple of extra fields that I'm not sure of that pertain to folder locations.

 

Thanks

Edited by Jetjockey
Link to comment
4 hours ago, Jetjockey said:

Hello all.

 

I had exactly the same question, and was wondering if I needed to build another computer to turn on the VM's I had created to replace the other computer in the first place? ? I had been considering a Raspberry Pi in fact!

 

So, the console to GUI mode seems the ideal answer, but, didn't I read somewhere that this can cause problems with the graphics on the VM's? ☹️

 

Another quick (but stupid) question. Am I correct in assuming that I must have a different GPU assigned to each VM I run if I want them to run at the same time, In other words, if I want to run a Win10 VM and a Linux VM at the same time?

 

Finally, where could I find a video tutorial on installing Linux Mint Cinnamon as a VM. I'm unsure of which template to use, is it the Linux template, or the Ubuntu template? I've had a go but there are a couple of extra fields that I'm not sure of that pertain to folder locations.

 

Thanks

Well the only thing is that if you pass through whatever video device runs the console, you won't be able to see the console :P. If you pass through your keyboard, you won't be able to type in the console. It won't cause problems on your guest VM, but good luck typing in the console.

 

Your assumption is sort of correct. So if you want to drive two different displays with hardware accelerated performance, you'll need two different video cards plugged into two different displays. With this setup, you'll also want two keyboards, two mice, etc. or a physical KVM switch. However, there's a trick. VM's don't require video cards. KVM can emulate a video card and show the output over VNC in a web browser. So what I do is I connect both screens to my 1070 which is on my windows VM, then I start a linux VM and use VNC graphics. I connect a native windows VNC client instead of using a web browser and make the client full screen on one of my screens, and voila! linux and windows running side by side on two different screens, you can seamlessly drag the mouse between them and type wherever you click!

Link to comment
12 hours ago, CommandLionInterface said:

If those commands really are all you need, you can either make little scripts, store them on your flash drive, then set your run script to automatically move them to your home folder, or you can try setting a shell alias. You'd put a line in your run script to append a a line to either your .bashrc or .bash_profile (or .profile? I'm a little rusty)

google the bash alias thing because I'm not sure what the restrictions are on that

 

What I am now looking to do is add them to a web page so I can select Shutdown Existing VM and Start New VM in one button...

 

9 hours ago, jonp said:

Why not just boot into GUI boot mode on your console monitor so you can use the webGui through the included Firefox browser?  You can enable this by moving the "menu default" item in your syslinux config to live under the GUI mode option.

 

Didnt exist AFAIK when I posted a year ago.. ;)   But I recall in an email from a Mr Jon Panozzo being told that LT were looking into some sort of control and "I would like what was offered".. still waiting... There is some paid app from a 3rd party that enables some control. All I would suggest is needed is (a) unRAID offering a mobile-optimized web interface  OR (b) being able to shutdown and start a new machine from web interface on machine you are shutting down!?

 

I am in process of moving all my data back onto unRAID with a 14 core Xeon box. I'd like to be able to toggle my VMs without needing to use a 2nd machine to do so. Don't have a spare GPU for the webGUI

Link to comment
  • 10 months later...
On 22.2.2017 at 9:09 AM, methanoid said:

 

What I am now looking to do is add them to a web page so I can select Shutdown Existing VM and Start New VM in one button...

 

 

Didnt exist AFAIK when I posted a year ago.. ;-)   But I recall in an email from a Mr Jon Panozzo being told that LT were looking into some sort of control and "I would like what was offered".. still waiting... There is some paid app from a 3rd party that enables some control. All I would suggest is needed is (a) unRAID offering a mobile-optimized web interface  OR (b) being able to shutdown and start a new machine from web interface on machine you are shutting down!?

 

I am in process of moving all my data back onto unRAID with a 14 core Xeon box. I'd like to be able to toggle my VMs without needing to use a 2nd machine to do so. Don't have a spare GPU for the webGUI

 

I have exactly the same problem. Do you find a solution yet?

Link to comment
  • 7 months later...

I use this script to swicth VM from the desktop. I put the switchvm.sh file at the root of my flash drive, then, I use a .bat file to call putty :

 

"C:\Program Files (x86)\PuTTY\plink.exe" -ssh  -pw  password root@tower  "/boot/switchvm.sh VM-1 VM-2 > /dev/null &"

 

You just need to change the user/password and the VM-1  VM-2 parameters

switchvm.sh

 

The script shuts down the first VM, waits for it to actually shut down, and the start the second VM.

Edited by wesker316
  • Like 5
Link to comment
9 hours ago, wesker316 said:

I use this script to swicth VM from the desktop. I put the switchvm.sh file at the root of my flash drive, then, I use a .bat file to call putty :

 

"C:\Program Files (x86)\PuTTY\plink.exe" -ssh  -pw  password root@tower  "/boot/switchvm.sh VM-1 VM-2 > /dev/null &"

 

You just need to change the user/password and the VM-1  VM-2 parameters

switchvm.sh

 

The script shuts down the first VM, waits for it to actually shut down, and the start the second VM.

 

Thanks for that... that works great from Windows only I assume...  so I can select to close my Windows VM and start ANY other VM depending on script selected. But to complete the puzzle we'd need similar for other OS's ... Linux and Mac have SSH built in yes? But a great workaround until a better WebUI typ version comes along 🙂

Link to comment
  • 2 weeks later...
On 9/1/2018 at 3:23 PM, itimpi said:

I would have thought you should be able to set these scripts up under the User Scripts plugin?    Then you can run it from the unRAID GUI without the need for ssh.

Yeah but then its "open Web browser, navigate through screens to UserScripts, execute" in comparison to "double click on BAT file on desktop"...

 

Link to comment
14 minutes ago, methanoid said:

Yeah but then its "open Web browser, navigate through screens to UserScripts, execute" in comparison to "double click on BAT file on desktop"...

 

+1

 

The ability to shutdown a VM and automatically starts a different one without touching the GUI is extremely useful for me.

I have multiple templates of my workstation VM (using 8 cores, 16 cores, 24 cores) that I'd like to switch to depending on what my current work is and what is running on the server. Adobe Lightroom lags like crazy with 24 cores. Adobe Premiere scales a lot better.

Link to comment
  • 1 year later...
On 8/31/2018 at 5:13 PM, wesker316 said:

I use this script to swicth VM from the desktop. I put the switchvm.sh file at the root of my flash drive, then, I use a .bat file to call putty :

 

"C:\Program Files (x86)\PuTTY\plink.exe" -ssh  -pw  password root@tower  "/boot/switchvm.sh VM-1 VM-2 > /dev/null &"

 

You just need to change the user/password and the VM-1  VM-2 parameters

switchvm.sh 621 B · 29 downloads

 

The script shuts down the first VM, waits for it to actually shut down, and the start the second VM.

Hey @wesker316, sorry for digging this one out of the grave, but your script idea looks like exactly what I was looking for. I'm a total linux noob though...  I tried running the script from the /boot folder as you suggested, but got permissions errors. Ran chmod -x switchvm.sh and still wouldn't run, so I moved it to my domains folder, and after doing chmod -x again it at least ran, but i get the error "error: Failed to get option 'domain': Option argument is empty". WOuld you be able to enlighten me on how the VM-1 & VM-2 paramter works (am i supposed to put the full vm name here?), and anything else I might be doing wrong?

 

Thank a lot!

  • Like 1
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.