CentOS 7常见问题

防火墙问题

  • 禁用防火墙

    [root@localhost ~]# systemctl stop firewalld.service
    
  • 增加服务允许规则

    [root@localhost ~]# firewall-cmd --add-service=ntp --permanent
    success
    [root@localhost ~]# firewall-cmd --reload
    success
    
  • 临时增加端口允许规则

    [root@localhost ~]# firewall-cmd --add-port=8888/tcp
    success
    

initramfs 增加新驱动

例如安装系统时可能未启用 ahci,后续主板 BIOS 启用了 ahci 或者更换到需要 ahci 的主板上,需要重新打包 initramfs 开启 ahci 支持:

[root@localhost ~]# dracut --add-drivers ahci -f /boot/initramfs-$(uname -r).img $(uname -r)

切换命令行和图形模式

CentOS 7 不再使用 inittab 实现用户级别,systemd 的 graphical.target 为图形模式,multi-user.target 为命令行模式。

[root@localhost ~]# systemctl get-default
graphical.target
[root@localhost ~]# ls -al /etc/systemd/system/default.target
lrwxrwxrwx. 1 root root 36 12月 23 19:36 /etc/systemd/system/default.target -> /lib/systemd/system/graphical.target
[root@localhost ~]# systemctl set-default multi-user.target
Removed symlink /etc/systemd/system/default.target.
Created symlink from /etc/systemd/system/default.target to /usr/lib/systemd/system/multi-user.target.

修改 GRUB 背景图片

首先需要将背景图片转换为 tga 格式并放到某个目录,然后修改 /etc/default/grub 文件:

[root@localhost ~]# cat /etc/default/grub
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
#GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto rhgb quiet"
GRUB_DISABLE_RECOVERY="true"
GRUB_BACKGROUND="/boot/grub/boot.tga"

需要注释掉 GRUB_TERMINAL_OUTPUT="console" 这一行,并增加 GRUB_BACKGROUND 这一行设置为 tga 图片文件的路径。

最后生成新的 GRUB 配置:

[root@localhost ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found background: /boot/grub/boot.tga
Found linux image: /boot/vmlinuz-3.10.0-514.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-514.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-0578b5229efe406bb0aef2444b098102
Found initrd image: /boot/initramfs-0-rescue-0578b5229efe406bb0aef2444b098102.img
done

注意 grub2-mkconfig 命令的输出中应该有 Found background 这种提示找到图片文件的信息。

强制 fsck

修改 kernel 命令行参数,指定 systemd 的 fsck 模式及操作:

  • fsck.mode

    One of “auto”, “force”, “skip”. Controls the mode of operation. The default is “auto”, and ensures that file system checks are done when the file system checker deems them necessary. “force” unconditionally results in full file system checks. “skip” skips any file system checks.

  • fsck.repair

    One of “preen”, “yes”, “no”. Controls the mode of operation. The default is ” preen”, and will automatically repair problems that can be safely fixed. “yes ” will answer yes to all questions by fsck and “no” will answer no to all questions.

RPM 问题

RPM checksum 报错

如果出现这种报错:Rpmdb checksum is invalid: pkg checksums,可以通过 rpm --rebuilddb 命令重建 RPM 数据库。

区域问题

安装中文字体

[root@localhost ~]# yum install bitmap-fonts bitmap-fonts-cjk
[root@localhost ~]# fc-cache