升级Ubuntu系统的Glibc版本
How to upgrade the Ubuntu system Glibc version?
————————————————————
注意: 以下内容以本人定制发行的 Ubuntu 18.04 CN原版系统为例。
查询当前系统使用的版本
ldd --version
检查系统中支持的Glibc:
strings /lib/x86_64-linux-gnu/libc.so.6 | grep GLIBC_
1. 从Debian获取升级
添加源到/etc/apt/sources.list
文件:
deb http://mirrors.ustc.edu.cn/debian-security buster/updates main
更新源:
sudo apt update
提示没有公钥,无法验证下列签名“ NO_PUBKEY 112695A0E562B32A NO_PUBKEY 54404762BBB6E853
”,把这俩签名换到下面这里:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 112695A0E562B32A 54404762BBB6E853
重新更新源后,查看更新列表:
sudo apt update
sudo apt list --upgradable
安装libc6更新:
sudo apt install libc6-dev libc6
检查更新:
strings /lib/x86_64-linux-gnu/libc.so.6 | grep GLIBC_
2. 从源码升级
官方:http://ftp.gnu.org/gnu/glibc/glibc-2.28.tar.xz
国内:
2.1 安装编译依赖
sudo apt install build-essential gawk bison
2.2 编译
$ tar -xvf glibc-2.28.tar.xz
$ cd glibc-2.28/
$ mkdir build
$ cd build
$ ../configure --prefix=/usr/local --disable-sanity-checks
$ make
2.3 安装
sudo make install
安装完毕后,检查结果:
lets@ubt:/work/glibc-2.28/build$ ldd --version
ldd (GNU libc) 2.28
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.
3. 安装报错
1. 找不到文件: /usr/local/etc/ld.so.conf
......
/work/glibc-2.28/build/elf/ldconfig: Warning: ignoring configuration file that cannot be opened: /usr/local/etc/ld.so.conf: No such file or directory
make[1]: Leaving directory '/work/glibc-2.28'
解决办法:执行下面这个后重新安装一次
lets@ubt:/work/glibc-2.28/build$ sudo cp /etc/ld.so.conf /usr/local/etc/ld.so.conf
2. 解决进入桌面的白色错误弹窗
弹窗的内容:
Error found when loading /etc/profile
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
As a result the session will not be configured correctly.
You should fix the problem as soon as possible.
问题是GLIBC_2.28中只有C和POSIX, 没有en_US.UTF-8,因此出现错误,换言之,在根据上述步骤安装glibc-2.28时,缺少locale文件的安装指令; 与此相对比的是en_UTF-8在旧的的GLIBC_2.27对应的/usr/lib/locale文件中。
解决办法:
在源码编译文件夹 /work/glibc-2.28/build/
中执行:
sudo make localedata/install-locales