zoukankan      html  css  js  c++  java
  • kickstart+virt-install安装虚拟机

    本文提供的方法适用于在远程服务器的kvm+qemu环境中部署CentOS虚拟机。

    #!/bin/bash
    set -xe
    diskimage=/var/lib/libvirt/images/centosvm.qcow2
    echo "Creating qcow2 disk image.."
    qemu-img create -f qcow2 -o preallocation=metadata $diskimage 40G
    #fallocate -l `ls -al $diskimage | awk '{print $5}'` $diskimage
    echo `ls -lash $diskimage`
    
    
    # [2] Create a minimal kickstart file for Fedora
    
    cat << EOF > fed.ks
    install
    text
    reboot
    lang en_US.UTF-8
    keyboard us
    network --bootproto dhcp
    rootpw abc123
    firewall --enabled --ssh
    selinux --enforcing
    network  --bootproto=static --ip=192.168.122.100 --netmask=255.255.255.0 --gateway=192.168.122.1 --nameserver=223.5.5.5,223.6.6.6 --device=eth0
    timezone --utc Asia/Shanghai
    bootloader --location=mbr --append="console=tty0 console=ttyS0,115200 rd_NO_PLYMOUTH"
    zerombr
    clearpart --all --initlabel
    autopart
    
    %packages
    @core
    net-tools
    git
    emacs
    mtr
    %end
    EOF
    
    # [3] Create the guest
    
    virt-install --connect=qemu:///system 
        --network network=default 
        --initrd-inject=./fed.ks 
        --extra-args="ks=file:/fed.ks console=tty0 console=ttyS0,115200 serial rd_NO_PLYMOUTH" 
        --name=test 
        --disk path=$diskimage,format=qcow2,cache=none 
        --ram 512 
        --vcpus=2 
        --check-cpu 
        --accelerate 
        --os-type linux 
        --os-variant centos7.0 
        --cpuset auto 
        --hvm 
        --location=CentOS-7-x86_64-Minimal-1804.iso 
        --nographics
    
  • 相关阅读:
    工商银行在线支付接口
    Runtime-compiler和Runtime-only的区别:
    响应式网站技术精要总结
    ajax基础
    jquery选择器 笔记
    js数组去重的几种方法
    js中的call apply bind
    es6中的类
    bootstrap组件
    es6中的模块化输出
  • 原文地址:https://www.cnblogs.com/powerrailgun/p/12158037.html
Copyright © 2011-2022 走看看