六、系统安装后准备

6.1 刚刚安好的虚拟机有很多地方不方便我们使用这儿我们需要进行设置。
— 配置yum源:
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# vi centos7.repo
[centos7]
name=centos7
baseurl=ftp://192.168.1.105/centos7
enabled=1
gpgcheck=0
~
[root@localhost yum.repos.d]# yum repolist
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
源标识 源名称 状态
centos7 centos7 9,591
repolist: 9,591
— 安装yum install net-tools [ifconfig]
[root@localhost ~]# yum -y install net-tools
— 查找命令在哪个包里【安装yum】
[root@localhost ~]# yum provides vim
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
2:vim-enhanced-7.4.160-2.el7.x86_64 : A version of the VIM editor which includes
: recent enhancements
源 :centos7
匹配来源:
提供 :vim = 7.4.160-2.el7
[root@localhost ~]# yum -y install vim-enhanced [vim ]
— tab补全命令
[root@localhost ~]# yum -y install bash-completion bash-completion-extras
— 禁用selinux(可选)
[root@localhost ~]# sed -i '/^SELINUX/s/=.*/=disabled/' /etc/selinux/config
[root@localhost ~]# init 6
— 卸载防火墙(可选)
[root@localhost ~]# yum -y remove firewalld-* python-firewall
— 卸载防火墙与NetworkManager
在卸载前先编写eth0配置文件
[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
ONBOOT="yes"
IPV6INIT="no"
BOOTPROTO="dhcp"
TYPE="Ethernet"
更改完成后卸载
[root@localhost ~]# rpm -qa | grep -i networkm
[root@localhost ~]# yum -y remove NetworkManager-*
[root@localhost ~]# systemctl stop networkmanager
[root@localhost ~]# systemctl restart network
— 安装lftp
[root@localhost ~]# yum -y install lftp
— 导入公钥验证配置:
[root@localhost ~]# lftp 192.168.0.254/centos7
lftp 192.168.0.254:/centos7> ls
-rw-rw-r-- 3 0 0 1690 Dec 09 2015 RPM-GPG-KEY-CentOS-7
lftp 192.168.0.254:/centos7> get RPM-GPG-KEY-CentOS-7
lftp 192.168.0.254:/centos7> bye
[root@localhost ~]# ls
anaconda-ks.cfg RPM-GPG-KEY-CentOS-7
更给yum配置文件
[root@localhost ~]# vim /etc/yum.repos.d/centos7.repo
[centos7]
name=centos7
baseurl=ftp://192.168.1.105/centos7
enabled=1
gpgcheck=1
[root@localhost ~]# rpm --import RPM-GPG-KEY-CentOS-7
[root@localhost ~]# yum -y install bridge-utils psmisc
— 禁止空路由
[root@localhost ~]# vim /etc/sysconfig/network
NOZEROCONF="yes"
— Console及磁盘分区配置
[root@localhost ~]#vim /etc/default/grub //添加 Console 配置
GRUB_CMDLINE_LINUX="biosdevname=0 net.ifnames=0 console=ttyS0,115200n8"
GRUB_DISABLE_LINUX_UUID="true" //使用磁盘卷标引导
GRUB_ENABLE_LINUX_LABEL="true”
[root@localhost ~]# grub2-mkconfig -o /boot/grub2/grub.cfg //重新生成 grub.cfg
[root@localhost ~]# blkid
/dev/vda1: UUID="03a1b187-5fd0-4e62-b500-cfa3fa9c2c85" TYPE="xfs" // 查看 uuid 对应的磁盘设备
[root@localhost ~]# vim /etc/fstab
/dev/vda1 / xfs defaults 0 0
[root@localhost ~]# yum install -y cloud-utils-growpart //安装分区扩展软件
*动态调整分区大小,可以自动扩容根目录也可以手动
[root@localhost ~]#chmod 755 /etc/rc.local //设置第一次开机自动扩容根目录
在 rc.local 里加入如下配置
###
/usr/bin/growpart /dev/vda 1 //1为分区号 ,将1号分区扩展为/dev/vda 全部空间
/usr/sbin/xfs_growfs / //xfs系统同步
/usr/bin/sed '/^###/,$d' -i /etc/rc.d/rc.local
设置到此就可以关闭虚拟机了
关闭虚拟机后,在物理机上执行如下操作:
[root@room8pc205 ~]# virt-sysprep –d centos7.0
如果:virt-sysprep命令不存在可以安装一下软件:
[root@room8pc205 ~]# yum -y install libguestfs-tools

[root@room8pc205 ~]# virsh console node1
连接到域 node1
换码符为 ^]


CentOS Linux 7 (Core)
Kernel 3.10.0-693.el7.x86_64 on an x86_64

localhost login: root
密码:
Last login: Mon Jul 19 12:58:32 from 192.168.0.254

posted @ 2021-07-19 14:15  落樰兂痕  阅读(67)  评论(0编辑  收藏  举报