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系統。

進入系統後,  在命令行默認安裝的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

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章