## 缘起
目前如式机上使用的ubuntu系统是很多年前装的系统,12.04。很多软件无法安装,如wine、understand,第三方提供的调试库有不支持12.04(编译不了)。所以决定升级系统
## 目标
把ubuntu12.04升级到16.04(台式机上的ubuntu与笔记本上的版本一致)
升级操作
```
sudo apt-get update
sudo apt-get upgrade
sudo do-release-upgrade
```
升级到14.04时,需要重新设置一下ubuntu 的“源”
然后再执行同样的操作。
## 所遇到的问题
ubuntu12.04无法直接升级到16.04,只能先升级到14.04,然后再升级到16.04。升级到14.04时正常,但从14.04升级到16.04时,重启一直卡在‘ubuntu’ 开机界面,下面的循环点一直在动,但就是进入不了系统。</br>
1. 试着按CTRL+ALT+F1进入控制台模式,发现按组合键无效。但此时按F1键会进入控制台登录模式,但此时的键盘录入有问题。无法正确进入控制台命令行模式。
2. 上述方法未能进入控制台模式,重启ubuntu,一直按SHIFT键,会弹出选项,选择进入“恢复模式”。进入恢复模式时,再按CTRL+ALT+F1,此时键盘是有效的。
3. 进入控制台模式时,本来想执行以下命令的,发现apt-get 出错。
```
sudo apt-get install --reinstall ubuntu-desktop
sudo reboot
```
结果提示libstdc++.so.6 出错,类似如下信息
*not defined in file libstdc++.so.6*
4. 对于上述错误解决方法
```
wget http://security.ubuntu.com/ubuntu/pool/main/g/gcc-5/libstdc++6_5.4.0-6ubuntu1~16.04.10_amd64.deb
sudo dpkg -i libstdc++6_5.4.0-6ubuntu1~16.04.10_amd64.deb
# I also found this helpful
sudo apt-get -f install
```
**注意**:这里的 *16.04.10_amd64.deb* ***10***会随着版本变化而变化。目前最新的版本是**12**所以写的应该是**16.04.12_amd64.deb**
5. 4的问题解决后,重新执行3的步骤。重启,能正常进入ubuntu界面。
f.进入ubuntu界面后发现终端打不开,报错信息如下
```
liu@ubuntu:~$ gnome-terminal
(process:2286): Gtk-WARNING **: Locale not supported by C library.
Using the fallback 'C' locale.
Error constructing proxy for org.gnome.Terminal:/org/gnome/Terminal/Factory0: Error calling StartServiceByName for org.gnome.Terminal: GDBus.Error:org.freedesktop.DBus.Error.Spawn.ChildExited: Process org.gnome.Terminal exited with status 9
liu@ubuntu:~$
```
6. 为了解决终端不能打开的问题,进行了一些尝试。
```
sudo apt install dconf-cli
dconf reset -f /org/gnome/terminal
sudo apt-get remove gnome-terminal
sudo apt-get install gnome-terminal
sudo locale-gen --purge
sudo dpkg-reconfigure locales
reboot
```
执行上述操作的显示
```
liu@ubuntu:~$ sudo apt install dconf-cli
Reading package lists... Done
Building dependency tree
Reading state information... Done
dconf-cli is already the newest version (0.24.0-2).
dconf-cli set to manually installed.
The following packages were automatically installed and are no longer required:
account-plugin-identica account-plugin-twitter fcitx-libs fcitx-libs-gclient fcitx-libs-qt gir1.2-ebook-1.2 gir1.2-ebookcontacts-1.2
gir1.2-edataserver-1.2 gir1.2-messagingmenu-1.0 gir1.2-networkmanager-1.0 lib32atomic1 lib32itm1 libjbig-dev liblzma-dev libtiff5-dev libtiffxx5
linux-image-3.13.0-170-generic linux-modules-3.13.0-170-generic linux-modules-extra-3.13.0-170-generic
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
liu@ubuntu:~$ dconf reset -f /org/gnome/terminal
liu@ubuntu:~$ sudo apt-get remove gnome-terminal
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
account-plugin-identica account-plugin-twitter fcitx-libs fcitx-libs-gclient fcitx-libs-qt gir1.2-ebook-1.2 gir1.2-ebookcontacts-1.2
gir1.2-edataserver-1.2 gir1.2-messagingmenu-1.0 gir1.2-networkmanager-1.0 lib32atomic1 lib32itm1 libjbig-dev liblzma-dev libtiff5-dev libtiffxx5
linux-image-3.13.0-170-generic linux-modules-3.13.0-170-generic linux-modules-extra-3.13.0-170-generic
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
gnome-terminal
0 upgraded, 0 newly installed, 1 to remove and 1 not upgraded.
After this operation, 1138 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 281439 files and directories currently installed.)
Removing gnome-terminal (3.18.3-1ubuntu1) ...
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for libglib2.0-0:amd64 (2.48.2-0ubuntu4.8) ...
Processing triggers for desktop-file-utils (0.22-1ubuntu5.2) ...
Processing triggers for mime-support (3.59ubuntu1) ...
Processing triggers for gnome-menus (3.13.3-6ubuntu3.1) ...
Processing triggers for bamfdaemon (0.5.3~bzr0+16.04.20180209-0ubuntu1) ...
Rebuilding /usr/share/applications/bamf-2.index...
liu@ubuntu:~$ sudo apt-get install gnome-terminal
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
account-plugin-identica account-plugin-twitter fcitx-libs fcitx-libs-gclient fcitx-libs-qt gir1.2-ebook-1.2 gir1.2-ebookcontacts-1.2
gir1.2-edataserver-1.2 gir1.2-messagingmenu-1.0 gir1.2-networkmanager-1.0 lib32atomic1 lib32itm1 libjbig-dev liblzma-dev libtiff5-dev libtiffxx5
linux-image-3.13.0-170-generic linux-modules-3.13.0-170-generic linux-modules-extra-3.13.0-170-generic
Use 'sudo apt autoremove' to remove them.
The following NEW packages will be installed:
gnome-terminal
0 upgraded, 1 newly installed, 0 to remove and 1 not upgraded.
Need to get 0 B/162 kB of archives.
After this operation, 1138 kB of additional disk space will be used.
Selecting previously unselected package gnome-terminal.
(Reading database ... 281420 files and directories currently installed.)
Preparing to unpack .../gnome-terminal_3.18.3-1ubuntu1_amd64.deb ...
Unpacking gnome-terminal (3.18.3-1ubuntu1) ...
Processing triggers for desktop-file-utils (0.22-1ubuntu5.2) ...
Processing triggers for mime-support (3.59ubuntu1) ...
Processing triggers for gnome-menus (3.13.3-6ubuntu3.1) ...
Processing triggers for bamfdaemon (0.5.3~bzr0+16.04.20180209-0ubuntu1) ...
Rebuilding /usr/share/applications/bamf-2.index...
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for libglib2.0-0:amd64 (2.48.2-0ubuntu4.8) ...
Setting up gnome-terminal (3.18.3-1ubuntu1) ...
liu@ubuntu:~$ sudo locale-gen --purge
Generating locales (this might take a while)...
en_AG.UTF-8... done
en_AU.UTF-8... done
en_BW.UTF-8... done
en_CA.UTF-8... done
en_DK.UTF-8... done
en_GB.UTF-8... done
en_HK.UTF-8... done
en_IE.UTF-8... done
en_IN.UTF-8... done
en_NG.UTF-8... done
en_NZ.UTF-8... done
en_PH.UTF-8... done
en_SG.UTF-8... done
en_US.UTF-8... done
en_ZA.UTF-8... done
en_ZM.UTF-8... done
en_ZW.UTF-8... done
Generation complete.
```
重装后还是出错。查看python版本,看是否是python版本引起的。
重新安装python3的版本
```
sudo apt-get --reinstall install python3-minimal
```
查看:
```
liu@ubuntu:~$ ls -larth `which python`*
lrwxrwxrwx 1 root root 10 Mar 23 2016 /usr/bin/python3m -> python3.5m
lrwxrwxrwx 1 root root 9 Mar 23 2016 /usr/bin/python3 -> python3.5
-rwxr-xr-x 1 root root 306 Mar 26 2016 /usr/bin/pythontex3
lrwxrwxrwx 1 root root 58 Mar 26 2016 /usr/bin/pythontex -> ../share/texlive/texmf-dist/scripts/pythontex/pythontex.py
lrwxrwxrwx 1 root root 16 Nov 24 2017 /usr/bin/python2-config -> python2.7-config
lrwxrwxrwx 1 root root 9 Nov 24 2017 /usr/bin/python2 -> python2.7
lrwxrwxrwx 1 root root 16 Nov 24 2017 /usr/bin/python-config -> python2.7-config
-rwxr-xr-x 2 root root 4.3M Jan 27 02:48 /usr/bin/python3.5m
-rwxr-xr-x 2 root root 4.3M Jan 27 02:48 /usr/bin/python3.5
-rwxr-xr-x 1 root root 3.4M Mar 2 04:47 /usr/bin/python2.7
lrwxrwxrwx 1 root root 33 Mar 2 04:47 /usr/bin/python2.7-config -> x86_64-linux-gnu-python2.7-config
lrwxrwxrwx 1 root root 24 Jun 7 14:41 /usr/bin/python -> /etc/alternatives/python
```
当前设置的版本为python2.7 ,指定python的版本为3.5
```
sudo update-alternatives --config python
```
发现没有关于python3.5的选项,于是把python3.5增加进选项中,默认设置使用py3.5的版本(再执行一下 --config python 选择3)
```
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.5 3
```
重启,发现设置默认python后还是不行,且会带来其它的问题。后面又设置回去。
h.最后在**/etc/default/locale**设置
```
LC_ALL="en_US.UTF-8"
```
系统的gnome-terminal 终端能运行起来了,但是terminator 却又不能打开。好在terminator 终端一般不怎么用。暂时不管它。