当前位置: 首页 > web >正文

wsl安装linux

安装wsl

启用适用于 Linux 的 Windows 子系统

以管理员身份打开 PowerShell (> PowerShell > 右键单击 > 以管理员身份运行) 并输入以下命令,然后重启

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

启用虚拟机功能

以管理员身份打开 PowerShell 并运行,然后重启

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

下载 Linux 内核更新包

wsl_update_x64.msi

将 WSL 2 设置为默认版本

wsl --set-default-version 2

更新 WSL

wsl --update

wsl基本命令

关机

wsl --shutdown

终止

wsl --terminate

更新 WSL

wsl --update

关闭wsl

wsl --shutdown

导出wsl

wsl --export Ubuntu-20.04 G:\WSL\myUbuntu.tar

注销原来的wsl

wsl --unregister Ubuntu-20.04

列出已安装的 Linux 分发版

wsl --list --verbose
wsl -l -v

恢复原来的用户名

myUsername=bo
echo -e “[user]\ndefault=$myUsername” >> /etc/wsl.conf

导入已有vhdx文件

wsl --import-in-place

wsl --import-in-place Ubuntu20.04 D:\wslubuntu\backup\ext4.vhdx

导入新的wsl

wsl --import WSL名称 安装目录 WSL压缩包文件地址

wsl --import Ubuntu-20.04 D:\wslubuntu\ D:\wslubuntu\ubuntu.tar --version 2

wsl config配置

Windows 文件资源管理器并在地址栏中输入 %UserProfile%。 该目录路径应类似于:C:\Users\<UserName>\.wslconfig

# Settings apply across all Linux distros running on WSL 2
[wsl2]# Limits VM memory to use no more than 4 GB, this can be set as whole numbers using GB or MB
memory=4GB # Sets the VM to use two virtual processors
processors=2# Specify a custom Linux kernel to use with your installed distros. The default kernel used can be found at https://github.com/microsoft/WSL2-Linux-Kernel
kernel=C:\\temp\\myCustomKernel# Specify the modules VHD for the custum Linux kernel to use with your installed distros.
kernelModules=C:\\temp\\modules.vhdx# Sets additional kernel parameters, in this case enabling older Linux base images such as Centos 6
kernelCommandLine = vsyscall=emulate# Sets amount of swap storage space to 8GB, default is 25% of available RAM
swap=8GB# Sets swapfile path location, default is %USERPROFILE%\AppData\Local\Temp\swap.vhdx
swapfile=C:\\temp\\wsl-swap.vhdx# Disable page reporting so WSL retains all allocated memory claimed from Windows and releases none back when free
pageReporting=false# Turn on default connection to bind WSL 2 localhost to Windows localhost. Setting is ignored when networkingMode=mirrored
localhostforwarding=true# Disables nested virtualization
nestedVirtualization=false# Turns on output console showing contents of dmesg when opening a WSL 2 distro for debugging
debugConsole=true# Enable experimental features
[experimental]
sparseVhd=true
http://www.xdnf.cn/news/10451.html

相关文章:

  • 测试总结(二)
  • Python 验证码识别(使用pytesseract库)
  • JVM——JVM运行时数据区的内部机制是怎样的?
  • unix/linux source 命令,在当前的 Shell 会话中读取并执行指定文件中的命令
  • 【AI学习】检索增强生成(Retrieval Augmented Generation,RAG)
  • Vue拖拽组件:vue-draggable-plus
  • 神经网络与Transformer详解
  • Ansible 剧本精粹 - 编写你的第一个 Playbook
  • Spring Boot 4.0实战:构建高并发电商系统
  • 通过内核寄存器排除HardFault
  • uni-app学习笔记十七-css和scss的使用
  • 振动力学:无阻尼单自由度系统
  • 【数据结构】顺序表和链表详解(上)
  • 图文详解Java并发面试题
  • 基于Canvas实现抽奖转盘
  • 打打基础 | 从翻转链表到寄存器、汇编与内存
  • 智慧新基建数字孪生,绘就桥梁运维新画卷
  • 【STM32F407 PWM配置和应用指南 】
  • [yolov11改进系列]基于yolov11引入上下文锚点注意力CAA的python源码+训练源码
  • Spring Boot中的事件与JMS消息集成
  • Windows搭建Swift语言编译环境?如何构建ObjC语言编译环境?Swift如何引入ObjC框架?Interface Builder的历史?
  • 【论文复现】水下单光子激光雷达设计 Sequential Multimodal Underwater Single
  • PySide6 GUI 学习笔记——常用类及控件使用方法(地址类QUrl)
  • Vert.x学习笔记-EventLoop与Context的关系
  • 图像处理篇---face_recognition库实现人脸检测
  • Linux系统之gettext详解
  • Excel to JSON 插件 2.4.0 版本更新
  • 【java面试】redis篇
  • 【Linux系统】第八节—进程概念(上)—冯诺依曼体系结构+操作系统+进程及进程状态+僵尸进程—详解!
  • 【请关注】ELK集群部署真实案例分享