Tag Archives: linux kvm

Kickstart install Centos 7 using virt-install


sudo qemu-img create -f qcow2 /var/lib/libvirt/images/centos7.qcow2 15G

sudo iptables -t nat -A POSTROUTING -j MASQUERADE
or
firewall-cmd --zone=external --add-masquerade --permanent
firewall-cmd --reload

This helps avoid errors like: dracut-initqueue[688]: Warning: unknown network kickstart URL: ...

mkdir kick && mkdir kick

vim centos7.cfg

#version=RHEL7
install

auth --enableshadow --passalgo=sha512
repo --name="EPEL" --baseurl=http://dl.fedoraproject.org/pub/epel/7/x86_64
eula --agreed
reboot
url --url="http://mirror.litnet.lt/centos/7/os/x86_64/"
firstboot --enable
ignoredisk --only-use=vda
keyboard --vckeymap=en --xlayouts='en'
lang en_US.UTF-8

network --bootproto=dhcp --device=enp0s3 --noipv6 --activate
network --hostname=centos7.test.local
rootpw mypassword
services --enabled=NetworkManager,sshd,chronyd
timezone Europe/Vilnius --isUtc --ntpservers=0.centos.pool.ntp.org,1.centos.pool.ntp.org,2.centos.pool.ntp.org,3.centos.pool.ntp.org
user --groups=wheel --homedir=/home/monit --name=monit --password=password --iscrypted --gecos="monit"
bootloader --location=mbr --boot-drive=vda
autopart --type=lvm
zerombr
clearpart --all --drives=vda
selinux --permissive

%packages
@base
@core
chrony
yum-cron
%end

python -m SimpleHTTPServer 1111
Serving HTTP on 0.0.0.0 port 1111 ...
or
python3 -m http.server 1111
Serving HTTP on 0.0.0.0 port 1111 (http://0.0.0.0:1111/) ...

sudo virt-install --connect=qemu:///system --network=bridge:virbr0 --extra-args="ks=http://192.168.0.101:1111/centos7.cfg console=tty0 console=ttyS0,115200" --name=centos7 --disk /var/lib/libvirt/images/centos7.qcow2,size=15,device=disk,bus=virtio,format=qcow2 --ram 1500 --vcpus=1 --check-cpu --accelerate --hvm --location=http://mirror.litnet.lt/centos/7/os/x86_64/ --nographics

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

centos7 login:

Kickstart install Centos 6 using virt-install


virt-install --connect=qemu:///system --network=bridge:virbr0 --initrd-inject=/tmp/centos.ks --extra-args="ks=file:/centos.ks console=tty0 console=ttyS0,115200" \
--name=centos \
--disk /var/lib/libvirt/images/centos.qcow2,size=10,device=disk,bus=virtio,format=qcow2 \
--ram 750 \
--vcpus=1 \
--check-cpu \
--accelerate \
--hvm \
--location=http://mirror.duomenucentras.lt/centos/6/os/x86_64/ \
--nographics

I am using kickstart file:

text
install
lang en_US.UTF-8
keyboard uk
network –bootproto=dhcp –device=eth0
reboot
authconfig –enableshadow –passalgo=sha512
selinux –enforcing
timezone –utc Europe/Vilnius
bootloader –location=mbr –driveorder=vda –append=”crashkernel=auto rhgb quiet”
zerombr
ignoredisk –only-use=vda
clearpart –linux –drives=vda –all –initlabel
rootpw  mypassword
#autopart
part /boot –fstype=ext4 –size=50
part / –fstype=ext4 –size=2000 –grow
part swap –size=500
part /home –fstype=ext4 –size=500
%packages –excludedocs –nobase
@Core
acpid

virt-install install Fedora 19 on server

If you love Fedora and want use it on your server, but don’t like graphical interface. Its not problem, lets download Fedora ISO image like Fedora-Live-LXDE-x86_64-19-1.iso from http://fedoraproject.org/en/get-fedora-options

virt-install –connect qemu:///system -n Fedora19 –disk path=/var/lib/libvirt/images/guest.qcow2,format=qcow2,bus=virtio,cache=none –cdrom /tmp/Fedora-Live-LXDE-x86_64-19-1.iso –video=vga –network=bridge:virbr0,model=e1000 –accelerate –noapic –keymap=en-us –ram 1024

before you should create qcow disk image:

qemu-img create -f qcow2 /var/lib/libvirt/images/guest.qcow2 10G -o preallocation=metadata

I am using bridge networking so can access Fedora using SSH. You should disable LXDE graphical interface, because I guess you don’t need it.

ln -sf /lib/systemd/system/multi-user.target /etc/systemd/system/default.target

and reboot your Fedora guest