Skip to content

Instantly share code, notes, and snippets.

@mgerdts
Last active February 19, 2020 15:56
Show Gist options
  • Save mgerdts/007f9a41e73aaff9a583eb4af87a6b8c to your computer and use it in GitHub Desktop.
Save mgerdts/007f9a41e73aaff9a583eb4af87a6b8c to your computer and use it in GitHub Desktop.

This records my configuration of a host used for Linux CN development. The host is a relatively current Intel box with 64 GiB of RAM. It is running Fedora 30.

Virtualization on the host

QEMU/KVM

I had initially gone down the route of using QEMU/KVM and this worked pretty well except:

  • SmartOS CNs were unable to run bhyve instances. This is problematic for testing unrelated to the Linux CN project.
  • debian-live CNs were unable to use MACVLAN in their nspawn configuration to bridge to my office network. Watching traffic generated by the container using MACVLAN, I could see that DHCP requests would make it to the DHCP server. The responses were seen on the Fedora 30 host but not in the debian-live guest. No amount of mucking about or googling lead to a solution.

VMware Workstation Pro

With VMware Workstation Pro, I was able to boot debian-live VMs without trouble. In the default bridged networking configuration, MACVLAN networks were still not recieving replies. However, the VMware GUI popped up a warning saying that promiscuous mode was not allowed due to permission problems on /dev/vmnet devices. After chmod 666 /dev/vmnet* and restarting the VM all is well.

I have the following networks:

Name Type External Connection Host Connection DHCP MTU Triton Name
vmnet0 bridged eno2 external0
vmnet1 host-only none vmnet1 yes host0
vmnet2 host-only note none no 9000 admin0
vmnet8 NAT NAT vmnet8 yes

Serial console

A serial console is enabled with the following in a machine's vmx file:

serial0.fileType = "pipe"
serial0.fileName = "/tmp/console-debian-live-template"

To access the console, use vmware-sercons. To build it I needed:

diff --git a/Makefile b/Makefile
index a6b9126..f902399 100644
--- a/Makefile
+++ b/Makefile
@@ -10,6 +10,9 @@ ifeq ($(OS),SunOS)
 CFLAGS += -m32
 CFLAGS += -lnsl -lsocket
 endif
+ifeq ($(OS),Linux)
+CFLAGS += -lpthread
+endif

 PROG = sercons

Once it is built:

$ ./sercons /tmp/console-debian-live-1
 * Waiting for socket (/tmp/console-debian-live-1)........

When the VM starts:

 * Waiting for socket (/tmp/console-debian-live-1)...................................................
 * Connected.  Escape sequence is <Enter>#.
[    0.000000] Linux version 4.19.0-8-amd64 ([email protected]) (gcc version 8.3.0 (Debian 8.3.0-6)) #1 SMP Debian 4.19.98-1 (2020-01-26)
...

To disconnect from sercons, type #..

The vmx file

The complete vmx file is:

.encoding = "UTF-8"
config.version = "8"
virtualHW.version = "16"
mks.enable3d = "TRUE"
pciBridge0.present = "TRUE"
pciBridge4.present = "TRUE"
pciBridge4.virtualDev = "pcieRootPort"
pciBridge4.functions = "8"
pciBridge5.present = "TRUE"
pciBridge5.virtualDev = "pcieRootPort"
pciBridge5.functions = "8"
pciBridge6.present = "TRUE"
pciBridge6.virtualDev = "pcieRootPort"
pciBridge6.functions = "8"
pciBridge7.present = "TRUE"
pciBridge7.virtualDev = "pcieRootPort"
pciBridge7.functions = "8"
vmci0.present = "TRUE"
hpet0.present = "TRUE"
displayName = "debian-live-template"
guestOS = "ubuntu"
nvram = "debian-live-template.nvram"
virtualHW.productCompatibility = "hosted"
powerType.powerOff = "soft"
powerType.powerOn = "soft"
powerType.suspend = "soft"
powerType.reset = "soft"
usb.vbluetooth.startConnected = "TRUE"
tools.syncTime = "FALSE"
sound.startConnected = "FALSE"
sound.autoDetect = "TRUE"
sound.fileName = "-1"
numvcpus = "4"
vcpu.hotadd = "TRUE"
memsize = "4096"
mem.hotadd = "TRUE"
scsi0.virtualDev = "lsilogic"
scsi0.present = "TRUE"
sata0.present = "TRUE"
scsi0:0.fileName = "debian-live-template.vmdk"
scsi0:0.present = "TRUE"
sata0:1.deviceType = "cdrom-image"
sata0:1.fileName = "/data/vmware/debian-live.iso"
sata0:1.present = "TRUE"
svga.graphicsMemoryKB = "786432"
ethernet0.addressType = "generated"
serial0.fileType = "pipe"
serial0.fileName = "/tmp/console-debian-live-template"
ethernet0.present = "TRUE"
extendedConfigFile = "debian-live-template.vmxf"
floppy0.present = "FALSE"
ethernet0.connectionType = "custom"
ethernet0.vnet = "/dev/vmnet0"
serial0.present = "TRUE"

The entire template configuration is available for download.

Creating new instances

To create a new instance from the template:

newname=debian-live-3
vmrun clone debian-live-template/debian-live-template.vmx $newname/$newname.vmx full
sed -i -e "s/debian-live-template/$newname/g" -e 's/Clone of //' $newname/$newname.vmx
mv $newname/debian-live-template-cl1.vmdk $newname/$newname-cl1.vmdk

Once a new instance is created, it may be booted then configured. See First boot build machine setup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment