LoginSignup
6
6

More than 5 years have passed since last update.

KVM Ubuntu 14.04 仮想マシン最小インストールスクリプト

Posted at
create_kvm_ubuntu1404.sh
#!/bin/bash

function main(){

    local NAME=$1

    if [ -z ${NAME} ]
    then
        echo $0 [NAME]
    else
        create_img ${NAME}
        create_kvm ${NAME}
    fi
}

function create_img(){

    local NAME=$1

    qemu-img create -f qcow2 /var/lib/libvirt/images/${NAME}.img 10GB
}

function create_kvm(){

    local NAME=$1

    virt-install \
    --connect qemu:///system \
    --name=${NAME} \
    --ram=512 \
    --disk path=/var/lib/libvirt/images/${NAME}.img,format=qcow2 \
    --vcpus=1 \
    --network bridge=br0 \
    --nographics \
    --accelerate \
    --hvm \
    --location=http://ftp.jaist.ac.jp/pub/Linux/ubuntu/dists/trusty/main/installer-amd64/ \
    --extra-args='console=tty0 console=ttyS0,115200n8 keymap=ja'

}

main ${@}
6
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
6