35

I'm trying to install a fully virtualized guest (Fedora 14 x86_64) on KVM (RHEL 6), using command-line only (both hypervisor and guest). It goes without errors, and without a tangible result . I'd like to know how to do a text-only installation.

So, here's what I've done:

# virt-install \
--name=FE --ram=756 --vcpus=1 \
--file=/var/lib/libvirt/images/FE.img  --network bridge:br0 \
--nographics --os-type=linux  \
--extra-args='console=tty0' -v \
--cdrom=/media/usb/Fedora-14-x86_64-Live-Desktop.iso 


Starting install...
Creating domain...                                                                                                                                                        |    0 B     00:00     
Connected to domain FE
Escape character is ^]
ÿ

Now what? As I understand after googling for a couple of days, I should see the guest's output from the text installation, but nothing happens. virt-viewer cannot connect to it, kindly suggesting that I explore all the options by adding --help (which I did). If I reconnect with virsh, I see this:

Domain installation still in progress. You can reconnect to 
the console to complete the installation process.
[root@v ~]
# virsh console FEConnected to domain FE
Escape character is ^]

This shows that VM is running

# virsh list
 Id Name                 State
----------------------------------
  8 FE                   running

Qemu log:

LC_ALL=C PATH=/sbin:/usr/sbin:/bin:/usr/bin /usr/libexec/qemu-kvm -S -M rhel6.0.0 -enable-kvm -m 756 -smp 1,sockets=1,cores=1,threads=1 -name FE -uuid 6989d008-7c89-424c-d2d3-f41235c57a18 -nographic -nodefconfig -nodefaults -chardev socket,id=monitor,path=/var/lib/libvirt/qemu/FE.monitor,server,nowait -mon chardev=monitor,mode=control -rtc base=utc -no-reboot -boot d -drive file=/var/lib/libvirt/images/FE.img,if=none,id=drive-ide0-0-0,format=raw,cache=none -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 -drive file=/media/usb/Fedora-14-x86_64-Live-Desktop.iso,if=none,media=cdrom,id=drive-ide0-1-0,readonly=on,format=raw -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 -netdev tap,fd=20,id=hostnet0 -device rtl8139,netdev=hostnet0,id=net0,mac=52:54:00:0a:65:8d,bus=pci.0,addr=0x2 -chardev pty,id=serial0 -device isa-serial,chardev=serial0 -usb -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 
char device redirected to /dev/pts/1

Output of /etc/libvirt/qemu/FE.xml

# cat /etc/libvirt/qemu/FE.xml 
<domain type='kvm'>
  <name>FE</name>
  <uuid>6989d008-7c89-424c-d2d3-f41235c57a18</uuid>
  <memory>774144</memory>
  <currentMemory>774144</currentMemory>
  <vcpu>1</vcpu>
  <os>
    <type arch='x86_64' machine='rhel6.0.0'>hvm</type>
    <boot dev='hd'/>
  </os>
  <features>
    <acpi/>
    <apic/>
    <pae/>
  </features>
  <clock offset='utc'/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>restart</on_crash>
  <devices>
    <emulator>/usr/libexec/qemu-kvm</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='raw' cache='none'/>
      <source file='/var/lib/libvirt/images/FE.img'/>
      <target dev='hda' bus='ide'/>
      <address type='drive' controller='0' bus='0' unit='0'/>
    </disk>
    <disk type='block' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <address type='drive' controller='0' bus='1' unit='0'/>
    </disk>
    <controller type='ide' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
    </controller>
    <interface type='bridge'>
      <mac address='52:54:00:0a:65:8d'/>
      <source bridge='br0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    </interface>
    <serial type='pty'>
      <target port='0'/>
    </serial>
    <console type='pty'>
      <target port='0'/>
    </console>
    <memballoon model='virtio'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </memballoon>
  </devices>
</domain>

I'm obviously missing something that many others don't, but what is it? Thanx in advance!

badbishop
  • 898
  • 3
  • 11
  • 21
  • 3
    How were you able to get the --extra-args switch to work with --cdrom? According to the virt-install man page --extra-args only works with --location? – slm Jun 18 '11 at 02:27
  • 4
    I removed `--network bridge:br0`, changed `cdrom`to `location`, and `extra-args` to `--extra-args='console=tty0 console=ttyS0,115200n8 serial'` and it worked! – some Mar 16 '13 at 04:42
  • 2
    I only changed cdrom to location and added "extra-args". No need to remove the --network options. – twan163 Dec 06 '14 at 12:08
  • 1
    For whatever reason `--cdrom` doesn't work with extra-args but `--location` (or `-l`) does. Same path and everything. – Rick Chatham Sep 30 '15 at 23:14

6 Answers6

13

I copied --extra-args='console=ttyS0' somewhere from Internet last time, it works!

  • No need for two "console" commands, that just opens two consoles instead of one
  • No need to manually specify the baud rate.
  • "--serial" option has been deprecated
  • The RedHat console device is "/dev/ttyS0", not "/dev/tty0"

See: http://anaconda-installer.readthedocs.io/en/latest/boot-options.html

brayden
  • 131
  • 1
  • 3
6

--nographics is used, and you have no console set up in the guest, besides the tty0 console. If you want a graphical console, especially available remotely you'd need to enable vga and vnc, or qxl and spice. this is an example: http://www.linux-kvm.com/content/tip-how-run-headless-guest-machine-using-vnc-kvm

http://www.linux-kvm.com/content/running-kvm-nographics-no-console-output or http://ubuntuforums.org/showpost.php?p=9610421&postcount=7 is also a solution.

dyasny
  • 18,482
  • 6
  • 48
  • 63
  • Thanks for answering, dyasny. Picking your points: 1. No, I do NOT want a graphical console (see my post) 2. Yes, I have been trying this and similar solutions. It didn't work for me. – badbishop Apr 10 '11 at 15:54
  • I'd try to ask on linux-kvm.org or on the libvirt mailing list – dyasny Apr 12 '11 at 17:11
6

I had a similar problem when trying to perform a text-only installation of CentOS. It all boils down to adding kernel arguments for specifying serial output console console=ttyS0 so that you can then connect to it when --graphics none or --nographics is used. From virt-install's manual:

--graphics none

No graphical console will be allocated for the guest. Fully virtualized guests (Xen FV or QEmu/KVM) will need to have a text console configured on the first serial port in the guest (this can be done via the --extra-args option). Xen PV will set this up automatically. The command 'virsh console NAME' can be used to connect to the serial device.

I've managed to solve it in two ways:

  1. by modifying the iso image and using the --cdrom option
  2. by exposing the iso image as NFS share and using the --location option with --extra-args

1. Modifying the image

In order to modify the kernel parameters on the iso installation disk:

  1. Get a program that allows manipulating images, for example, isomaster.
  2. Go to to the isolinux/isolinux.cfg file on the image, open it, find the first line with initrd= on it and append console=ttyS0 to it and all other lines that have the mentioned parameter.
  3. Save the file and the image.
  4. Use the modified image with virt-install as usual, e.g.:

    $ sudo virt-install --name centos-vm --ram 1024 --disk path=/home/user/domains/centos-vm --cdrom /home/user/images/centos-modified.iso --os-type linux --nographics --accelerate
    

Done.

2. Using a NFS share

  1. Mount the image:

    $ sudo mount -o loop,unhide -t iso9660 -r /home/user/images/CentOS.iso /home/user/mnt/cdrom
    
  2. Start the NFS service if not running: service nfs start

  3. Add the following line in /etc/exports to make it available to the clients:

    /home/user/mnt/cdrom    *(ro,insecure,all_squash)
    
  4. Refresh the system's export table with:

    $ exportfs -r
    
  5. Use the share with virt-install making sure to inculde the --extra-args, e.g.:

    $ sudo virt-install --name centos-vm --ram 1024 --disk path=/home/user/domains/centos-vm --location /home/user/mnt/cdrom --os-type linux --nographics --accelerate --extra-args="console=ttyS0"
    
  6. During the installation of CentOS you get a prompt asking about the location of the installation files. You have to type the address of your machine and the full path to the share.

Done.

Johnny Baloney
  • 161
  • 1
  • 3
  • i have tried your second method to mount iso file but i got this error Starting install... Retrieving file .treeinfo... | 552 B 00:00:00 ERROR No option 'kernel' in section: 'images-x86_64' i mount iso file to /mnt and use --location /mnt in virt-install – public_name Jan 04 '15 at 13:04
  • @public_name Try not mounting the iso but just specifying the path to the iso after `--location` like `--location /tmp/centos6.iso`. – Rick Chatham Sep 30 '15 at 23:18
  • Worked on Ubuntu 16, editing isolinux/txt.cfg instead of isolinux/isolinux.cfg. – John McGehee Aug 16 '18 at 01:55
2

You need to run the Fedora installer in text mode. Try adding 'text' to the extra args. Alternatively, you could try adding "vnc" which will allow you to connect to the installer over VNC once it is started

katriel
  • 4,407
  • 22
  • 20
  • 1
    Checked it out, for a newer libvirt, you can't use -x and --cdrom. Try mounting the cdrom somewhere on the network and using --location http://somewhere.com/mounted-iso --graphics none --extra-args "console=ttyS0,115200 text headless" – katriel Aug 07 '11 at 21:08
1

I'd guess you are seeing a misconfigured console.

Maybe try this or similar:

First I add console line to my grub config, e.g. for an Arch guest: kernel /vmlinuz26 root=/dev/vda2 ro console=ttyS0,115200 Then I edit /etc/inittab to enable ttyS0 (same Arch guest): co:23:respawn:/sbin/agetty -8 115200 ttyS0 linux. And make sure you have ttyS0 in your /etc/securetty.

More info here: `http://www.linux-kvm.com/content/running-kvm-nographics-no-console-output

--edit--

You could try console=ttyS0,115200and check other possible console parameters maybe.

Navin
  • 115
  • 1
  • 7
Jonathan Ross
  • 2,173
  • 11
  • 14
1

I've been doing my installations for a while now using cobbler and koan. Within cobbler I set my kernel options like so under my Centos60-x86_64 profile:

Kernel Options: serial console=ttyS0,115200
Kernel Options (Post Install): console=ttyS0,115200

After boot you can use console=tty0 console=ttS0,115200 to get console to show on two devices; this doesn't work for installation. If you edit the grub options under /etc/grub and regenerate grub.conf the serial console settings will survive a kernel upgrade. Add "text" to the kernel command line to prevent installer from starting a GUI.

When my KVM guest instances start I then connect to them while logged into the KVM host and connect to a guest's console like this:

[root@vmhost ~]# virsh console guestvm

I then see this in my shell:

Connected to domain guestvm
Escape character is ^]

CentOS Linux release 6.0 (Final)
Kernel 2.6.32-71.el6.x86_64 on an x86_64

guestvm login: 

One final note, when I tell koan to start building one of my KVM guests, I call it with the --nogfx switch like so:

koan --server 192.168.1.1 --virt --nogfx --system=guestvm
slm
  • 7,355
  • 16
  • 54
  • 72