虚拟机里装了CentOS 7的系统。装好之后发现启动默认是命令行界面,想要改成默认图形界面启动。这就需要安装额外的软件比如GNOME Desktop。所以第一步要先配置本地repo source:
使用DVD创建本地YUM Repository
创建源
把CD/DVD ROM 挂载到任意的文件夹,这里使用/cdrom。
mkdir /cdrom
mount /dev/cdrom /cdrom
创建Repo文件
创建repo 文件之前,如果不需要的话,把/etc/yum.repos.d目录中存在的现有repo文件挪一边去。
mv /etc/yum.repos.d/*.repo /tmp/
在 /etc/repos.d 目录下创建新的 repo 文件,命名为cdrom.repo。
vi /etc/yum.repos.d/local.repo
Add the following details.
[LocalRepo]
name=LocalRepository
baseurl=file:///cdrom
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
对应项解释如下,
[LocalRepo] = Repository Name which will be displayed during package installation
name = Name of the repository
baseurl = Location of the package
Enabled = Enable repository
gpgcheck = Enable secure installation
gpgkey = Location of the key
gpgcheck is optional (If you set gpgcheck=0, there is no need to mention gpgkey)
安装一个软件包检查一下,没想好装什么,这里就清理一下缓存试试吧。
yum clean all
配置完成后执行就可以开始软件安装了!
安装服务器GUI软件组
先查看一下都有哪些group:
yum group list
输出:
Loaded plugins: fastestmirror There is no installed groups file. Maybe run: yum groups mark convert (see man yum) Loading mirror speeds from cached hostfile Available Environment Groups: Minimal Install Compute Node Infrastructure Server File and Print Server Basic Web Server Virtualization Host Server with GUI GNOME Desktop KDE Plasma Workspaces Development and Creative Workstation Available Groups: Compatibility Libraries Console Internet Tools Development Tools Graphical Administration Tools Legacy UNIX Compatibility Scientific Support Security Tools Smart Card Support System Administration Tools System Management Done
如果是CentOS 7,安装:
yum groupinstall "GNOME Desktop" "Graphical Administration Tools"
如果是RHEL 7,安装:
yum groupinstall "Server with GUI"
设置系统启动时使用GUI。在CentOS 7 / RHEL 7中,systemd使用“targets”而不是运行级别。 /etc/inittab文件不再用于更改运行级别。 因此,使用以下命令以在系统启动时启用GUI。
ln -sf /lib/systemd/system/runlevel5.target /etc/systemd/system/default.target
重启机器即可进入图形模式。
reboot