Centos 7 install with virt-install
It took me quite sometime to figure out how to install Centos 7 in text-mode with virt-install
.
Somehow, Centos 6 can be installed normally using standard method but it always crashes during text-installation of Centos 7. In this quick note, let try to solve it.
So, my Virsh version is 0.10.2(virt-install is at 0.600.0) running inside an old Centos 6 host.
Normally, to install a Centos guest, we need to execute command such as:
virt-install --name=centos7
--ram=1024
--vcpus=1
--os-type=linux
--disk path=/var/lib/libvirt/images/centos7,size=15
--network=bridge:br0
--location http://ftp.tsukuba.wide.ad.jp/Linux/centos/7/os/x86_64/
--console pty,target_type=serial
--extra-args 'console=ttyS0,115200n8 serial'
this works until Centos 7, which somehow still runs the graphical installation and messes up the console. In order to install Centos 7, I’ve done the following steps.
First, download an ISO, I’ve used minimal install from one of many Centos’s mirrors:
http://isoredirect.centos.org/centos/7/isos/x86_64/
Second, download a seperated initrd
and vmlinuz
images(or we can extract it from the iso)
http://ftp.jaist.ac.jp/pub/Linux/CentOS/7.7.1908/os/x86_64/images/pxeboot/
Third, run the virt-install
command
virt-install --name=centos7
--ram=1024
--vcpus 1
--network bridge=br0
--disk path=/var/lib/libvirt/images/centos7,size=10
--disk /var/lib/libvirt/isos/CentOS-7-x86_64-Minimal-1908.iso,device=cdrom
--console pty,target_type=serial
--boot kernel=/var/lib/libvirt/isos/vmlinuz,initrd=/var/lib/libvirt/isos/initrd.img,kernel_args="earlyprintk=serial console=ttyS0"
This time, Centos 7 is really run in text intall mode.
Lastly, after finishing the installation, we can shutdown this guest, running it again without the boot command(this time we will boot directly from disk and don’t need the cdrom anymore), so the command looks like:
virt-install --name=centos7
--ram=1024
--vcpus 1
--network bridge=br0
--disk path=/var/lib/libvirt/images/centos7,size=10
--console pty,target_type=serial
--boot hd