Update VM deployment script and documentation to reflect new default VM name 'CUBE' and IP configuration. Adjusted cloud-init settings for static IP and network details. Enhanced README and related scripts for clarity on VLAN and bridge usage.
This commit is contained in:
39
README.md
39
README.md
@@ -13,12 +13,14 @@ Deploy a **Debian 13 minimal** VM with cloud-init on a host running **QEMU** and
|
||||
|
||||
## Specs (as requested)
|
||||
|
||||
- **VM name:** `CUBE` (override with `VM_NAME=...`)
|
||||
- **CPU:** 2 cores
|
||||
- **Memory:** 4 GB RAM + 4 GB swap
|
||||
- **Storage:** 128 GB
|
||||
- **IP:** 192.168.0.225
|
||||
- **IP:** 192.168.0.225 (set in `cloud-init/user-data`; override there if needed)
|
||||
- **User:** `rina` / **Password:** `rinapwd`
|
||||
- **OS:** Latest Debian minimal (Debian 13 Trixie cloud image)
|
||||
- **Network:** By default the VM is attached to bridge **br1.40** (VLAN 40). See [VLAN 40 / br1.40 setup](docs/vlan40-bridge-systemd-networkd.md) on the host first.
|
||||
|
||||
## Requirements on the remote host
|
||||
|
||||
@@ -36,37 +38,41 @@ sudo apt install libvirt-daemon-system qemu-kvm virtinst libguestfs-tools cloud-
|
||||
|
||||
1. Copy this directory to the remote machine (or clone there).
|
||||
|
||||
2. **Optional:** Edit `cloud-init/user-data` and `cloud-init/network-config`:
|
||||
- Change gateway (default `192.168.0.1`) or DNS if your LAN differs.
|
||||
2. **On the host:** If using VLAN 40, configure br1.40 and eth1.40 first (see [docs/vlan40-bridge-systemd-networkd.md](docs/vlan40-bridge-systemd-networkd.md)).
|
||||
|
||||
3. **Optional:** Edit `cloud-init/user-data` and `cloud-init/network-config`:
|
||||
- Change IP (default `192.168.0.225/24`), gateway (`192.168.0.1`), or DNS if your LAN differs.
|
||||
- Add your SSH public key under `ssh_authorized_keys` for key-based login.
|
||||
- Network is also embedded in `user-data`; `network-config` is kept for reference.
|
||||
|
||||
3. Run the deploy script (on the remote host):
|
||||
4. Run the deploy script (on the remote host):
|
||||
|
||||
```bash
|
||||
chmod +x deploy-rina-vm.sh
|
||||
./deploy-rina-vm.sh
|
||||
```
|
||||
By default the VM is named **CUBE** and attached to bridge **br1.40**. Override with `VM_NAME=...` or `BRIDGE=...` if needed.
|
||||
|
||||
4. Wait for first boot (~1–2 minutes). Then:
|
||||
5. Wait for first boot (~1–2 minutes). Then:
|
||||
|
||||
```bash
|
||||
ssh rina@192.168.0.225
|
||||
# password: rinapwd
|
||||
```
|
||||
Or open the console: `virsh console CUBE`.
|
||||
|
||||
## What the script does
|
||||
|
||||
1. Downloads the Debian 13 generic cloud image (qcow2) once to `/var/lib/libvirt/images/`.
|
||||
2. Creates a 128 GB disk for the VM backed by that image.
|
||||
3. Builds a cloud-init **NoCloud** seed ISO from `cloud-init/user-data` and `cloud-init/meta-data`.
|
||||
4. Creates and starts the VM with **virt-install** (2 vCPU, 4 GB RAM, 128 GB disk, seed ISO attached).
|
||||
4. Creates and starts the VM with **virt-install** (name **CUBE**, 2 vCPU, 4 GB RAM, 128 GB disk, bridge **br1.40**, seed ISO attached).
|
||||
|
||||
## Customization
|
||||
|
||||
- **VM name:** `VM_NAME=myvm ./deploy-rina-vm.sh` (default: **CUBE**)
|
||||
- **Pool directory:** `POOL_DIR=/path/to/images ./deploy-rina-vm.sh`
|
||||
- **Network:** By default the script uses the libvirt network `default`. For a bridge (e.g. `br0`):
|
||||
`NETWORK=br0 ./deploy-rina-vm.sh`
|
||||
- **Network:** By default the VM is attached to bridge **br1.40** (VLAN 40). To use another bridge: `BRIDGE=br0 ./deploy-rina-vm.sh`. To use a libvirt network: `BRIDGE= NETWORK=default ./deploy-rina-vm.sh`
|
||||
- **Resources:** `CPU=4 MEMORY_GB=8 DISK_GB=256 ./deploy-rina-vm.sh`
|
||||
|
||||
## Firewall and SSH (same as “Rina PC”)
|
||||
@@ -91,25 +97,28 @@ runcmd:
|
||||
|
||||
Adjust rules to match your Rina PC before deploying.
|
||||
|
||||
## Interface name (192.168.0.225 not working)
|
||||
## Interface name (wrong IP or DHCP)
|
||||
|
||||
If the VM gets an IP via DHCP instead of 192.168.0.225, the interface name might not be `enp1s0`. On the VM run `ip a` and note the main interface (e.g. `eth0`). Then in `cloud-init/user-data`, change the `network.ethernets` key from `enp1s0` to that name, rebuild the seed ISO, and redeploy (or fix netplan inside the VM once).
|
||||
If the VM gets an IP via DHCP instead of 192.168.0.225, the interface name might not be `enp1s0`. On the VM run `ip a` and note the main interface (e.g. `eth0`). Then in `cloud-init/user-data` (and `cloud-init/network-config` if used), change the `network.ethernets` key from `enp1s0` to that name, rebuild the seed ISO, and redeploy (or fix netplan inside the VM once).
|
||||
|
||||
## Useful commands (on the host)
|
||||
|
||||
```bash
|
||||
virsh list --all
|
||||
virsh console rina
|
||||
virsh shutdown rina
|
||||
virsh start rina
|
||||
virsh console CUBE
|
||||
virsh shutdown CUBE
|
||||
virsh start CUBE
|
||||
```
|
||||
(Use your `VM_NAME` if you overrode it.)
|
||||
|
||||
## Files
|
||||
|
||||
- `deploy-rina-vm.sh` – Deploy script (download image, create disk, build seed ISO, virt-install).
|
||||
- `cloud-init/user-data` – User `rina`, password, sudo, SSH, packages, static IP, 4 GB swap.
|
||||
- `deploy-rina-vm.sh` – Deploy script (VM name **CUBE**, bridge **br1.40** by default; download image, create disk, build seed ISO, virt-install).
|
||||
- `setup-vlan40-bridge.sh` – Optional one-off script to create br1.40 and attach eth1.40; for persistent config use systemd-networkd (see docs).
|
||||
- `cloud-init/user-data` – User `rina`, password, sudo, SSH, packages, static IP (192.168.0.225), 4 GB swap.
|
||||
- `cloud-init/meta-data` – Instance ID and hostname.
|
||||
- `cloud-init/network-config` – Standalone netplan-style config (reference; main config is in user-data).
|
||||
- `docs/vlan40-bridge-systemd-networkd.md` – Host setup for VLAN 40 and bridge br1.40 with systemd-networkd.
|
||||
|
||||
## Reference
|
||||
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
instance-id: rina-vm-01
|
||||
local-hostname: rina
|
||||
local-hostname: cube
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
# Static network for Rina VM (VLAN 40 / br1.40)
|
||||
# Adjust gateway and nameservers to match your VLAN 40
|
||||
# Static network for VM (attached to br1.40 on host)
|
||||
# Adjust gateway and nameservers to match your network
|
||||
version: 2
|
||||
ethernets:
|
||||
enp1s0:
|
||||
addresses:
|
||||
- 192.168.40.225/24
|
||||
- 192.168.0.225/24
|
||||
routes:
|
||||
- to: default
|
||||
via: 192.168.40.1
|
||||
via: 192.168.0.1
|
||||
nameservers:
|
||||
addresses:
|
||||
- 8.8.8.8
|
||||
- 8.8.4.4
|
||||
- 192.168.0.1
|
||||
|
||||
|
||||
@@ -2,17 +2,17 @@
|
||||
# Rina VM - Debian minimal with cloud-init
|
||||
# User, SSH, swap, static IP, and base setup
|
||||
|
||||
# Static network on VLAN 40 (br1.40). IP 192.168.40.225; adjust gateway if your VLAN 40 differs.
|
||||
# Static network (VM is attached to br1.40 on host). IP 192.168.0.225; adjust gateway/DNS in this file if needed.
|
||||
network:
|
||||
version: 2
|
||||
ethernets:
|
||||
enp1s0:
|
||||
addresses: [192.168.40.225/24]
|
||||
addresses: [192.168.0.225/24]
|
||||
routes:
|
||||
- to: default
|
||||
via: 192.168.40.1
|
||||
via: 192.168.0.1
|
||||
nameservers:
|
||||
addresses: [192.168.40.1]
|
||||
addresses: [192.168.0.1]
|
||||
|
||||
users:
|
||||
- name: rina
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
set -e
|
||||
|
||||
VM_NAME="${VM_NAME:-rina}"
|
||||
VM_NAME="${VM_NAME:-CUBE}"
|
||||
CPU="${CPU:-2}"
|
||||
MEMORY_GB="${MEMORY_GB:-4}"
|
||||
DISK_GB="${DISK_GB:-128}"
|
||||
@@ -109,6 +109,6 @@ sudo virsh dumpxml "$VM_NAME" > "$VM_XML"
|
||||
echo "VM definition saved to: $VM_XML"
|
||||
|
||||
echo ""
|
||||
echo "VM '$VM_NAME' is starting. First boot runs cloud-init (user rina, password rinapwd, IP 192.168.40.225 on VLAN 40 / br1.40)."
|
||||
echo "VM '$VM_NAME' is starting. First boot runs cloud-init (user rina, password rinapwd; IP from cloud-init/user-data, e.g. 192.168.0.225)."
|
||||
echo "To open console: virsh console $VM_NAME"
|
||||
echo "To check: virsh list; ssh rina@192.168.40.225 (after cloud-init finishes, ~1–2 min)."
|
||||
echo "To check: virsh list; ssh rina@<VM_IP> (after cloud-init finishes, ~1–2 min)."
|
||||
|
||||
@@ -158,13 +158,13 @@ This ties the VLAN to eth1 so it is created when eth1 is configured. eth1 stays
|
||||
|
||||
## 8. Deploy the VM on br1.40
|
||||
|
||||
After `br1.40` is up and has `eth1.40` as a port, deploy the Rina VM onto it:
|
||||
After `br1.40` is up and has `eth1.40` as a port, deploy the VM onto it:
|
||||
|
||||
```bash
|
||||
BRIDGE=br1.40 ./deploy-rina-vm.sh
|
||||
```
|
||||
|
||||
The VM will get an IP in your VLAN 40 subnet via cloud-init (e.g. 192.168.40.225); adjust cloud-init if your subnet or gateway differ.
|
||||
By default the VM is named **CUBE**. It will get the IP configured in `cloud-init/user-data` (e.g. 192.168.0.225/24); adjust that file if your subnet or gateway differ. Console: `virsh console CUBE`.
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ echo "Done. $VLAN_IF is on bridge $BRIDGE."
|
||||
echo "Optionally assign an IP to $BRIDGE if this host must be on VLAN 40, e.g.:"
|
||||
echo " ip addr add 192.168.40.254/24 dev $BRIDGE"
|
||||
echo ""
|
||||
echo "Deploy Rina VM on this bridge with:"
|
||||
echo " BRIDGE=$BRIDGE ./deploy-rina-vm.sh"
|
||||
echo "Deploy VM on this bridge with:"
|
||||
echo " BRIDGE=$BRIDGE ./deploy-rina-vm.sh # VM name CUBE by default"
|
||||
echo "(Or use systemd-networkd for persistent config; see docs/vlan40-bridge-systemd-networkd.md)"
|
||||
echo ""
|
||||
|
||||
Reference in New Issue
Block a user