|  | 
| 3 | 3 | - NOTE: The username `guest` is used throughout this configuration (e.g., in sudoers, systemd user services, etc.). | 
| 4 | 4 |   To use a different user, replace all occurrences of `guest` with the `user_name` that is set in the `User Credentials` section of the `config-file`. | 
| 5 | 5 |   For example, if your user is 'myuser', replace `guest` with `myuser` in: | 
| 6 |  | -   - /etc/sudoers.d/idv_scripts | 
| 7 |  | -   - /etc/systemd/system/[email protected] /autologin.conf | 
| 8 |  | -   - runcmd section (sudo -u ...) | 
| 9 |  | -   - Any other relevant locations in this file. | 
| 10 |  | - | 
| 11 |  | -Author(s): Krishna, Shankar | 
| 12 |  | - | 
| 13 |  | -Last updated: 25/06/2025 | 
|  | 6 | +  - /etc/sudoers.d/idv_scripts | 
|  | 7 | +  - /etc/systemd/system/[email protected] /autologin.conf | 
|  | 8 | +  - runcmd section (sudo -u ...) | 
|  | 9 | +  - Any other relevant locations in this file. | 
| 14 | 10 | 
 | 
| 15 | 11 | ## Abstract | 
| 16 | 12 | 
 | 
| @@ -48,38 +44,7 @@ write_files: | 
| 48 | 44 |     append: true | 
| 49 | 45 |     content: | | 
| 50 | 46 |       export INTEL_IDV_GPU_PRODUCT_ID=$(cat /sys/devices/pci0000:00/0000:00:02.0/device | sed 's/^0x//') | 
| 51 |  | -      export INTEL_IDV_GPU_VENDOR_ID=$(cat /sys/devices/pci0000:00/0000:00:02.0/vendor | sed 's/^0x//') | 
| 52 |  | -   | 
| 53 |  | -  # hugepages.service pre-allocates enough 2MB hugepages for 2 VMs with 6GB RAM each. | 
| 54 |  | -  # Formula: 6 (memory per VM in GB) * 2048 (2MB pages per GB) * 2 (Number of VMs) = total hugepages needed.  | 
| 55 |  | -  # Adjust the 'memory per VM in GB' and 'number of VMs' as needed. | 
| 56 |  | -  - path: /usr/bin/allocate_hugepages.sh | 
| 57 |  | -    permissions: '0755' | 
| 58 |  | -    content: | | 
| 59 |  | -      #!/bin/bash | 
| 60 |  | -      HUGEPAGES=$(( 6 * 2048 * 2 )) | 
| 61 |  | -      HUGEPAGES_KB=$((HUGEPAGES * 2048)) | 
| 62 |  | -      MEM_TOTAL_KB=$(awk '/MemTotal/ {print $2}' /proc/meminfo) | 
| 63 |  | -      MEM_FREE_KB=$(awk '/MemFree/ {print $2}' /proc/meminfo) | 
| 64 |  | -      if [ "$MEM_TOTAL_KB" -le "$HUGEPAGES_KB" ] || [ "$MEM_FREE_KB" -le "$HUGEPAGES_KB" ]; then | 
| 65 |  | -        echo "ERROR: Not enough memory for hugepages allocation: need $HUGEPAGES_KB kB, total $MEM_TOTAL_KB kB, free $MEM_FREE_KB kB" >&2 | 
| 66 |  | -        exit 1 | 
| 67 |  | -      fi | 
| 68 |  | -      echo $HUGEPAGES > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages | 
| 69 |  | -
 | 
| 70 |  | -  - path: /etc/systemd/system/hugepages.service | 
| 71 |  | -    permissions: '0644' | 
| 72 |  | -    content: | | 
| 73 |  | -      [Unit] | 
| 74 |  | -      Description=Configure Hugepages | 
| 75 |  | -      Before=k3s.service | 
| 76 |  | -
 | 
| 77 |  | -      [Service] | 
| 78 |  | -      Type=oneshot | 
| 79 |  | -      ExecStart=/usr/bin/allocate_hugepages.sh | 
| 80 |  | -
 | 
| 81 |  | -      [Install] | 
| 82 |  | -      WantedBy=multi-user.target | 
|  | 47 | +      export INTEL_IDV_GPU_VENDOR_ID=$(cat /sys/devices/pci0000:00/0000:00:02.0/vendor | sed 's/^0x//')   | 
| 83 | 48 | 
 | 
| 84 | 49 |   # autologin.conf configures automatic login for the specified user on tty1. | 
| 85 | 50 |   # Change AUTOLOGIN_USER to your intended username if not using 'guest' user. | 
| @@ -156,15 +121,10 @@ write_files: | 
| 156 | 121 | runcmd: | 
| 157 | 122 |   # Source /etc/environment to ensure newly created environment variables are available to subsequent commands in this boot sequence | 
| 158 | 123 |   - source /etc/environment | 
| 159 |  | -  - udevadm control --reload-rules | 
| 160 |  | -  - systemctl enable hugepages.service | 
| 161 |  | -  - systemctl start hugepages.service | 
|  | 124 | +  - udevadm control --reload-rules   | 
| 162 | 125 |   # Change `guest` to your intended username if not using 'guest' user. | 
| 163 | 126 |   - sudo -u guest XDG_RUNTIME_DIR=/run/user/$(id -u guest) systemctl --user enable idv-init.service | 
| 164 | 127 |   - sudo -u guest XDG_RUNTIME_DIR=/run/user/$(id -u guest) systemctl --user start idv-init.service | 
| 165 | 128 |   - test -f /opt/user-apps/network_config.sh && bash /opt/user-apps/network_config.sh /etc/cloud/custom_network.conf || echo "network_config.sh is missing" | 
| 166 |  | -  - test -f /opt/user-apps/apply_bridge_nad.sh && bash /opt/user-apps/apply_bridge_nad.sh /etc/cloud/custom_network.conf > /etc/cloud/apply_bridge_nad.log 2>&1 & | 
| 167 |  | -  - sudo systemctl restart k3s.service && while [ "$(systemctl is-active k3s.service)" != "active" ]; do echo "Waiting for k3s.service"; sleep 5; done; echo "k3s started" | 
| 168 |  | -  - k wait --for=condition=ready pod --all --timeout=300s | 
| 169 |  | - | 
|  | 129 | +  - test -f /opt/user-apps/apply_bridge_nad.sh && bash /opt/user-apps/apply_bridge_nad.sh /etc/cloud/custom_network.conf > /etc/cloud/apply_bridge_nad.log 2>&1 & || echo "apply_bridge_nad.sh is missing"   | 
| 170 | 130 | ``` | 
0 commit comments