RHEL学习 - 各种问题集合

1.关闭subscription Manager

不会导致redhat.repo的经常生成

找到subscription-manage的配置文件/etc/yum/pluginconf.d/subscription-manager.conf

[main]
enabled=0 

 

2.文件删除

  • 删除大小为0的文件
find ./ -name "*" -type f -size 0c | xargs -n 1 rm -f
  • 删除大小小于5K的文件
find ./ -size -5k -exec rm {} \;
  • 删除大于50M的文件
find ./ -size +50M -exec rm {} \;

 

3. 安装KVM

dnf install qemu-kvm qemu-img libvirt virt-install libvirt-client

 

4.启动虚拟机发生的问题

qemu-kvm: could not open disk image ' ': Permission denied

修改 /etc/libvirt/qemu.conf, 把user和group的root打开

# The user for QEMU processes run by the system instance. It can be
# specified as a user name or as a user id. The qemu driver will try to
# parse this value first as a name and then, if the name doesn't exist,
# as a user id.
#
# Since a sequence of digits is a valid user name, a leading plus sign
# can be used to ensure that a user id will not be interpreted as a user
# name.
#
# Some examples of valid values are:
#
#       user = "qemu"   # A user named "qemu"
#       user = "+0"     # Super user (uid=0)
#       user = "100"    # A user named "100" or a user with uid=100
#
user = "root"

# The group for QEMU processes run by the system instance. It can be
# specified in a similar way to user.
group = "root"

然后

service libvirtd restart

 

 5.虚拟机操作

启动虚拟机

virt-install --connect qemu:///system   -n fcos -r 2048 --os-variant=fedora31 --import   --graphics=none   --disk size=10,backing_store=/root/fedora-coreos-32.20200726.3.1-qemu.x86_64.qcow2   --qemu-commandline="-fw_cfg name=opt/com.coreos/config,file=/root/example-ignition.ign"

 

列出虚拟机

[root@localhost .ssh]# virsh list
 Id    Name                           State
----------------------------------------------------
 1     fcos                           running

停止

[root@localhost .ssh]# virsh shutdown  fcos
Domain fcos is being shutdown

[root@localhost .ssh]# virsh list --all
 Id    Name                           State
----------------------------------------------------
 -     fcos                           shut off

重新启动

virsh --connect qemu:///system start fcos

 

 

posted @ 2020-03-15 15:23  ericnie  阅读(260)  评论(0编辑  收藏