CentOS7.x最小化安装GNOME
原创大约 2 分钟
检查是否有内核升级包(可选)
> yum check-update | grep kernel
# 升级内核前注意做好系统盘快照,避免操作错误导致服务器无法启动
> yum update kernel
> cd /boot
> ll
> cd /boot
确认新版本的内核或initrd/initramfs
是否有xen-vbd
和virtio_blk
驱动({3.10.0-514.26.2.el7.x86_64}
表示视版本而定)。
> lsinitrd /boot/initramfs-3.10.0-514.26.2.el7.x86_64.img |grep -i -E 'xen-blkfront|virtio_blk'
查看补丁样例(具体视版本而定,可以cd /boot/
目录下面查看对应的initramfs
文件)。
> lsinitrd /boot/initramfs-3.10.0-514.26.2.el7.x86_64.img |grep -i -E 'xen-blkfront|virtio_blk'
# 如果有,则重启
> reboot
# 如果没有,则需要给initramfs安装驱动
> mkinitrd -f --allow-missing \
--with=xen-blkfront --preload=xen-blkfront \
--with=virtio_blk --preload=virtio_blk \
--with=virtio_pci --preload=virtio_pci \
--with=virtio_console --preload=virtio_console initramfs-3.10.0-514.26.2.el7.x86_64.img 3.10.0-514.26.2.el7.x86_64
再次执行({3.10.0-514.26.2.el7.x86_64}
表示视版本而定),查看是否有驱动,然后重启系统。
> lsinitrd /boot/initramfs-3.10.0-514.26.2.el7.x86_64.img |grep -i -E 'xen-blkfront|virtio_blk'
# 查看升级后的内核版本
> uname -a
# 或者
> rpm -q --changelog kernel | grep 'CVE-2016-5195'
注意:更新完毕后可能会安装两个内核,但不影响系统运行。
安装GNOME
> yum install links -y
# 停止防火墙
> systemctl stop firewalld.service
# 禁用防火墙
> systemctl disable firewalld.service
# 安装httpd并启动
> yum install httpd -y
> systemctl enable httpd.service
> systemctl restart httpd.service
# 安装`X Window`
> yum install epel-release -y
> yum groupinstall "X Window system" -y
> yum install gnome-classic-session gnome-terminal nautilus-open-terminal control-center liberation-mono-fonts -y
安装中文支持
> yum install kde-l10n-Chinese -y
# 安装中文字体(最好安装,否则命令行等界面会显示不正常)
> yum -y install cjkuni-ukai-fonts
> yum -y install google-noto-sans-simplified-chinese-fonts.noarch
# 以通过fc-list查看当前系统安装了那些字体
> fc-list
> yum install -y fontconfig
> mkdir -pv /usr/share/fonts/chinese
# 将字体上传至/usr/share/fonts/chinese目录下,同时修改`chinese`目录的权限
> chmod -R 755 /usr/share/fonts/chinese
# 安装ttmkfdir来搜索目录中所有的字体信息,并汇总生成fonts.scale文件
> yum -y install ttmkfdir
> ttmkfdir -e /usr/share/X11/fonts/encodings/encodings.dir
# 修改字体配置文件
> vi /etc/fonts/fonts.conf
# 把需要的中文字体位置加进去
<dir>/usr/share/fonts/chinese</dir>
# 刷新内存中的字体缓存使配置对系统生效
> fc-cache
设置默认界面
设置默认为图形界面。
> unlink /etc/systemd/system/default.target
> ln -sf /lib/systemd/system/graphical.target /etc/systemd/system/default.target
> reboot
# 设置不启动图形界面
> init 3
# 或者
> systemctl set-default multi-user.target
CentOS系列版本的继承性都比较好,这些脚本即使在CentOS 8
和CentOS Stream 9
中也变化不大。
感谢支持
更多内容,请移步《超级个体》。