Start Ubuntu without Login Windows

Hi all,

I am using Windows 10 with Ubuntu to build the NC server. But I aware if I restart the server / logoff the Windows. Then the NC will down due to the Apache server is stopped. Does anyone know how to handle this problem? Thanks a lot!

Regards,
Steven

Hi, does I suppose correctly that Ubuntu is running in a VM on your Windows 10 PC? If yes, which Hypervisor are you using?

@szaimen I am running WSL App on WIndows- Ubuntu 20.04 LTS. Yes, It like a VM run the Linux in the Windows 10. Thank you so much!

WSL version 1 or WSL version 2?

@szaimen It should be WSL version 2. Thank you!

Hi.

Thats not a direct answer to your question. But please consider running a productive nextcloud instance on a seperate device or at least in a VM. WSL is not designed to run productive services. even their FAQ say so…

https://docs.microsoft.com/en-us/windows/wsl/faq

WSL targets a developer audience with the intent to be used as part of an inner development loop. Let’s say that Sam is creating a CI/CD pipeline (Continuous Integration & Continuous Delivery) and wants to test it first on a local machine (laptop) before deploying it to the cloud. Sam can enable WSL (& WSL 2 to improve speed and performance), and then use a genuine Linux Ubuntu instance locally (on the laptop) with whatever Bash commands and tools they prefer. Once the development pipeline is verified locally, Sam can then push that CI/CD pipeline up to the cloud (ie Azure) by making it into a Docker container and pushing the container to a cloud instance where it runs on a production-ready Ubuntu VM.

Also, even though you will be able to run many popular server applications (e.g. Redis), we do not recommend WSL for hosting production services – Microsoft offers a variety of solutions for running production Linux workloads in Azure, Hyper-V, and Docker.

Besides of that Windows 10 is generally not designed to run services without a user logged in, even with native Windows apps. For this purpose MS offer their various Windows Server products.

In case you absolutely have to do it anyway, maybe this video will help you…

https://www.youtube.com/watch?v=KmFwDHx7lhw

…or this google search:

https://www.google.com/search?q=autostart+wsl2+services+windows+10

But i’m not sure whether a user still has to log in to windows for this to work.

1 Like

If found those search results for you: https://www.ecosia.org/search?tt=42b8ae98&q=automatic+start+wsl2+upon+restart
The first two results already look pretty good to me.

1 Like

@szaimen Thank you so much. Finally, I follow 1st result and for grant the apache2 without password option need to use this command “sudo visudo -f /etc/sudoers.d/wsl_start_up”. Then the service will start when user logged in to the Windows. As I want the service start when computer start. So that I do one more thing that I add task schedule to run the .bat when windows start. After that seems everything is fine.

@szaimen And I found that if I create a task schedule to execute when startup. Then I need to remove run the bat at startup folder. otherwise, it will have a error.