KVM virtualization – text only CentOS guest install

It took me a little while today to figure out how to do a text only install of a CentOS guest on KVM. Previously I had started the install using virt-install and then connected to the VNC console over SSH. This is a bit of a hassle though when all you want is a quick, text based install.

So here’s how.

Firstly all of my VMs live on LVM so create a virtual disk to hold the VM. I’m creating a 20G ‘partition’ in a volume group called kvm-storage. The logical volume is called host.demo.com.

lvcreate -L20G -n host.demo.com kvm-storage

Now download the CentOS install ISO. Either CD1 or the netinstall ISO should be fine –

wget http://mirrors.manchester.icecolo.com/centos/5.5/isos/x86_64/CentOS-5.5-x86_64-bin-1of8.iso

Now we mount the ISO –

mkdir /mnt/centos55

mount -o loop CentOS-5.5-x86_64-bin-1of8.iso /mnt/centos55/

Now we run the virt-install command. I suggest putting this command in a file and running it from there to make editing easier!

virt-install \
-n host.demo.com \
-r 512 \
--vcpus=1 \
--os-variant=rhel5.4 \
--accelerate \
--nographics  \
-v \
-l /mnt/centos55/ \
-w bridge:br1 \
--disk path=/dev/kvm-storage/host.demo.com \
-x "console=ttyS0"

Here are the parts of the command above that allow for a text based install –

–nographics  – tells KVM not to allocate a graphics console to the VM

-v  – means we’re doing full virtualization

-l  – sets the boot location to be the ISO we mounted earlier

–disk  – sets the install destination disk to be the disk we created earlier

-x “console=ttyS0”  – sets a kernel boot parameter telling CentOS to use ttyS0 as the console

Once this is done you should see the text based installation screens. This worked pretty well in putty, you are able to tell what menu options you are selecting. You won’t be able to use the mounted ISO for the actual installation media so I did a HTTP install, selecting one of the CentOS mirrors to do the install from  (like – http://mirrors.manchester.icecolo.com/centos/5.5/os/x86_64/)

Once the install is complete and the VM rebooted you can access the console again by running –

virsh
list --all
console VM-ID

6 thoughts on “KVM virtualization – text only CentOS guest install

  1. Alex

    You don’t have to mount the iso you can just -l to the iso. Do you have a way to do an install from the local iso media rather than from http? I can’t get this to work.

  2. matt Post author

    No, I couldn’t either. I just use virt-manager if I need to do a full ISO install.

  3. Pingback: Installing centos and freebsd with serial console | MoVn - Linux Ubuntu Center

  4. Dan Pritts

    A couple thoughts.

    1) a quick workaround to installing from local iso media is just to export the loopback-mounted filesystem via NFS or http from the host to the guest.

    2) you don’t mention, so I will: to escape from the console you connected to with virsh, issue control-] (same as the telnet escape character for you old timers).

  5. ipeacocks

    just I dont understand why i cant use iso-file with -c key like

    -c /home/ipeacocks/CentOS-6.4-x86_64-bin-DVD1.iso

    and should mount iso . Because option -x “console=ttyS0” will not work with iso-image.

    Anyway thank you ! 🙂

Comments are closed.