Autostart virtualbox VM with specific user

Forum Forums New users New Users and General Questions Autostart virtualbox VM with specific user

  • This topic has 8 replies, 4 voices, and was last updated Jul 29-11:53 am by christophe.
Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #39189
    Member
    diegooo1972

      Hi all

      I hope this is not a dumb question.
      Someone was able to succesfully autostart a VM at boot with a specific user ( not root ) ?
      I have an installed antix in the HD. Not Live.
      systemd is not available in antix. I tried init.d, oracle guide with autostart service, startvm as a service but nothing seems to work. If you autostart bash script it run like root.
      I need to startvm with my user account and not with root.
      I love Antix and need just that thing to be completely happy with it.
      Thanks in any case for your attention.

      #39243
      Member
      Xecure
        Helpful
        Up
        0
        ::

        Can you add the path to your virtual machine file in atartup? Can it not launch that way?
        How do you usually launch your virtual machine?

        antiX Live system enthusiast.
        General Live Boot Parameters for antiX.

        #39373
        Member
        diegooo1972
          Helpful
          Up
          0
          ::

          IF I put the path in startup it just try to run it as root. But the VM is not present in root because it was installed in user account. I don’t find a way to launch the VM as user.
          I’m new with antix but I really like it. I’d like to know if someone was able to run VM as user with virtualbox.

          #39374
          Member
          Xecure
            Helpful
            Up
            0
            ::

            To launch VBox, as sugested by this post:

            In order to minimize (at least partially) possible antiX system freeze, you may start the virtualbox from CLI as follows
            nice virtualbox &

            adding this command to startup.

            To launch a specific virtual machine, you would do:
            vboxmanage startvm <name> --type gui &
            where you would add the name of your virtual machine. Let us imagine your machine you called your machine Windows7-32bits. It would look like:
            vboxmanage startvm Windows7-32bits --type gui &
            based on this:
            https://blog.scottlowe.org/2016/11/10/intro-to-vbox-cli/

            Please first try all commands in a terminal to see if they work before adding them to your startup file.

            If you still cannot launch it without having to give your password, you could add a rule in /etc/sudoers
            myusername ALL = (root) NOPASSWD: /path/to/my/program
            where myusername has to be replaces with your real username, and /path/to/my/program either to virtualbox path (you can find it with command -v virtualbox) or to vboxmanage path (same as before, command -v vboxmanage).
            I have barely any experience with the sudoers file, so maybe someone can correct me if I am wrong.

            antiX Live system enthusiast.
            General Live Boot Parameters for antiX.

            #39460
            Member
            diegooo1972
              Helpful
              Up
              0
              ::

              The problem is that if I login with root and launch vbox I don’t see the vm listed. If I login as user I see the vm listed.
              When i autostart the vm it’s always going to be executed as root so it’s not going to load and work.
              I wonder how I can launch in autostart as user.
              I think the problem is that the vm has been created as user and root use different path to vm.
              Mmmm maybe i can change path for root. I’d prefer to launch vm as user anyway.
              Thanks for the answer. I’ll take allok anyway.

              #39466
              Moderator
              christophe
                Helpful
                Up
                0
                ::

                I did this a while back — you want to autostart a vm, like conky autostarts, directly after login & when X comes up?

                First, I created a desktop launcher for the VM. When the basic virtualbox graphical menu is open, click “machine,” then in the dropdown, there should be a choice for creating a desktop shortcut/launcher onto desktop. (I’m on antiX19 32-bit right now — no virtualbox, so I’m describing this by memory.)

                Then I opened both the desktop file (in ~/Desktop folder) and your ~/desktop-session/startup file in geany (or other text editor). I copied the exec line from the launcher to the startup file/ My example:

                /usr/lib/virtualbox/VirtualBoxVM --comment "WinXP Games" --startvm "{dd4a25ea-458e-4f13-bf7d-b4d05eaa5c3a}" &

                (Don’t forget to put the “&” at the end of the line. The rest is copied & pasted.)

                That should set it up, (it did for me a while back) — if I understand what you are trying to do correctly. 🙂

                • This reply was modified 2 years, 9 months ago by christophe.

                confirmed antiX frugaler, since 2019

                #39467
                Member
                sybok
                  Helpful
                  Up
                  0
                  ::

                  Hi, I stumbled across this post and have one clarifying question.
                  Do you want to run the VM:
                  (1) Start the VM immediately after you login as the user (without the GUI of the VirtualBox program itself)?
                  1.A) Log in as the user.
                  1.B) The VM will be automatically started immediately after 1.A), i.e. there will be a slight delay due to the start-up of the VM (depends on the resources of your PC).
                  (2) At boot, i.e. somehow boot into the VM run in antiX (without starting the user desktop session at all)?
                  Expected steps in this scenario
                  1.A) Start the machine during boot as a specific user.
                  1.B) Log in as the user.
                  1.C) The VM is already there, up and running (no VM’s startup delay as it was already started prior to the user’s log-in).

                  Variant (1):
                  I have successfully tested the command (which I was previously unaware of)
                  vboxmanage startvm <name> --type gui &
                  and it works.
                  You can add the (appropriately modified) command suggested above by Xecure to user’s start-up file ‘/home/<user>/.desktop-session/startup’.

                  This means that once the user logs in, the command will be executed, i.e. the VM will be launched.

                  Variant (2):
                  Creating a service called at startup, run as the specific user (could require executed as root (?), probably with ‘sudo -u <user> [-E]’ …)…
                  Frankly, I am not sure how the VM’s GUI could be “attached” to the non-existing X11 session of the user (not logged in yet).

                  #39567
                  Member
                  diegooo1972
                    Helpful
                    Up
                    0
                    ::

                    What I really want is to launch that VM at boot before I login but as User.
                    Maybe this behaviour is possibile only as root ?
                    I can run the VM after login with USER using that command “vboxmanage startvm <name> –type gui &”. I use headless but it’s the same and I can view it later with “show”.
                    Lgin as USER this work as expected and start immediately. And the VM is in the list of VM.
                    When I login with root this VM don’t appear in vbox VM list. It seems that it belong only to user.
                    Maybe that’s not a normal behaviour in antix ?
                    @christophe Can you tell me what the “&” at the end of the command is going to do ?
                    Your answers are really interesting anyway. Thank for the interest.

                    #39575
                    Moderator
                    christophe
                      Helpful
                      Up
                      0
                      ::

                      @christophe Can you tell me what the “&” at the end of the command is going to do ?
                      Your answers are really interesting anyway. Thank for the interest.

                      That’s just for the user startup file. It is needed for some window managers, telling it to fork the command into the background, while it starts up the window manager.
                      (But that’s not what you are looking for here. I have no idea how to start a VM prior to login.)

                      confirmed antiX frugaler, since 2019

                    Viewing 9 posts - 1 through 9 (of 9 total)
                    • You must be logged in to reply to this topic.