Tag Archives: virt-install

‘utf-8’ codec can’t decode byte 0xf0 in position 0: invalid continuation byte virt-install


Error: --disk path=/var/lib/libvirt/images/centos7.qcow2,size=15,device=disk,bus=virtio,format=qcow2: 'utf-8' codec can't decode byte 0xf0 in position 0: invalid continuation byte

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=aaa --disk path=/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.cherryservers.com/centos/7/os/x86_64/ --nographics

virsh # pool-list

Name State Autostart
------------------------------------
boot-scratch active yes
images active yes
tmp active yes
virtio-win active yes
vit active yes

virsh # pool-destroy vit
Pool vit destroyed

virsh # pool-destroy virtio-win
Pool virtio-win destroyed

'utf-8' codec can't decode byte 0xf0 in position 0: invalid continuation byte error was because of virStorageVolGetName:

File "/usr/lib64/python3.7/site-packages/libvirt.py", line 3650, in name
ret = libvirtmod.virStorageVolGetName(self._o)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf0 in position 0: invalid continuation byte
[Mon, 17 Feb 2020 15:26:54 virt-install 57908] DEBUG (cli:263) File "/usr/share/virt-manager/virt-install", line 1005, in

virt-install should be working now again

LXC container on Centos

LXC isn’t a real Virtualization technique, but is more like a chroot environment, but on “steroids”. Its similar to OpenVZ virtualization, but can use your native kernel version. In some cases its very important.

mkdir /var/lib/libvirt/lxc/centos-6-x86_64/etc/yum.repos.d/ -p  
cat /etc/yum.repos.d/CentOS-Base.repo |sed s/'$releasever'/6/g > /var/lib/libvirt/lxc/centos-6-x86_64/etc/yum.repos.d/CentOS-Base.repo
yum groupinstall core --installroot=/var/lib/libvirt/lxc/centos-6-x86_64/ --nogpgcheck -y
yum install plymouth libselinux-python --installroot=/var/lib/libvirt/lxc/centos-6-x86_64/ --nogpgcheck -y

You should crate selinux rule:

module lxc 1.0;

require {
type hald_t;
type virtd_lxc_t;
class dbus send_msg;
}

#============= hald_t ==============
allow hald_t virtd_lxc_t:dbus send_msg;

You should create manually your selinux rule to allow virtd_lxc_t to use dbus daemon. How crate custom selinux rules, you can check in other my article there.

chroot /var/lib/libvirt/lxc/centos-6-x86_64/ 

echo your_password_there |passwd root --stdin

#Fix root login on console

echo "pts/0" >>/etc/securetty

sed -i s/"session    required     pam_selinux.so close"/"#session    required     pam_selinux.so close"/g /etc/pam.d/login

sed -i s/"session    required     pam_selinux.so open"/"#session    required     pam_selinux.so open"/g /etc/pam.d/login

sed -i s/"session    required     pam_loginuid.so"/"#session    required     pam_loginuid.so"/g /etc/pam.d/login

#Configuring basic networking

cat > /etc/sysconfig/network << EOF

NETWORKING=yes

HOSTNAME=lxc.linux4you.tk

EOF

cat > /etc/sysconfig/network-scripts/ifcfg-eth0 << EOF

DEVICE=eth0

BOOTPROTO=dhcp

ONBOOT=yes

EOF

#Enabling sshd

chkconfig sshd on

# Fixing root login for sshd

sed -i s/"session    required     pam_selinux.so close"/"#session    required     pam_selinux.so close"/g /etc/pam.d/sshd

sed -i s/"session    required     pam_loginuid.so"/"#session    required     pam_loginuid.so"/g /etc/pam.d/sshd

sed -i s/"session    required     pam_selinux.so open env_params"/"#session    required     pam_selinux.so open env_params"/g /etc/pam.d/sshd

# Leaving the chroot'ed filesystem

exit
virt-install --connect lxc:/// --name test --ram 512 --vcpu 1 --filesystem /var/lib/libvirt/lxc/centos-6-x86_64/,/ --noautoconsole

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