Win10 开启 Ubuntu 及Ubuntu升级过程中的部分问题

操作环境:

Win10Home-x64-version1903        i3-3110M       DRAM-10GB

Win10-verison1709开始陆续支持了linux子系统服务,可以在Win10中启用linux支持,启用方式比较简单,主要分以下两步:
  1. 控制面板 => 程序(窗口左侧) => 程序和功能 => 开启和关闭Windows功能 => 勾选Windows子系统Linux
  2. 设置 => windows更新&安全 => 开发者选项 => 勾选开发者模式

子系统安装方式可以通过命令行,也可以通过windows应用商店,或者到微软官网、ubuntu官网下载安装(文章最底下有链接,可以下载),下面采用的是命令行安装,期间存在不少问题。

重启计算机,cmd命令行输入bash进入linux(ubuntu版本)系统,此时会提示下载linux系统,输入y继续,等待下载完毕,设置用户名密码,后续默认bash命令采用此时设置的用户名登陆linux系统。

Win10 开启 Ubuntu 及Ubuntu升级过程中的部分问题_第1张图片

进入系统后,  在命令行默认安装的ubuntu为14.04版本,很老旧啊...,目前最新的大概已经到18.04了,而且14.04已经不再维护,16.04维护至2021,18.04维护至2023..

紧接着进行系统更新,首先修改apt源,如果访问国外网络比较好也可以直接用默认的,此处修改为中科大的源(可以根据需要到网上找一找,国内的源比较多,我这连接中科大速度比较快就用的中科大).

首先备份默认源配置,然将国内源内容贴到sources.list中:

mv etc/apt/sources.list etc/apt/sources.list.def

vi /etc/apt/sources.list  把下面内容贴进去(贴入方式,鼠标移到对话框标题左键点击,弹出的菜单中编辑->粘贴)

 

# 中科大 deb-src为源文件,此处只是用二进制的包所以把源文件的源注释掉了
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
# source file
#deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
#deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
#deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
#deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse

# 预览版源一般不需要开启,有时候系统软件存在bug时,可能会将修复后的发布至预览版,如果需要修复某些重要的问题可以开启 preview version
#deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
# deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse

 更新系统及软件:apt-get update & apt-get upgrade

此时出现第一个问题:

...........省略.............
Get:1 https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates/main tar amd64 1.29b-2ubuntu0.1 [234 kB]
Fetched 234 kB in 1s (118 kB/s)
Extracting templates from packages: 100%
Preconfiguring packages ...
dpkg-deb: error: archive '/var/cache/apt/archives/libc-bin_2.27-3ubuntu1_amd64.deb' has premature member 'control.tar.xz' before 'control.tar.gz', giving up
dpkg: error processing archive /var/cache/apt/archives/libc-bin_2.27-3ubuntu1_amd64.deb (--unpack):
 subprocess dpkg-deb --control returned error exit status 2
dpkg-deb: error: archive '/var/cache/apt/archives/locales_2.27-3ubuntu1_all.deb' has premature member 'control.tar.xz' before 'control.tar.gz', giving up
dpkg: error processing archive /var/cache/apt/archives/locales_2.27-3ubuntu1_all.deb (--unpack):
 subprocess dpkg-deb --control returned error exit status 2
dpkg-deb: error: archive '/var/cache/apt/archives/libc6_2.27-3ubuntu1_amd64.deb' has premature member 'control.tar.xz' before 'control.tar.gz', giving up
dpkg: error processing archive /var/cache/apt/archives/libc6_2.27-3ubuntu1_amd64.deb (--unpack):
 subprocess dpkg-deb --control returned error exit status 2
Errors were encountered while processing:
 /var/cache/apt/archives/libc-bin_2.27-3ubuntu1_amd64.deb
 /var/cache/apt/archives/locales_2.27-3ubuntu1_all.deb
 /var/cache/apt/archives/libc6_2.27-3ubuntu1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

出现此问题,主要原因是:dpkg版本过低,但是apt-get update命令更新得到的软件包采用了新的软件包结构,导致默认的dpkg工具无法识别进而出现错误:..xxx... has premature member 'control.tar.xz' before 'control.tar.gz', giving up。

(ubuntu系统中的dpkg是一个命令行管理工具用于安装、删除、卸载、管理系统上的软件等。)

此时需要将dpkg升级到新版,由于dpkg版本在1.17.5ubuntu5.8以后开始都采用了新的软件结构,因此升级时候,无法直接升级到最新版本,需要将dpkg先升级到1.17.5ubuntu5.8,才能后续升级到更高的版本。

升级步骤如下:

# 新建一个目录下载1.17.5ubuntu5.8版本的dpkg安装包
root@TOM:/var/lib/dpkg-fix# mkdir dpkg-fix
root@TOM:/var/lib/dpkg-fix# cd dpkg-fix
root@TOM:/var/lib/dpkg-fix# wget https://launchpad.net/ubuntu/+archive/primary/+files/dpkg_1.17.5ubuntu5.8_amd64.deb
--2019-11-23 17:55:27--  https://launchpad.net/ubuntu/+archive/primary/+files/dpkg_1.17.5ubuntu5.8_amd64.deb
Resolving launchpad.net (launchpad.net)... 91.189.89.222, 91.189.89.223, 2001:67c:1560:8003::8003, ...
Connecting to launchpad.net (launchpad.net)|91.189.89.222|:443... connected.
HTTP request sent, awaiting response... 303 See Other
Location: https://launchpadlibrarian.net/359699265/dpkg_1.17.5ubuntu5.8_amd64.deb [following]
--2019-11-23 17:55:34--  https://launchpadlibrarian.net/359699265/dpkg_1.17.5ubuntu5.8_amd64.deb
Resolving launchpadlibrarian.net (launchpadlibrarian.net)... 91.189.89.228, 91.189.89.229, 2001:67c:1560:8003::8008, ...
Connecting to launchpadlibrarian.net (launchpadlibrarian.net)|91.189.89.228|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1957810 (1.9M) [application/x-debian-package]
Saving to: ‘dpkg_1.17.5ubuntu5.8_amd64.deb’

dpkg_1.17.5ubuntu5.8_amd64.deb   100%[========================================================>]   1.87M  11.9KB/s    in 2m 59s

2019-11-23 17:58:40 (10.7 KB/s) - ‘dpkg_1.17.5ubuntu5.8_amd64.deb’ saved [1957810/1957810]
root@TOM:/var/lib/dpkg-fix# dpkg -i dpkg_1.17.5ubuntu5.8_amd64.deb
(Reading database ... 25197 files and directories currently installed.)
Preparing to unpack dpkg_1.17.5ubuntu5.8_amd64.deb ...
Unpacking dpkg (1.17.5ubuntu5.8) over (1.17.5ubuntu5.7) ...
Setting up dpkg (1.17.5ubuntu5.8) ...
Processing triggers for man-db (2.7.5-1) ...

升级完毕,dpkg就可以安装新版本软件结构的安装包了。

继续执行apt-get update和apt-get upgrade,此时出现第二个问题:

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = (unset),
        LC_ALL = (unset),
        LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_ALL to default locale: No such file or directory
(Reading database ... 25218 files and directories currently installed.)
Preparing to unpack .../libc-bin_2.27-3ubuntu1_amd64.deb ...
dpkg: error processing archive /var/cache/apt/archives/libc-bin_2.27-3ubuntu1_amd64.deb (--unpack):
 triggers ci file contains unknown directive `interest-await'
Errors were encountered while processing:
 /var/cache/apt/archives/libc-bin_2.27-3ubuntu1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

先处理上面的perl: warning: xxxx, 处理方式如下

cd ~
vi .bashrc   
# 行尾加入 然后wq
export LC_ALL=C

source .bashrc

下面这个错误triggers ci file contains unknown directive `interest-await'是由于dpkg包安装工具过低导致,需要再次升级将之前升级的的dpkg_1.17.5ubuntu5.8_amd64.deb升级到dpkg_1.18.4ubuntu1_amd64.deb,注意有1.17.5升级必须先升级到1.18.4ubuntu1版本,如果跳过这个版本,无法升级成功,会出现大量包依赖问题(作为一个菜鸡, 饶了好大的弯,linux是个好东西需要系统学习一下)。

dpkg -i dpkg_1.18.4ubuntu1_amd64.deb
dpkg --version

升级完成后,继续进行系统软件升级,apt-get -f dist-upgrade (该命令与upgrade命令的区别是dist-upgrade会自动处理依赖关系中有问题的包,自动安装/删除不满足依赖关系的包,-f是--fix-broken自动修复依赖关系,更多man apt-get查看)。

执行命令后,等待更新package完成,期间会有提示reboot操作,ok重启即可。

最后执行完成,又出现下面错误:‘xxxx....org.freedesktop.systemd1.conf' is not an absolute path

Removing systemd-shim (6-2bzr1) ...
dpkg-maintscript-helper: error: old-conffile 'debian/systemd-shim/etc/dbus-1/system.d/org.freedesktop.systemd1.conf' is
not an absolute path
dpkg: error processing package systemd-shim (--remove):
 installed systemd-shim package pre-removal script subprocess returned error exit status 1
dpkg-maintscript-helper: error: old-conffile 'debian/systemd-shim/etc/dbus-1/system.d/org.freedesktop.systemd1.conf' is
not an absolute path
dpkg: error while cleaning up:
 installed systemd-shim package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 systemd-shim
E: Sub-process /usr/bin/dpkg returned an error code (1)

systemd-shim的安装、卸载前后脚本执行( /var/lib/dpkg/info/systemd-shim.preinst/postinst/prerm/postrm)错误,说是目录不是绝对路径, 应该是systemd-shim版本问题,下载新版并安装(warning应该不影响吧...)

wget http://ftp.sjtu.edu.cn/ubuntu/pool/main/s/systemd-shim/systemd-shim_9-1bzr4ubuntu1_amd64.deb
dpkg -i systemd-shim_9-1bzr4ubuntu1_amd64.deb

Selecting previously unselected package systemd-shim.
(Reading database ... 27189 files and directories currently installed.)
Preparing to unpack systemd-shim_9-1bzr4ubuntu1_amd64.deb ...
dpkg-maintscript-helper: error: old-conffile 'debian/systemd-shim/etc/dbus-1/system.d/org.freedesktop.systemd1.conf' is
not an absolute path
dpkg: warning: old systemd-shim package pre-removal script subprocess returned error exit status 1
dpkg: trying script from the new package instead ...
dpkg: ... it looks like that went OK
Leaving 'diversion of /usr/share/dbus-1/system-services/org.freedesktop.systemd1.service to /usr/share/dbus-1/system-ser
vices/org.freedesktop.systemd1.service.systemd by systemd-shim'
Unpacking systemd-shim (9-1bzr4ubuntu1) over (6-2bzr1) ...
dpkg-maintscript-helper: error: old-conffile 'debian/systemd-shim/etc/dbus-1/system.d/org.freedesktop.systemd1.conf' is
not an absolute path
dpkg: warning: old systemd-shim package post-removal script subprocess returned error exit status 1
dpkg: trying script from the new package instead ...
dpkg: ... it looks like that went OK
dpkg: dependency problems prevent configuration of systemd-shim:
 systemd-shim depends on libglib2.0-0 (>= 2.39.4); however:
  Package libglib2.0-0:amd64 is not configured yet.
 systemd-shim depends on cgmanager (>= 0.32); however:
  Package cgmanager is not installed.

执行apt -f full-upgrade 更新整个系统软件(包括ubuntu系统)  , 他么的还一大堆问题,先告一段落,he~~e~~~~tui!!!!

参考:

microsoft-wsl

ubuntu-on-windows

ubuntu-dpkg-bug

ubuntu-dpkg-upgrade

dpkg-download

ftp-ubuntu-libs

xenial-libs

 

 

 

你可能感兴趣的:(Linux,Win10)