Wsl windows 10 установка debian

About

As of March 2018 Debian is available for Windows users through the Windows store as an app for the Windows Subsystem for Linux (WSL).

The app gives you a Debian stable command line environment running on the Windows kernel (WSL1) or Hyper-V with the new WSL 2 interface depending on your Windows 10 release version. Most of the packages in Debian stable should «just work».

Install

  • Note: As of the time of writing, 2024-06-28, your best option for installing and using Debian GNU/Linux on WSL will probably be to use the WSL 2 subsystem and systemd mode. The Microsoft documentation for achieving this is rather fragmented. Therfore a detailed instruction is given in more detail under a separate heading below.

To use the store app you have to enable the WSL subsystem first by following the guide.

Afterwards just install the Debian app from the Microsoft Store.

You will be asked to define a user and password upon first start. This user will also be given sudo rights.

There is a way to install the Debian WSL distro offline & without using Microsoft Market.

Further information about the ongoing development of WSL can be found in the WSL tag of the Microsoft blog.

WSL 2 with systemd support

Microsoft partnered with Canonical to bring systemd support to WSL 2, and it is also available for Debian and other GNU/Linux distributions.

WSL 2 with systemd is probably what you want for your freshly installed Debian GNU/Linux system, as WSL 2 is a prerequisite for GUI application support, and systemd is a prerequisite for many Debian packages. Read more about GUI apps here.

At the time of this writing, 2024-06-28, the documentation over at Microsoft Learn for acieving a Debian install in a WSL 2 subsystem with systemd activated is rather fragmented. Therefore the process is detailed here.

  • Note that a Windows 11 operating system for hosting WSL is assumed.

Lengtly description follows here:

To prepare your system:

  1. Make sure your computer has the Virtualization features enabled in UEFI Settings (some may refer to this as BIOS Settings).
  2. Activate and install the needed features and software on your Windows host OS. Open PowerShell in Administrator mode and type these commands:

     dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
     dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

  3. Reboot your Windows 11 host
  4. Update your WSL Linux kernel update package. Open PowerShell in administrator mode and enter the ffollowing command

     wsl.exe --update

    • This will install and update WSL from Microsoft Store
    • If you do dot wish or cannot use Microsoft Store, please consult this Microsoft Learn article

To install Debian GNU/Linux

  1. Giong forward we are in usermode. So you must open normal PowerShell without administrator mode for the steps in this section.

  2. Set WSL 2 as you default WSL version. This is a per-user setting in Windows.
     wsl --set-default-version 2

  3. Install Debian
     wsl --install -d Debian

    • This takes some time
  4. Set a username and password for your Debian GNU/Linux installation when prompted

    • You are now logged in to your Debian system in command line mode
  5. Add some text to the file /etc/wsl.conf to activate systemd mode on next boot of WSL 2

     sudo echo '
     [boot]
     systemd=true' >> /etc/wsl.conf

    Provide the user password you set in the previous step when prompted.

  6. Verify the content of the file /etc/wsl.conf and correct any errrors. There should be only one section [boot] and exactly one instance of the line systemd=true in it.

     sudo editor /etc/wsl.conf

  7. Exit to PowerShell by issuing the command logout, or by pressing [Ctrl] + D

  8. Shut down your Debian WSL 2 instance from PowerShell

     wsl --shutdown -d Debian

  9. Start your Debian instance and log back in
     wsl -d Debian -u <username>

  10. Use apt to upgrade your WSL 2 Debian and apt or aptitude to install some packages (mesa-utils is required on the Debian side for the GUI apps integration to work)

     sudo apt update
     sudo apt dist-upgrade
     sudo apt install mesa-utils firefox-esr

  11. The installed programs can be started from a Debian shell, or from the Windows start menu.

Advanced Usage

WSL 2 brings GUI application and sytemd support to WSL. That is, you now can run Debian apps in an integrated desktop mode.

To activate the new GUI application support you have to update your WSL 2 environment to Debian bookworm or later.

After that you need to install mesa-utils this will install all the necessary packages for th GUI app support to work.

Most of the GUI apps in Debian should now just work out-of-the-box (e.g., try firefox).

Feedback

Please use the Microsoft Store review/feedback to report bugs or feature requests for now.

There is a IRC channel on OFTC to discuss WSL related stuff: #debian-wsl

You can also leave patches and issues at the WSL repo on Salsa.

Known Issues

Any software relying on systemd or low-level hardware accessibility might fail due to missing support from the current Windows kernel or virtualization interface.

systemd support has been added to WSL 2. See description of this above.

As WSL is a pretty new project from Microsoft improvement can be expected to happen with every new Windows stable channel release (approx. every 6 months). The app launcher will be updated to support stable release features continuously.

If WSL itself is installed from Microsoft Store, for example by issuing wsl —update in an elevated PowerShell prompt on the Windows Host, Microsoft claims WSL will be updated more frequently and independently of the Windows stable chanel releases.

FAQ

How do I keep my Debian environment up-to-date

as with any other Debian installation use apt/apt-get to install and update software from the official Debian mirrors (e.g., apt update && apt dist-upgrade)

How do I install a newer release?
You can install the app, change your sources.list and upgrade your install as with every other Debian installation.
How many people are using Debian via WSL?
Approximately 1,746,662 at last count (unique installs according to the Microsoft Partner Center dashboard 2024-11-20).

Code & Issues

The full app code and all build dependencies can be found in the WSL repo on salsa.

Debian is one of the oldest Linux distributions available that is currently being maintained actively. Ubuntu, which is the most popular Linux distribution, is based upon the experimental version ‘Sid’. And Ubuntu in turn acts as a base for numerous operating systems such as Linux Mint, Pop_OS!, Linux Lite, etc. Debian is mostly used by servers around the world because Debian is very stable.

Microsoft has recently updated their WSL or Windows Subsystem for Linux to version 2 (termed WSL2) and the Linux instance installed is more usable for all users now. In this tutorial, we will try to install this Debian Linux on our Windows machine using WSL2.

Enable/Install WSL2

If you are using Windows 11, WSL2 is already installed on your system, and you just have to enable it. We will discuss this after learning to install this on Windows 10. Windows 10 users have to first enable WSL on their system. From the Start Menu, search and run Turn Windows features on or off, and launch it. From Here, enable ‘Virtual Machine Platform‘ and ‘Windows Subsystem for Linux‘ and click OK and restart your PC.

Turn On WSL2

Turn On Windows Subsystem For Linux

Now, search and open ‘PowerShell’ application and right-click upon it to run it as administrator. Now, just type the following command and press the Enter key on your keyboard :

Run Powershell As Administrator From The Start Menu

Run PowerShell As Administrator From The Start Menu
wsl --set-default-version 2
wsl --list --online

If you are using Windows 11, open the ‘PowerShell’ application as Administrator and then run the following command :

wsl --set-default-version 2
wsl --list --online

Installing Debian on WSL2

List Available Distributions On WSL2 1

List of Available Distributions On WSL2

Now, the default version that is installed on your PC is Ubuntu (marked by an asterisk here), to install Debian, you can run the following command :

Installing Debian Using WSL2

Installing Debian Using WSL2

If prompted, you should also reboot your system.

Post installation tweaks

Once you restart your PC, you will see a Terminal window waiting for you asking you to create a Username and Password.

Enter Your Username And Password And You Are Now Done With The Installation

Enter Your Username And Password And You Are Now Done With The Installation

Now, you should also update your system to the latest version using the apt command, type the following in your Debian Machine :

sudo apt update && sudo apt full-upgrade
Update Your Debian Installation

Update Your Debian Installation

Summary

While WSL2 provides the complete command line experience to any developer/user, it is still not a complete replacement for actual Installation on a Virtual machine or on bare metal. Applications do not have hardware acceleration and hence drain the battery more and so on. It is still a good decision from Microsoft as many people will have the exposure to Linux command line and maybe even encourage people to fully switch to the Linux Desktop

References

Microsoft’s Official WSL2 Documentation

Installing Debian on Windows 10/11 using WSL from the command line

I have been using WSL for some time now, and with it Ubuntu on my Windows machine, but since I switched to WSL2, the startup time has increased from «instant» to 10 seconds.

It wouldn’t let me reset it to WSL1, so if I’m going to reinstall WSL for this anyway, I’ll see what other distributions are available besides Ubuntu. Because there are.

If you’ve been reading my blog for a long time, you’ve probably seen me mention that I’m using Windows 10 LTSC. This has many advantages (and disadvantages), I don’t intend to go into them in this article.

One of those disadvantages (for some, for me it’s an advantage) is that it doesn’t have a Microsoft Store. And if you want to use a distribution other than the default Ubuntu, you will need it. Right? No.

So why did I choose Debian?

  1. For one thing, all my servers are running Debian (including Raspberry Pi), so it’s handy.
  2. Secondly, because of its size. If you look at the size in the MS Store linked above, you can currently see that Ubuntu will download 608MB, while Debian requires only 93.5MB. That is a significant difference.Used storage after the installation with Ubuntu:
    WSL Ubuntu size

    Meanwhile the Debian uses:

    WSL Debian size

    Both configured the same way.

The installation of Debian is relatively simple, but it’s hard to find how to do it without the MS Store. That is one of the reasons for this article :)

Let’s get started!

  1. Open a CMD, but with a normal user, no admin rights required.
  2. Set WSL1 as a default:
    wsl.exe --set-default-version 1
  3. List all available distributions:
    wsl.exe --list --online
  4. If you want to install Debian, do so:
    wsl.exe --install -d Debian
  5. Set up your new user by entering your username (in lower case only!) and password twice.
  6. You’re in the Debian. Great! You’re almost done.
  7. Update your system by running:
    sudo apt update && sudo apt upgrade -y
  8. Remember to pin the icon to the taskbar:
  9. If you’d like to check the list of installed distributions, run this command in CMD:
    wsl.exe -l -v

Extra settings

From now on I will only write down what was important for me to get a usable system. You can use the system without these, but if you want to SSH to another machine from here, they will speed things up considerably.

  1. I don’t want to write an article on SSH config, there are good sites for that, e.g. this one. However, to get the TAB autocomplete to work, you need to put these up:
    sudo apt install openssh-client bash-completion
  2. To use sudo without password, the /etc/sudoers file must be edited:
    sudo nano /etc/sudoers
    And replace the line starting with «%sudo» with this:
    %sudo ALL=(ALL) NOPASSWD:ALL
  3. Use «magic» command as an ultimate updater, and add date to the history by editing
    nano /etc/bash.bashrc
    add to the bottom:
    alias magic='sudo apt update && sudo apt dist-upgrade --autoremove -y'
    HISTTIMEFORMAT="%Y-%m-%d %T "
  4. I like to scripting in ksh, so install it:
    sudo apt install ksh
  5. And I also use these tools:
    sudo apt install curl wget
  6. The systemd enabled by default. However, since I don’t use it, I disabled it to save resources:
    sudo nano /etc/wsl.conf

    And add these lines:
    [boot]
    systemd=false

Cover image for Run Debian in Windows 10 with WSL 2

We use Windows in our workstations at my current job (it was not my choice 🙊), but there is a lot of tasks that are easier to do in a Linux environment. Some days ago I needed to manipulate a huge CSV and just thought: «This would be a lot simple with cat, grep, sort, etc.».

So, I remember that I have read something about running Linux inside Windows using WSL and, well, why not give a try?

Setting up the environment

Some considerations:

  • WSL 2 is only available in Windows 10, Version 2004, Build 19041 or higher. Check your Windows version by selecting the Windows logo key + R, type winver, select OK.
  • All Windows commands should be typed in a PowerShell session with administrative privileges unless otherwise specified (right-click in the PowerShell icon and choose «Run as administrator»).

Here we go! Since I’m a command-line lover and do not have a Microsoft account to access Microsoft Store, I’ll do this from there as much as possible. First, let’s install a decent terminal emulator and Microsoft is doing a good job with Windows Terminal. I have downloaded v1.1.2021.0 and renamed it to WindowsTerminal.msixbundle. This is the latest version at the time of writing. The installation is pretty straight forward, just open a PowerShell instance, navigate to the directory where the executable was downloaded and type:

.\WindowsTerminal.msixbundle

Now, click in Instal and wait a few seconds to the windows of Windows Terminal show up. Close this window for now, we need to open it as Administrator soon.

The next step is to enable WSL. Use the same method stated at the top of the article to launch an instance of Windows Terminal with administrative privileges (damn, I wish that there was a «sudo» for this. Maybe Microsoft can launch an «addo» 🙃). Observe that should have a «PS» before your prompt, this indicates that you are in a PowerShell session. Now type:

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

The ‘Virtual Machine Platform’ is needed to run WSL 2. To enable it, just type:

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

You should see «The operation completed successfully.» to both commands. Now reboot your computer.

Once rebooted, open Windows Terminal again and set WSL2 as default:

wsl —set-default-version

If you already have a distribution installed and like to convert it to use WSL2, this is possible. First, check the current status.

wsl —list —verbose

The above command will show a list of installed distributions separated by NAME, STATE, and VERSION. For instance, if you have an Ubuntu installation that is running at version 1 you can type:

wsl —set-version Ubuntu 2

You also can revert it to WSL 1 if you are not satisfied with the result, just change the version number.

Download and installation

Now it is time to download the distribution that you wish to install. I chose Debian because it is very light and stable. Since Windows 10 Spring 2018 Update, curl.exe is present, so let’s use it.

curl.exe -L -o debian.appx https://aka.ms/wsl-debian-gnulinux

The installation step is also quite simple.

Add-AppxPackage .\debian.appx

A strange progress bar will be displayed. Once it disappears, it is done. Now Debian should be available in your applications menu, but don’t click there, use the Windows Terminal do open a Debian session. On the right side of the tab, there is an arrow that hides all the possible sessions.
Clicking on Debian will lead you to the user configuration screen. Choose your username and password and you are done.

Configuration

Now, I recommend that you update installation:

sudo apt update && sudo apt upgrade

Verify the version of Debian that was installed.

cat /etc/os-release

For an unknown reason by me, the downloaded image was still the Stretch version of Debian. No problem, let’s update it to Debian Buster. First, make a backup of your sources.list file.

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

Now, replace every «stretch» entry with «buster». You can do this with nano or vi or directly with sed.

sudo sed -i ‘s/stretch/buster/g’ /etc/apt/sources.list

Then update the system again.

sudo apt update && sudo apt upgrade && sudo apt full-upgrade

Now get rid of obsolete packages in your system.

sudo apt autoremove

Close the Debian tab and open another one to check if you have installed Debian Buster with success.

cat /etc/os-release

You should see something like the below:

PRETTY_NAME="Debian GNU/Linux 10 (buster)"
NAME="Debian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

Final considerations

For a better file system performance, make sure to store your Linux project files in the Linux file system (not the Windows file system).
It is probable that when you open a Debian session your prompt show something like: username@hostname:/mnt/c/Users/username$ This is why WSL exposes the Windows file system through mount points placed in /mnt like /mnt/c and /mnt/d just type cd ~ to go to your real home.

Not only the file system of Windows is exposed by WSL, but you can use Windows applications too, try to type explorer.exe . As you can see, Windows Explorer will open with the files of your current directory loaded.

That is it, everything is set up and ready to use.

Back in 2017, Windows released Windows Subsystem for Linux that lets developers run a GNU/Linux environment, including most command-line tools, utilities, and applications directly in Windows without setting up a virtual machine or dual-boot.

WSL2 has since been released, and it’s an improvement over version 1. The new and improved version comes with performance boost, full system call compatibility, and built with a new architecture and that delivers features that make WSL an amazing way to run a Linux environment in Windows.

To install WSL 2 on Windows 10, these two requirements must be met:

  • Windows 10 May 2020 (2004), Windows 10 May 2019 (1903), or Windows 10 November 2019 (1909) or later
  • A computer with Hyper-V Virtualization support

Since you can now install Linux systems, including Debian directly in Windows, let’s go ahead and install Debian. Before you can do that, you must first enable WSL or WSL2 in Windows.

Enable WSL in Windows

To enable WSL in Windows, you will want to open PowerShell terminal as administrator. Click on Start then begin typing PowerShell.

Next, right-click Windows PowerShell app and choose to run as administrator.

When the console opens, run the commands below:

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

After installing, you should get a success message similar to the lines below:

Deployment Image Servicing and Management tool
Version: 10.0.19041.844

Image Version: 10.0.19042.844

Enabling feature(s)
[==========================100.0%==========================]
The operation completed successfully.

Enable Virtual Machine Platform

WSL 2 requires Windows 10 Virtual Machine Platform to be enabled. This is not Hyper-V. To enable the VM platform feature in Windows, run the commands below from the same PowerShell administrator’s console.

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

If you’re using Windows 10 version lower than 2004, then use the commands below:

Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform -NoRestart

When you’re done running the commands above, restart your computer for all the configuration changes to apply. If you don’t restart, the below command might not be recognized.

After restarting your computer, login back in and launch PowerShell as administrator. Then run the commands below to configure WSL 2 as the default version of WSL.

wsl --set-default-version 2

PS: If you get an error about not having Linux kernel installed, get it from the link below and run it in Windows, then try the command above again.

https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi

Install Debian in Windows 10

Now that WSL 2 is installed and ready to be used, open the link below to download and install a copy of Debian from Windows store.

  • Get Debian – Microsoft Store

Debian on Windows allows you to use Debian Terminal and run Debian command line utilities including bash, ssh, git, apt and many more.

Click the Get button and install. After installing Debian, you’ll want the option to launch Debian from Windows WSL environment.

After downloading and installing, you will get a Launch button.

After launching Debian, it should install and prompt to create your account.

Installing, this may take a few minutes…
Please create a default UNIX user account. The username does not need to match your Windows username.
For more information visit: https://aka.ms/wslusers
Enter new UNIX username: ngubri
New password:
Retype new password:
passwd: password updated successfully
Installation successful!
ngubri@DESKTOP-M1235UB:~$

That should do it!

Some troubleshooting commands to run when you run into issues.

wsl --set-default-version 1
bcdedit /set hypervisorlaunchtype auto start

Now simply launch Debian from Windows start by searching for it. You can also pin it to the taskbar and always have it launch from there.

That should do it!

To ensure that WSL 2 is enabled in your system, open the Windows command prompt and run the below-mentioned command:

 wsl -l -v
 //OR
 wsl --list --verbose

Note that the above command only works on Windows build version “18362” and higher. If the output indicates the WSL version properly, that means WSL 2 is enabled in your system:

If you are still running the WSL version 1, then use the following command to enable WSL 2:

 wsl --set-default-version 2

Though WSL 2 is the latest version, there are still some features that are only supported by WSL 1, such as quick access to files stored on Windows, serial port support, etc. So to set a specific version of WSL to a specific distribution, use the command:

wsl --set-version [distro_name] [wsl_version_number]

Replace the “[distro_name]” with the Linux distribution name and mentioned the WSL version in the place of “[wsl_version_number].” (example: wsl –set-version Debian 2)

Conclusion:

WSL is a Windows feature that allows Windows 10 users to run Linux on Windows 10 natively. There are two main versions of WSL; WSL 2 is the updated version of WSL 1 and supports all system calls, and 20% faster than its predecessor.WSL converts the Linux calls into windows calls and executes them, though WSL 2 has its own specifically designed kernel that no longer needed call system translation. After enabling WSL in Windows and installing Linux distribution, you can use bash shell for all compatible utilities. It is quite helpful for developers who are interested to learn Linux on Windows.

WSL 2 uses an actual Linux kernel that allows Linux containers. WSL 1 was genius with running Linux on the Windows kernel, but of course lacked some of the features, such as containers. 

Although the WSL 2 is the current and overhauled version, some exceptions might make you use WSL 1. Which version you should use is a personal choice, but I would recommend going with WSL 2 because it is efficient and allows you to install Linux updates easily.

Reference:

https://websiteforstudents.com/

Понравилась статья? Поделить с друзьями:
0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии
  • Kms активатор windows 10 прямая ссылка
  • Не работает tor browser на windows 11
  • Загрузите этот файл в кодировке utf 8 или windows 1251 или замените на другой
  • Windows 10 перезапуск видеодрайвера
  • Rsync windows 10 install