Windows Subsystem for Linux

http://www.oschina.net/news/72834/windows-subsystem-for-linux?p=3

微软正式宣布 Bash on Ubuntu on Windows 功能已经可通过 Windows Subsystem for Linux (WSL) 原生支持 Linux ELF64 二进制文件在 Windows 10 中执行。WSL 是由微软 Windows Kernel 团队开发的,自上月宣布并在 Windows Insider Build 版本中提供试用以来,很多用户都开始关注并有兴趣知道 Windows Kernel Team 是如何建立该子系统的。

为回应用户关注,微软在 Channel 9 视频 中对 Windows Subsystem for Linux 进行了概述、回答了 WSL 的常见问题并披露了相关实现细节。虽然我们前文对 Ubuntu on Windows 10 的工作方式 也进行过简要解析,还是一起在看看微软的官方回应。

WSL 是支持原生 Linux ELF64 二进制文件在 Windows 上运行的组件集合,它包含用户模式和内核模式组件:

  • 用户模式会话管理器服务处理 Linux 实例的生命周期

  • Pico 提供者驱动程序(lxss.sys, lxcore.sys)模拟 Linux kernel 翻译 Linux 系统调用

  • Pico 进程托管未修改的用户模式 Linux(例如 /bin/bash)

奇迹就发生在用户模式 Linux 二进制文件和 Windows Kernel 之间,通过 Pico 进程中的 Linux 二进制文件可以将 Linux 系统调用导向到 Windows kernel,而 lxss.sys 和 lxcore.sys 驱动则负载将 Linux 系统调用翻译成 NT API 和模拟 Linux Kernel。

在新版 Win10 中启用 Linux Bash 环境

http://jingyan.baidu.com/article/aa6a2c14e347010d4c19c48f.html

卸载wsl子系统

wslconfig /l  #显示出你安装的列表。
wslconfig /u debian #debian为上述列表中的名字   注销子系统

wsl硬盘迁移:

1. 打开管理员权限的PowerShell

2. wsl -l -v 查询要迁移的系统名称

PS C:\Users\xxx> wsl -l -v
  NAME            STATE           VERSION
* Ubuntu-16.04    Running         2

3. 迁移

wsl --export Ubuntu-16.04 x:\Ubuntu_bak.tar
wsl --unregister Ubuntu-16.04

4 导入

wsl --import Ubuntu-16.04 D:\Ubuntu D:\Ubuntu_bak.tar --version 2

5. 修改用户名

这种导入的版本,不能直接用

XXXX config --default-user aaa  // //XXXX 为wsl -l -v查到的名称, aaa为用户名

需要在ubunt中新建一个用户(不是改名,是新建,带文件夹的那种)

在ubuntu下新建/etc/wsl.conf

内容参考:

# Automatically mount Windows drive when the distribution is launched
[automount]

# Set to true will automount fixed drives (C:/ or D:/) with DrvFs under the root directory set above. Set to false means drives won't be mounted automatically, but need to be mounted manually or with fstab.
enabled = true

# Sets the directory where fixed drives will be automatically mounted. This example changes the mount location, so your C-drive would be /c, rather than the default /mnt/c. 
root = /

# DrvFs-specific options can be specified.  
options = "metadata,uid=1003,gid=1003,umask=077,fmask=11,case=off"

# Sets the `/etc/fstab` file to be processed when a WSL distribution is launched.
mountFsTab = true

# Network host settings that enable the DNS server used by WSL 2. This example changes the hostname, sets generateHosts to false, preventing WSL from the default behavior of auto-generating /etc/hosts, and sets generateResolvConf to false, preventing WSL from auto-generating /etc/resolv.conf, so that you can create your own (ie. nameserver 1.1.1.1).
[network]
hostname = bbb
generateHosts = false
generateResolvConf = false

# Set whether WSL supports interop process like launching Windows apps and adding path variables. Setting these to false will block the launch of Windows processes and block adding $PATH environment variables.
[interop]
enabled = false
appendWindowsPath = false

# Set the user when launching a distribution with WSL.
[user]
default = aaa

# Set a command to run when a new WSL instance launches. This example starts the Docker container service.
[boot]
command = service docker start

解决wsl2下ubuntu乱码的问题

sudo dpkg-reconfigure locales
空格选中:en_US.UTF-8, zh_CN.UTF-8, 使用tab切换到ok, 再选en_US.UTF-8为默认。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值