virt-manager requires GUI locally and it is slow. On other hand virt-install is a command line tool for provisioning new virtual machines using the “libvirt” hypervisor management library. The tool supports both text based & graphical installations, using serial console, SDL graphics or a VNC client/server pair. The guest can be configured to use one or more virtual disks, network interfaces, audio devices, and physical host devices (USB, PCI). You can use the virt-install to create virtualized guests as follows to install FreeBSD or CentOS.

Install FreeBSD As Guest OS

Again, use the wget command to grab FreeBSD ISO image:
# cd /tmp
# wget

Type the following command to install FreeBSD 7.3 64 bit with 512 MB RAM, 1 vcore cpu, 4GB disk space, br0 and br1 network interface:
# virt-install \
-n freebsd \
-r 512 \
--vcpus=1 \
--os-variant=freebsd7 \
--accelerate \
-v \
-c /nfsclient/iso/FreeBSD-7.3-RELEASE-amd64-disc1.iso \
-w bridge:br0 \
-w bridge:br1 \
--vnc \
--disk path=/raid10/kvm/freebsd73.img,size=4

Sample outputs:

Starting install...
Creating storage file...                                                                     | 4.0 GB     00:00     
Creating domain...                                                                           |    0 B     00:01     
Domain installation still in progress. You can reconnect to 
the console to complete the installation process.

Use your local vnc viewer or type the following at server itself:
# vncviewer
OR over ssh session, enter:
# ssh -X -C
# virt-viewer freebsd

Sample outputs:

Fig.01: Creating guest with virt-install and installing guests with vnc

Fig.01: Creating guest with virt-install and installing guests with vnc

Once again, just follow on screen installation instructions and install FreeBSD as per your requirements. The above procedure can be repeated for MS-Windows, OpenBSD, FreeBSD and all other supported guest operating systems.

Install CentOS As Guest OS

Type the following command to install CentOS using http mirror method with 512MB RAM, 4GB disk space stored on nas server mounted at /nas, br0 and br1 network interface:
# virt-install \
-n centos \
-r 512 \
--vcpus=1 \
--os-variant=rhel5.4 \
--accelerate \
-v \
-l \
-w bridge:br0 \
-w bridge:br1 \
--vnc \
--disk path=/nas/kvm/centos.img,size=4

You can grab installer screen using vnc as follows (or use your local vnc viewer):
# ssh -X -C
# virt-viewer centos

Understanding virt-install Command Line Options

  1. -n centos – Name of the new guest virtual machine instance. This must be unique amongst all guests known to the hypervisor on this machine, including those not currently active.
  2. -r 512 – VM memory allocation.
  3. –vcpus=1 – VM cpu allocation.
  4. –os-variant=rhel5.4 – Optimize the guest configuration for a type of operating system called rhel5.4.
  5. –accelerate – When installing a QEMU guest, make use of the KVM or KQEMU kernel acceleration capabilities if available. Use of this option is recommended unless a guest OS is known to be incompatible with the accelerators. The KVM accelerator is preferred over KQEMU if both are available.
  6. -v – This guest should be a fully virtualized guest
  7. -l – Install using http mirror.
  8. -w bridge:br0 – Connect the guest to the host network. In this example connect to a bridge device in the host called “br0”. Use this option if the host has static networking config & the guest requires full outbound and inbound connectivity to/from the LAN. Also use this if live migration will be used with this guest.
  9. -w bridge:br1 – Same as above but using br1 so that guest can have full outbound and inbound connectivity to/from the Internet.
  10. –vnc – Setup a virtual console in the guest and export it as a VNC server in the host.
  11. –disk path=/nas/kvm/centos.img,size=4 – Path to the file, disk partition, or logical volume to use as the backing store for the guest’s virtual disk.
This entry is 4 of 14 in the CentOS / Redhat (RHEL) KVM Virtulization series. Keep reading the rest of the series:
  1. CentOS / Redhat: Install KVM Virtualization Software
  2. CentOS / Redhat: KVM Bridged Network Configuration
  3. KVM virt-manager: Install CentOS As Guest Operating System
  4. KVM virt-install: Install FreeBSD / CentOS As Guest Operating System
  5. KVM: Install CentOS / RHEL Using Kickstart File (Automated Installation)
  6. Troubleshooting KVM Virtualization Problem With Log Files
  7. KVM Virsh: Redirect FreeBSD Console To A Serial Port
  8. KVM: Starting / Stopping Guest Operating Systems With virsh Command
  9. Linux KVM: Disable virbr0 NAT Interface
  10. FreeBSD / OpeBSD Running in KVM Does Not Accept FTP Traffic
  11. KVM: Start a Virtual Machine / Guest At Boot Time
  12. KVM virt-install: Install OpenBSD As Guest Operating System
  13. Linux KVM: OpenBSD Guest Hangs At Starting tty Flags
  14. KVM Virtualization: Start VNC Remote Access For Guest Operating Systems

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 5 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersncdu pydf
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
5 comments… add one
  • Krishna Jan 30, 2013 @ 9:17

    Hi Vivek,

    i have a vm running on RHEL6.3

    # virsh list
    Id Name State
    1 vm1 running

    # virt-install –name=vm1 –arch=x86_64 –vcpus=1 –ram=512 –os-type=linux –os-variant=rhel6 –hvm –connect=qemu:///system –network bridge:virbr0 –cdrom=/rhel-server-6.3-x86_64-dvd.iso –disk path=/mnt/virtual_machines/vm.img,size=20 –accelerate –vnc –noautoconsole –keymap=es

    2013-01-30 16:17:12.012+0000: starting up
    LC_ALL=C PATH=/sbin:/usr/sbin:/bin:/usr/bin QEMU_AUDIO_DRV=none /usr/libexec/qemu-kvm -S -M rhel6.3.0 -enable-kvm -m 512 -smp 1,sockets=1,cores=1,threads=1 -name vm1 -uuid 515b248f-b38e-61b6-a4d1-c7995a9cf110 -nodefconfig -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/vm1.monitor,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc -no-shutdown -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 -drive file=/mnt/virtual_machines/vm.img,if=none,id=drive-virtio-disk0,format=raw,cache=none -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x4,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 -drive 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=23,id=hostnet0,vhost=on,vhostfd=24 -device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:4a:54:ed,bus=pci.0,addr=0x3 -chardev pty,id=charserial0 -device isa-serial,chardev=charserial0,id=serial0 -device usb-tablet,id=input0 -vnc -k es -vga cirrus -incoming fd:21 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5
    char device redirected to /dev/pts/1

    i did not get past to complete the installation …. when i try to console in i get hanged

    # virsh console vm1
    Connected to domain vm1
    Escape character is ^]

    can you let me know what am I missing …

    • Eric Pretorious Sep 25, 2015 @ 1:17


      1. `virsh list` shows that the virtual machine ‘vm1’ is already running.
      2. You are using `virt-install` to create ANOTHER virtual machine named ‘vm1’.

      That, right there, should cause some errors. Try using a different name for creating a new VM.

      Eric P.

  • Paul Aug 17, 2015 @ 13:50

    Hi , i have Centos 6 VPS with 2 Gb Ram , i want to install quest FreeBSD , wen i type this

    virt-install \
    -n freebsd \
    -r 512 \
    --vcpus=1 \
    --os-variant=freebsd7 \
    --accelerate \
    -v \
    -c /nfsclient/iso/FreeBSD-7.3-RELEASE-amd64-disc1.iso \
    -w bridge:br0 \
    -w bridge:br1 \
    --vnc \
    --disk path=/raid10/kvm/freebsd73.img,size=4

    its say:

    ERROR Error with storage parameters: No read access to directory ‘/raid10/kvm’

    what to do? please help me

    • Eric Pretorious Sep 25, 2015 @ 0:30

      Hi, Paul:

      It looks like you haven’t defined the directory /raid10/kvm as a storage pool (so libvirtd is unable to create an image file [to act as the VM’s storage volume] at the location).


  • Eric Pretorious Sep 29, 2015 @ 20:56

    Personally, I prefer to access the HVM using VNC and SSH. (You’ve already enabled this by passing the –vnc flag to virt-install so there’s no need to change anything!)

    I began by establishing an SSH-encrypted tunnel from my workstation to the host:

    # ssh -L 5900:localhost:5900

    …and then configuring vinagre (the VNC viewer on my workstation) to use that tunnel:

    # vinagre localhost

    Eric Pretorious

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum