How to shut down Ubuntu 11.10 host from within a Windows 7 VirtualBox guest?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








up vote
1
down vote

favorite












I have installed virtual box 4.2 on a Ubuntu 11.10 host.



I have Windows 7 as the only guest OS.



I'm able to auto start Windows 7 virtual when Ubuntu boots by adding it in start application with the command "VBoxMange startvm Win7" in the command option.



Now when I shutdown Windows 7 , the virtualbox program is getting closed, but I go back to Ubuntu, when I want to have Ubuntu shut down as well when I click Shutdown in Windows 7 in Virtualbox.



This is an assignment for me. Can anybody please help me on this?



Also, when virtual box starts up automatically, Ubuntu's desktop should not be visible.







share|improve this question


















  • 1




    It would have been a major design flaw indeeed, if guests could issue a shutdown command for for their hosts. I hope the designers of VirtualBox were smart enough to not allow something like that.
    – mikewhatever
    Jan 27 '13 at 13:34






  • 2




    This is such a curious request. Why don't you just install Windows 7 on your machine rather than running it within a VM?
    – Paddy Landau
    Jan 27 '13 at 13:52














up vote
1
down vote

favorite












I have installed virtual box 4.2 on a Ubuntu 11.10 host.



I have Windows 7 as the only guest OS.



I'm able to auto start Windows 7 virtual when Ubuntu boots by adding it in start application with the command "VBoxMange startvm Win7" in the command option.



Now when I shutdown Windows 7 , the virtualbox program is getting closed, but I go back to Ubuntu, when I want to have Ubuntu shut down as well when I click Shutdown in Windows 7 in Virtualbox.



This is an assignment for me. Can anybody please help me on this?



Also, when virtual box starts up automatically, Ubuntu's desktop should not be visible.







share|improve this question


















  • 1




    It would have been a major design flaw indeeed, if guests could issue a shutdown command for for their hosts. I hope the designers of VirtualBox were smart enough to not allow something like that.
    – mikewhatever
    Jan 27 '13 at 13:34






  • 2




    This is such a curious request. Why don't you just install Windows 7 on your machine rather than running it within a VM?
    – Paddy Landau
    Jan 27 '13 at 13:52












up vote
1
down vote

favorite









up vote
1
down vote

favorite











I have installed virtual box 4.2 on a Ubuntu 11.10 host.



I have Windows 7 as the only guest OS.



I'm able to auto start Windows 7 virtual when Ubuntu boots by adding it in start application with the command "VBoxMange startvm Win7" in the command option.



Now when I shutdown Windows 7 , the virtualbox program is getting closed, but I go back to Ubuntu, when I want to have Ubuntu shut down as well when I click Shutdown in Windows 7 in Virtualbox.



This is an assignment for me. Can anybody please help me on this?



Also, when virtual box starts up automatically, Ubuntu's desktop should not be visible.







share|improve this question














I have installed virtual box 4.2 on a Ubuntu 11.10 host.



I have Windows 7 as the only guest OS.



I'm able to auto start Windows 7 virtual when Ubuntu boots by adding it in start application with the command "VBoxMange startvm Win7" in the command option.



Now when I shutdown Windows 7 , the virtualbox program is getting closed, but I go back to Ubuntu, when I want to have Ubuntu shut down as well when I click Shutdown in Windows 7 in Virtualbox.



This is an assignment for me. Can anybody please help me on this?



Also, when virtual box starts up automatically, Ubuntu's desktop should not be visible.









share|improve this question













share|improve this question




share|improve this question








edited Jan 27 '13 at 12:18









Eliah Kagan

79.2k20218359




79.2k20218359










asked Jan 27 '13 at 11:45









Bharath VRP

62




62







  • 1




    It would have been a major design flaw indeeed, if guests could issue a shutdown command for for their hosts. I hope the designers of VirtualBox were smart enough to not allow something like that.
    – mikewhatever
    Jan 27 '13 at 13:34






  • 2




    This is such a curious request. Why don't you just install Windows 7 on your machine rather than running it within a VM?
    – Paddy Landau
    Jan 27 '13 at 13:52












  • 1




    It would have been a major design flaw indeeed, if guests could issue a shutdown command for for their hosts. I hope the designers of VirtualBox were smart enough to not allow something like that.
    – mikewhatever
    Jan 27 '13 at 13:34






  • 2




    This is such a curious request. Why don't you just install Windows 7 on your machine rather than running it within a VM?
    – Paddy Landau
    Jan 27 '13 at 13:52







1




1




It would have been a major design flaw indeeed, if guests could issue a shutdown command for for their hosts. I hope the designers of VirtualBox were smart enough to not allow something like that.
– mikewhatever
Jan 27 '13 at 13:34




It would have been a major design flaw indeeed, if guests could issue a shutdown command for for their hosts. I hope the designers of VirtualBox were smart enough to not allow something like that.
– mikewhatever
Jan 27 '13 at 13:34




2




2




This is such a curious request. Why don't you just install Windows 7 on your machine rather than running it within a VM?
– Paddy Landau
Jan 27 '13 at 13:52




This is such a curious request. Why don't you just install Windows 7 on your machine rather than running it within a VM?
– Paddy Landau
Jan 27 '13 at 13:52










2 Answers
2






active

oldest

votes

















up vote
3
down vote













The way to do this is to write a script to start your VM, wait until it terminates, and then issue the shut-down command.



Create a folder bin in your home folder (if it does not exist already).



Now create a file with the following contents. Let's call it win7vmshutdown, and save it in your bin folder.



#!/bin/bash

VBoxManage startvm 'Win7' # Start the VM.

sleep 10s # Give it time to start up.

while pgrep VirtualBox >/dev/null # As long as the VM is running...
do
sleep 5s # Wait a bit before trying again.
done

gnome-session-quit --power-off # Issue the command to shut down.


Make the script executable; enter the following in a Terminal.



chmod +x ~/bin/win7vmshutdown


In your Startup Applications, remove the VBoxManage ... command and replace it with win7vmshutdown.



The shutdown command will prompt you for shutdown; if you don't answer, it will shut down in 60 seconds. This gives you time to interrupt the shutdown in case of unexpected problems.



Reboot your computer to test.



You said:




Also, when virtual box starts up automatically, Ubuntu's desktop should not be visible.




To do that, you want to run your VM in full-screen. Install the Guest Additions in your VM, reboot it, and run it full-screen.






share|improve this answer





























    up vote
    1
    down vote













    You need to create a script that runs on your Windows box that performs a coordinated shutdown of your systems.



    From what I read, you want to trigger this from inside your Windows 7 VM.



    For a scriptable shutdown of Windows 7, use the psshutdown utility from SysInternals.



    You will also need to signal your host to shut down. The best way to do this is to remotely trigger it using secure shell.



    On the Ubuntu machine :



    You should create a user specifically for this task, and an SSH key specifically for this user. This user will be running a script with elevated privileges and access to it should be at a minimum.



    On the Windows machine :



    You will need a means to run the script on the host machine via SSH. The Cygwin version of OpenSSH is probably the best option.



    So your Windows script should



    • Use SSH to start the script on the host

    • Run psshutdown -t 0 -k

    The Ubuntu script should



    • Be owned by root

    • Have the setuid attribute on so that it will run with root privileges


    • sleep for a period of time greater than the Windows machine shutdown

    • Execute /sbin/poweroff

    As for the other matter - if you don't want to see the Ubuntu desktop at any time, you can just not load it. Add a user X session that only starts the VirtualBox instance in full screen mode.






    share|improve this answer




















      Your Answer







      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "89"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      convertImagesToLinks: true,
      noModals: false,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );








       

      draft saved


      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f248211%2fhow-to-shut-down-ubuntu-11-10-host-from-within-a-windows-7-virtualbox-guest%23new-answer', 'question_page');

      );

      Post as a guest






























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      3
      down vote













      The way to do this is to write a script to start your VM, wait until it terminates, and then issue the shut-down command.



      Create a folder bin in your home folder (if it does not exist already).



      Now create a file with the following contents. Let's call it win7vmshutdown, and save it in your bin folder.



      #!/bin/bash

      VBoxManage startvm 'Win7' # Start the VM.

      sleep 10s # Give it time to start up.

      while pgrep VirtualBox >/dev/null # As long as the VM is running...
      do
      sleep 5s # Wait a bit before trying again.
      done

      gnome-session-quit --power-off # Issue the command to shut down.


      Make the script executable; enter the following in a Terminal.



      chmod +x ~/bin/win7vmshutdown


      In your Startup Applications, remove the VBoxManage ... command and replace it with win7vmshutdown.



      The shutdown command will prompt you for shutdown; if you don't answer, it will shut down in 60 seconds. This gives you time to interrupt the shutdown in case of unexpected problems.



      Reboot your computer to test.



      You said:




      Also, when virtual box starts up automatically, Ubuntu's desktop should not be visible.




      To do that, you want to run your VM in full-screen. Install the Guest Additions in your VM, reboot it, and run it full-screen.






      share|improve this answer


























        up vote
        3
        down vote













        The way to do this is to write a script to start your VM, wait until it terminates, and then issue the shut-down command.



        Create a folder bin in your home folder (if it does not exist already).



        Now create a file with the following contents. Let's call it win7vmshutdown, and save it in your bin folder.



        #!/bin/bash

        VBoxManage startvm 'Win7' # Start the VM.

        sleep 10s # Give it time to start up.

        while pgrep VirtualBox >/dev/null # As long as the VM is running...
        do
        sleep 5s # Wait a bit before trying again.
        done

        gnome-session-quit --power-off # Issue the command to shut down.


        Make the script executable; enter the following in a Terminal.



        chmod +x ~/bin/win7vmshutdown


        In your Startup Applications, remove the VBoxManage ... command and replace it with win7vmshutdown.



        The shutdown command will prompt you for shutdown; if you don't answer, it will shut down in 60 seconds. This gives you time to interrupt the shutdown in case of unexpected problems.



        Reboot your computer to test.



        You said:




        Also, when virtual box starts up automatically, Ubuntu's desktop should not be visible.




        To do that, you want to run your VM in full-screen. Install the Guest Additions in your VM, reboot it, and run it full-screen.






        share|improve this answer
























          up vote
          3
          down vote










          up vote
          3
          down vote









          The way to do this is to write a script to start your VM, wait until it terminates, and then issue the shut-down command.



          Create a folder bin in your home folder (if it does not exist already).



          Now create a file with the following contents. Let's call it win7vmshutdown, and save it in your bin folder.



          #!/bin/bash

          VBoxManage startvm 'Win7' # Start the VM.

          sleep 10s # Give it time to start up.

          while pgrep VirtualBox >/dev/null # As long as the VM is running...
          do
          sleep 5s # Wait a bit before trying again.
          done

          gnome-session-quit --power-off # Issue the command to shut down.


          Make the script executable; enter the following in a Terminal.



          chmod +x ~/bin/win7vmshutdown


          In your Startup Applications, remove the VBoxManage ... command and replace it with win7vmshutdown.



          The shutdown command will prompt you for shutdown; if you don't answer, it will shut down in 60 seconds. This gives you time to interrupt the shutdown in case of unexpected problems.



          Reboot your computer to test.



          You said:




          Also, when virtual box starts up automatically, Ubuntu's desktop should not be visible.




          To do that, you want to run your VM in full-screen. Install the Guest Additions in your VM, reboot it, and run it full-screen.






          share|improve this answer














          The way to do this is to write a script to start your VM, wait until it terminates, and then issue the shut-down command.



          Create a folder bin in your home folder (if it does not exist already).



          Now create a file with the following contents. Let's call it win7vmshutdown, and save it in your bin folder.



          #!/bin/bash

          VBoxManage startvm 'Win7' # Start the VM.

          sleep 10s # Give it time to start up.

          while pgrep VirtualBox >/dev/null # As long as the VM is running...
          do
          sleep 5s # Wait a bit before trying again.
          done

          gnome-session-quit --power-off # Issue the command to shut down.


          Make the script executable; enter the following in a Terminal.



          chmod +x ~/bin/win7vmshutdown


          In your Startup Applications, remove the VBoxManage ... command and replace it with win7vmshutdown.



          The shutdown command will prompt you for shutdown; if you don't answer, it will shut down in 60 seconds. This gives you time to interrupt the shutdown in case of unexpected problems.



          Reboot your computer to test.



          You said:




          Also, when virtual box starts up automatically, Ubuntu's desktop should not be visible.




          To do that, you want to run your VM in full-screen. Install the Guest Additions in your VM, reboot it, and run it full-screen.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jan 27 '13 at 14:31

























          answered Jan 27 '13 at 13:52









          Paddy Landau

          3,07722243




          3,07722243






















              up vote
              1
              down vote













              You need to create a script that runs on your Windows box that performs a coordinated shutdown of your systems.



              From what I read, you want to trigger this from inside your Windows 7 VM.



              For a scriptable shutdown of Windows 7, use the psshutdown utility from SysInternals.



              You will also need to signal your host to shut down. The best way to do this is to remotely trigger it using secure shell.



              On the Ubuntu machine :



              You should create a user specifically for this task, and an SSH key specifically for this user. This user will be running a script with elevated privileges and access to it should be at a minimum.



              On the Windows machine :



              You will need a means to run the script on the host machine via SSH. The Cygwin version of OpenSSH is probably the best option.



              So your Windows script should



              • Use SSH to start the script on the host

              • Run psshutdown -t 0 -k

              The Ubuntu script should



              • Be owned by root

              • Have the setuid attribute on so that it will run with root privileges


              • sleep for a period of time greater than the Windows machine shutdown

              • Execute /sbin/poweroff

              As for the other matter - if you don't want to see the Ubuntu desktop at any time, you can just not load it. Add a user X session that only starts the VirtualBox instance in full screen mode.






              share|improve this answer
























                up vote
                1
                down vote













                You need to create a script that runs on your Windows box that performs a coordinated shutdown of your systems.



                From what I read, you want to trigger this from inside your Windows 7 VM.



                For a scriptable shutdown of Windows 7, use the psshutdown utility from SysInternals.



                You will also need to signal your host to shut down. The best way to do this is to remotely trigger it using secure shell.



                On the Ubuntu machine :



                You should create a user specifically for this task, and an SSH key specifically for this user. This user will be running a script with elevated privileges and access to it should be at a minimum.



                On the Windows machine :



                You will need a means to run the script on the host machine via SSH. The Cygwin version of OpenSSH is probably the best option.



                So your Windows script should



                • Use SSH to start the script on the host

                • Run psshutdown -t 0 -k

                The Ubuntu script should



                • Be owned by root

                • Have the setuid attribute on so that it will run with root privileges


                • sleep for a period of time greater than the Windows machine shutdown

                • Execute /sbin/poweroff

                As for the other matter - if you don't want to see the Ubuntu desktop at any time, you can just not load it. Add a user X session that only starts the VirtualBox instance in full screen mode.






                share|improve this answer






















                  up vote
                  1
                  down vote










                  up vote
                  1
                  down vote









                  You need to create a script that runs on your Windows box that performs a coordinated shutdown of your systems.



                  From what I read, you want to trigger this from inside your Windows 7 VM.



                  For a scriptable shutdown of Windows 7, use the psshutdown utility from SysInternals.



                  You will also need to signal your host to shut down. The best way to do this is to remotely trigger it using secure shell.



                  On the Ubuntu machine :



                  You should create a user specifically for this task, and an SSH key specifically for this user. This user will be running a script with elevated privileges and access to it should be at a minimum.



                  On the Windows machine :



                  You will need a means to run the script on the host machine via SSH. The Cygwin version of OpenSSH is probably the best option.



                  So your Windows script should



                  • Use SSH to start the script on the host

                  • Run psshutdown -t 0 -k

                  The Ubuntu script should



                  • Be owned by root

                  • Have the setuid attribute on so that it will run with root privileges


                  • sleep for a period of time greater than the Windows machine shutdown

                  • Execute /sbin/poweroff

                  As for the other matter - if you don't want to see the Ubuntu desktop at any time, you can just not load it. Add a user X session that only starts the VirtualBox instance in full screen mode.






                  share|improve this answer












                  You need to create a script that runs on your Windows box that performs a coordinated shutdown of your systems.



                  From what I read, you want to trigger this from inside your Windows 7 VM.



                  For a scriptable shutdown of Windows 7, use the psshutdown utility from SysInternals.



                  You will also need to signal your host to shut down. The best way to do this is to remotely trigger it using secure shell.



                  On the Ubuntu machine :



                  You should create a user specifically for this task, and an SSH key specifically for this user. This user will be running a script with elevated privileges and access to it should be at a minimum.



                  On the Windows machine :



                  You will need a means to run the script on the host machine via SSH. The Cygwin version of OpenSSH is probably the best option.



                  So your Windows script should



                  • Use SSH to start the script on the host

                  • Run psshutdown -t 0 -k

                  The Ubuntu script should



                  • Be owned by root

                  • Have the setuid attribute on so that it will run with root privileges


                  • sleep for a period of time greater than the Windows machine shutdown

                  • Execute /sbin/poweroff

                  As for the other matter - if you don't want to see the Ubuntu desktop at any time, you can just not load it. Add a user X session that only starts the VirtualBox instance in full screen mode.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jan 27 '13 at 13:58









                  Adrian

                  4,8261026




                  4,8261026






















                       

                      draft saved


                      draft discarded


























                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f248211%2fhow-to-shut-down-ubuntu-11-10-host-from-within-a-windows-7-virtualbox-guest%23new-answer', 'question_page');

                      );

                      Post as a guest













































































                      Popular posts from this blog

                      pylint3 and pip3 broken

                      Missing snmpget and snmpwalk

                      How to enroll fingerprints to Ubuntu 17.10 with VFS491