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

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

相关文章:

  • 【火山引擎 大模型批量处理数据教程-详细】
  • 从前端工程化角度解析 Vite 打包策略:为何选择 Rollup 而非 esbuild。
  • Windows搭建Swift语言编译环境?如何构建ObjC语言编译环境?Swift如何引入ObjC框架?Interface Builder的历史?
  • 数据库,Spring Boot,数据源
  • Unity Mono与IL2CPP比较
  • 【CF】Day72——Codeforces Round 890 (Div. 2) CDE1 (二分答案 | 交互 + 分治 | ⭐树上背包)
  • 多模态大语言模型arxiv论文略读(103)
  • Java抽象工厂模式详解
  • 【计算机网络】第3章:传输层—面向连接的传输:TCP
  • Linux下目录递归拷贝的单进程实现
  • RuoYi前后端分离框架实现前后端数据传输加密(二)之前端篇
  • 如何用docker部署ELK?
  • 设计模式——观察者设计模式(行为型)
  • 在 SpringBoot+Tomcat 环境中 线程安全问题的根本原因以及哪些变量会存在线程安全的问题。
  • 设计模式——桥接设计模式(结构型)
  • NodeJS全栈开发面试题讲解——P1Node.js 基础与核心机制
  • java servlet: context-path的作用
  • 基于GeoTools和OSM路网求解两条道路相交点-以长沙市为例
  • 视觉分析明火检测助力山东化工厂火情防控
  • 【寻找Linux的奥秘】第九章:自定义SHELL
  • 属于网站建设过程规划/微商引流的最快方法是什么
  • 三大门户网站/百度快速排名 搜
  • 网站和虚拟服务器/营销网站建设免费
  • 阳江 网站建设/如何接广告赚钱
  • 广告设计图案/网站推广优化的方法
  • 个人网站的建设方法和过程/百度首页登录