this post was submitted on 20 Jun 2025
11 points (100.0% liked)

Linux

55437 readers
617 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 6 years ago
MODERATORS
11
submitted 14 hours ago* (last edited 9 hours ago) by d00phy@lemmy.world to c/linux@lemmy.ml
 

I'm trying to boot some VMs using a script w/ a kickstart file. I'm using the following script that I found online and modified:

#!/usr/bin/env bash
#set -x
## Define variables
MEM_SIZE="8192"      # Memory setting in MiB
VCPUS="2"             # CPU Cores count
#OS_VARIANT="rocky9"   # List with osinfo-query  os
OS_VARIANT="rhel7.9"   # List with osinfo-query  os
ISO_FILE="~/Documents/software/os/RHEL-7.9-20200917.0-Server-x86_64-dvd1.iso" # Path to ISO file

case $OS_VARIANT in
        rhel7.9)
                KS=ks7.cfg;;
        rocky9)
                KS=ks9.cfg;;
esac

echo -en "Enter vm name: "
read VM_NAME
OS_TYPE="linux"
echo -en "Enter virtual disk size : "
read DISK_SIZE

DISK=~/.local/share/libvirt/images/${VM_NAME}.qcow2

echo "Creating disk"
sudo virt-install \
     --name ${VM_NAME} \
     --memory=${MEM_SIZE} \
     --vcpus=${VCPUS} \
     --location ${ISO_FILE} \
     --network network=default \
     --disk path=${DISK},size=${DISK_SIZE} \
     --graphics=none \
     --os-variant=${OS_VARIANT} \
     --console pty,target_type=serial \
     --initrd-inject ~/virt/${KS} --extra-args "inst.ks=file:/${KS} console=tty0 console=ttyS0,115200n8"

I've obfuscated the directory paths, but they're all full paths and the script will build a VM. So basically just setting up a basic system, using the default network. Here's the config for that:

<network connections='3'>
  <name>default</name>
  <uuid>61afc7f1-9c5e-4cra-8d18-e3cf4f9358e9</uuid>
  <forward mode='nat'>
    <nat>
      <port start='1024' end='65535'/>
    </nat>
  </forward>
  <bridge name='virbr0' stp='on' delay='0'/>
  <mac address='52:54:00:7c:32:9b'/>
  <ip address='192.168.122.1' netmask='255.255.255.0'>
    <dhcp>
      <range start='192.168.122.2' end='192.168.122.254'/>
    </dhcp>
  </ip>
</network>

Looking at the XML for the VM, I see the following for the network:

<interface type='network'>
      <mac address='52:54:00:07:82:78'/>
      <source network='default' portid='800dfd67-d90a-42te-a0b7-c4c78cdae481' bridge='virbr0'/>
      <target dev='vnet7'/>
      <model type='virtio'/>
      <alias name='net0'/>
      <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
    </interface>

When this VM is installing, and when it's booted, it does not have an IP. Meanwhile, if I go through virt-manager and select the default network, it gets an IP just fine. I've tried running the virt-install command w/ and w/o sudo (I run virt-manager as me - I'm in the libvirt group). Looking at the virt-manager built VM:

    <interface type='network'>
      <mac address='52:54:00:5e:f5:05'/>
      <source network='default' portid='d57dbc56-759e-40f9-856f-9623f4801a93' bridge='virbr0'/>
      <target dev='vnet8'/>
      <model type='virtio'/>
      <alias name='net0'/>
      <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
    </interface>

Looking at virbr0:

$ ip link show master virbr0
11: vnet7: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master virbr0 state UNKNOWN mode DEFAULT group default qlen 1000
    link/ether fe:54:00:07:82:78 brd ff:ff:ff:ff:ff:ff
12: vnet8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master virbr0 state UNKNOWN mode DEFAULT group default qlen 1000
    link/ether fe:54:00:5e:f5:05 brd ff:ff:ff:ff:ff:ff

Only difference I can see is one is created using virt-install and the other using virt-manager (which calls to virt-install, no?). I thought there was a way to see the actual virt-install command virt-manager was about to use when creating a VM, but I can't find it. Also can't find any logs to give me an idea why the VM isn't getting an IP. Running ethtool on the VM interface shows a link. I've wasted too much time getting this to work, and all the documentation suggests it should "just work!"

you are viewing a single comment's thread
view the rest of the comments
[–] data1701d@startrek.website 2 points 6 hours ago

I’m pretty sure by default, virtual networks are not enabled automatically if you’re not using virt-manager GUI.

To make it run automatically, run the following: virsh net-autostart default

If it’s not that, just to make it easier to find information, what’s your host distro? I’m guessing by mention of Kickstart files that it’s something Red Hat related, possibly Rocky 9 based on your choice of guest.