首页 > 系统相关 >Ubuntu22.04 安装 kvm

Ubuntu22.04 安装 kvm

时间:2023-12-22 14:46:58浏览次数:51  
标签:jammy universe -- 安装 Ubuntu22.04 kvm ubuntu main multiverse

确认环境

egrep -c '(vmx|svm)' /proc/cpuinfo

输出结果需要大于0,否则主机需要开启cpu虚拟化功能。

设置桥接网卡

# 网卡配置示例
cat <<'EOF' | sudo tee /etc/netplan/00-installer-config.yaml > /dev/null
# This is the network config written by 'subiquity'
network:
  ethernets:
    ens33:
      dhcp4: false
      dhcp6: false
  bridges:
    br0:
      interfaces: [ens33]
      dhcp4: false
      addresses:
      - 192.168.32.132/24
      routes:
      - to: default
        via: 192.168.32.2
      nameservers:
        addresses:
        - 114.114.114.114
        - 223.5.5.5
      parameters:
        stp: false
      dhcp6: false
  version: 2
EOF

# 重启网卡
sudo netplan apply 

更新apt源

不同系统配置文件不一致

sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup

$ cat <<'EOF' | sudo tee /etc/apt/sources.list >> /dev/null 
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse

deb http://security.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse
# deb-src http://security.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse

# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse
# # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse
EOF

sudo apt update

安装kvm包

sudo apt install qemu-kvm libvirt-daemon-system libvirt-clients virtinst -y

将用户添加到kvm和libvirt组

sudo usermod -aG kvm $USER
sudo usermod -aG libvirt $USER

启动和设置开机自启动

sudo systemctl enable --now libvirtd
sudo systemctl status libvirtd

创建虚拟硬盘

sudo qemu-img create -f qcow2 /var/lib/libvirt/images/CentOS7.qcow2 64G

安装kvm虚拟机

sudo virt-install --virt-type kvm --name CentOS7 --vcpus 1 --ram 2048 --cdrom=/var/lib/libvirt/CentOS-7-x86_64-Minimal-1810.iso --disk path=/var/lib/libvirt/images/CentOS7.qcow2 --network bridge=br0 --graphics vnc,listen=0.0.0.0 --noautoconsole 

--cdrom 参数是指定ISO文件路径,请自行上传到主机目录上
--disk 参数是指定虚拟硬盘路径

说明:启动没有报错的话,主机上会生成 5900 端口(默认),通过vpc客户端连接即可

img

标签:jammy,universe,--,安装,Ubuntu22.04,kvm,ubuntu,main,multiverse
From: https://www.cnblogs.com/jiaxzeng/p/17921526.html

相关文章

  • win10安装git fatal: open /dev/null or dup failed: No such file or directory错误
    https://files.cnblogs.com/files/netlock/null.zip?t=1703226893&download=true文件地址解决方法:1.C:\Windows\System32\drivers\null.sys这个文件损坏,可以从网上下载win7、win10对应的null.sys文件,然后进行替换。由于我是win10的电脑,提供链接。百度网盘链接:https://pan.baid......
  • 【Stress-ng】CentOS 7 离线安装Stress-ng
    手动下载RPM包以及依赖Stree-nglibmdlibbsdStress-ng有两个依赖包,安装顺序如下:rpm-ilibmd-1.1.0-1.el7.x86_64.rpmrpm-ilibbsd-0.11.7-2.el7.x86_64.rpmrpm-istress-ng-0.07.29-2.el7.x86_64.rpmyumdownloader也可以通过yumdownloader自动解析stress-ng依赖......
  • CentOS 7.9 安装net 8运行时环境[转]
    1.从官网下载对应的运行时环境压缩包。下载地址:https://dotnet.microsoft.com/zh-cn/download/dotnet/8.0dotnet-sdk-8.0.100-linux-x64.tar.gz2.上传至服务器,以我为例我是上传至/usr/local/software/dotnet83.运行命令解压环境压缩包tar-zxvf/home/dotnet8/dotnet-sdk-8.......
  • (亲测)CENTOS 7.9 yum 安装mysql
    CENTOS7安装mysql1、下载MySQL官方的YumRepositorywget-i-chttp://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm2、安装Repositoryyum-yinstallmysql57-community-release-el7-10.noarch.rpm3、更新过期的证书rpm--importhttps://repo.mysq......
  • Centos中安装Python3的mysqlclient库
    问题系统是centos7需要在python3中安装mysqlclient库使用pip3installmysqlclient然后无法安装报错Lookinginindexes:https://pypi.douban.com/simple/CollectingmysqlclientUsingcachedhttps://mirrors.cloud.tencent.com/pypi/packages/37/fb/d9a8f763c84f1e7......
  • 本地安装mysql (zip)
    下载https://downloads.mysql.com/archives/community/解压到文件夹且添加系统环境变量C:\Dinstall\Dmysql\mysql-8.2.0-winx64C:\Dinstall\Dmysql\mysql-8.2.0-winx64\bin在安装目录下创建并配置初始化的my.ini[mysqld]#skip-grant-tables#密码错误就用这个,不用密码......
  • Ubuntu18下实时Linux内核的编译安装记录(保姆级)
    本人系统是虚拟机上的ubuntu18,过程参考了以下3个链接:https://blog.csdn.net/huangjunsheng123/article/details/116202848https://blog.51cto.com/u_15899439/5907513https://kunaly.blog.csdn.net/article/details/101111502?spm=1001.2101.3001.6650.3&utm_medium=distribute......
  • 小傅哥自研插件,为开发提效80%,已经有8.1k安装量!
    作者:小傅哥博客:https://bugstack.cn沉淀、分享、成长,让自己和他人都能有所收获!......
  • MySQL运维14-管理及监控工具Mycat-web的安装配置
    一、Mycat-web介绍Mycat-web(现改名为Mycat-eye)是对Mycat-server提供监控服务,通过JDBC连接对Mycat,MySQL监控,监控远程服务器的cpu,内存,网络,磁盘等情况的使用。Mycat-web运行过程中需要依赖zookeeper,因此需要先安装zookeeper,下载地址如下:zookeeper:链接: https://pa......
  • Mac安装JDK1.8
    官网https://www.oracle.com/java/technologies/downloads/#java8-mac下载需要Oracle帐号安装点击安装一直下一步安装成功配置系统环境变量JDK主目录:/Library/Java/JavaVirtualMachinesJDK真实目录:/Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Homeo......