Author: C.J. Collier

  • Browser Errors vs. Link Lights: Demystifying Network Connectivity with the OSI Model

    Browser Errors vs. Link Lights: Demystifying Network Connectivity with the OSI Model

    We’ve all been there: you open your web browser, eager to surf the net, only to be greeted by the dreaded “There is no Internet connection” message. It’s frustrating, but understanding how your computer connects to the internet can turn that frustration into a methodical troubleshooting process. This is where the OSI (Open Systems Interconnection) model comes in handy, helping us understand the different layers of network communication.

    Consider the common scenario depicted in the image you might have seen:

    The image above perfectly illustrates this point. We see a person attempting to fix a network cable with a crimping tool, followed by the familiar “There is no Internet connection” error message. This simple sequence highlights a crucial distinction in network troubleshooting: the difference between verifying low-level physical connectivity and the high-level application layer reporting a problem.

    The OSI Model: A Layered Approach to Networking

    To truly understand this, we need to briefly touch upon the OSI (Open Systems Interconnection) model. Think of it as a seven-layer cake, where each layer handles a specific aspect of network communication. Data travels down the layers on the sender’s side and up the layers on the receiver’s side.

    Layer 7: Application Layer
    This is where your web browser lives. It’s what you interact with directly. When the browser displays “no Internet connection,” it’s reporting a problem at this highest layer, indicating that it can’t reach the desired resource (like a website).
    Layer 6: Presentation Layer
    Responsible for data formatting and encryption/decryption.
    Layer 5: Session Layer
    Manages communication sessions between applications.
    Layer 4: Transport Layer
    Handles reliable data transfer between applications (e.g., TCP for web browsing). If a connection can’t be established, the browser will eventually time out.
    Layer 3: Network Layer
    Deals with logical addressing (IP addresses) and routing data across different networks. If your computer doesn’t have a valid IP address or can’t find a route to the internet, this layer is the culprit.
    Layer 2: Data Link Layer
    Manages physical addressing (MAC addresses) and frames data for transmission over the local network segment. This layer ensures data is correctly passed to the physical layer.
    Layer 1: Physical Layer
    This is the most fundamental layer. It deals with the actual physical medium of transmission – the cables, connectors, Wi-Fi signals, and the electrical or optical signals that carry data. The act of crimping an Ethernet cable, as shown in the image, directly addresses this layer.

    Browser Error: A High-Level Symptom

    When your browser throws up a “no Internet connection” error, it’s a high-level symptom. It means that somewhere down the OSI stack, a problem is preventing it from communicating with the internet. The browser doesn’t know *exactly* what the problem is, only that its request isn’t being fulfilled. The issue could be:

    • A disconnected or faulty cable (Layer 1)
    • Incorrect network settings (Layer 3)
    • A problem with your router or modem
    • A DNS issue preventing name resolution
    • A firewall blocking access
    • The website you’re trying to reach is down

    Link Lights: A Low-Level Diagnostic

    This is where checking network interface (NIC) or switch port link lights becomes incredibly useful. These small, often green or amber, lights on your computer’s Ethernet port or on your network switch/router provide direct feedback on the status of **Layer 1 (Physical Layer)** and sometimes **Layer 2 (Data Link Layer)** connectivity.

    • Link Light ON: This usually means a physical connection has been established. The cable is plugged in correctly, and the devices on both ends are communicating at the most basic level. For Ethernet, it often also implies a successful auto-negotiation of speed and duplex settings.
    • Link Light OFF: This is a red flag! It’s a strong indicator of a Layer 1 problem. The cable might be disconnected, faulty, or incorrectly crimped (as our image suggests). It could also mean the device on the other end is powered off or has a bad port.

    The Crucial Distinction

    The key takeaway is that the browser provides a high-level, generalized error, while link lights offer a low-level, specific diagnostic. If your link light is off, you know immediately that the problem is at the physical layer or very close to it. There’s no point in troubleshooting IP addresses or DNS settings if your physical connection isn’t even established.

    However, if your link light *is* on, but your browser still reports no internet, then you know the physical connection is likely fine, and you need to investigate higher layers of the OSI model – perhaps your IP address configuration, DNS settings, or even a problem with your Internet Service Provider (ISP).

    So, the next time you face an internet outage, remember the OSI model. Start with the basics: check those link lights. If they’re off, you’ve likely found your culprit at the physical layer. If they’re on, then you can confidently move up the stack to diagnose issues at the network or transport layers, bringing you closer to getting back online!

  • Installing a desktop environment on the HP Omen

    `dmidecode | grep -A8 ‘^System Information’`

    tells me that the Manufacturer is HP and Product Name is OMEN Transcend Gaming Laptop 14-fb0xxx

    I’m provisioning a new piece of hardware for my eng consultant and it’s proving more difficult than I expected. I must admit guilt for some of this difficulty. Instead of installing using the debian installer on my keychain, I dd’d the pv block device of the 16 inch 2023 version onto the partition set aside from it. I then rebooted into rescue mode and cleaned up the grub config, corrected the EFI boot partition’s path in /etc/fstab, ran the grub installer from the rescue menu, and rebooted.

    On the initial boot of the system, X or Wayland or whatever is supposed to be talking to this vast array of GPU hardware in this device, it’s unable to do more than create a black screen on vt1. It’s easy enough to switch to vt2 and get a shell on the installed system. So I’m doing that and investigating what’s changed in Trixie. It seems like it’s pretty significant. Did they just throw out Keith Packard’s and Behdad Esfahbod’s work on font rendering? I don’t understand what’s happening in this effort to abstract to a simpler interface. I’ll probably end up reading more about it.

    In an effort to have Debian re-configure the system for Desktop use, I have uninstalled as many packages as I could find that were in the display and human interface category, or were firmware/drivers for devices not present in this Laptop’s SoC. Some commands I used to clear these packages and re-install connamon follow:

    ```
    dpkg -S /etc/X11
    dpkg -S /usr/lib/firmware
    apt-get purge $(dpkg -l | grep -i \
      -e gnome -e gtk -e x11-common -e xfonts- -e libvdpau -e dbus-user-session -e gpg-agent \
      -e bluez -e colord -e cups -e fonts -e drm -e xf86 -e mesa -e nouveau -e cinnamon \
      -e avahi -e gdk -e pixel -e desktop -e libreoffice -e x11 -e wayland -e xorg \
      -e firmware-nvidia-graphics -e firmware-amd-graphics -e firmware-mediatek -e firmware-realtek \
      | awk '{print $2}')
    apt-get autoremove
    apt-get purge $(dpkg -l | grep '^r' | awk '{print $2}')
    tasksel install cinnamon-desktop
    ```

    And then I rebooted. When it came back up, I was greeted with a login prompt, and Trixie looks to be fully functional on this device, including the attached wifi radio, tethering to my android, and the thunderbolt-attached Marvell SFP+ enclosure.

    I’m also installing libvirt and fetched the DVD iso material for Debian, Ubuntu and Rocky in case we have a need of building VMs during the development process. These are the platforms that I target at work with gcp Dataproc, so I’m pretty good at performing maintenance operation on them at this point.

  • Security concerns regarding OpenSSH mac sha1 in Debian

    What is HMAC?

    HMAC stands for Hash-Based Message Authentication Code. It’s a specific way to use a cryptographic hash function (like SHA-1, SHA-256, etc.) along with a secret key to produce a unique “fingerprint” of some data. This fingerprint allows someone else with the same key to verify that the data hasn’t been tampered with.

    How HMAC Works

    Keyed Hashing: The core idea is to incorporate the secret key into the hashing process. This is done in a specific way to prevent clever attacks that might try to bypass the security.
    Inner and Outer Hashing: HMAC uses two rounds of hashing. First, the message and a modified version of the key are hashed together. Then, the result of that hash, along with another modified version of the key, are hashed again. This two-step process adds an extra layer of protection.

    HMAC in OpenSSH

    OpenSSH uses HMAC to ensure the integrity of messages sent back and forth during an SSH session. This prevents an attacker from subtly modifying data in transit.

    HMAC-SHA1 with OpenSSH: Is it Weak?

    SHA-1 itself is considered cryptographically broken. This means that with enough computing power, it’s possible to find collisions (two different messages that produce the same hash). However, HMAC-SHA1 is generally still considered secure for most purposes. This is because exploiting weaknesses in SHA-1 to break HMAC-SHA1 is much more difficult than just finding collisions in SHA-1.

    Should you use it?

    While HMAC-SHA1 might still be okay for now, it’s best practice to move to stronger alternatives like HMAC-SHA256 or HMAC-SHA512. OpenSSH supports these, and they provide a greater margin of safety against future attacks.

    In Summary

    HMAC is a powerful tool for ensuring data integrity. Even though SHA-1 has weaknesses, HMAC-SHA1 in OpenSSH is likely still safe for most users. However, to be on the safe side and prepare for the future, switching to HMAC-SHA256 or HMAC-SHA512 is recommended.

    Following are instructions for creating dataproc clusters with sha1 mac support removed:

    I can appreciate an excess of caution, and I can offer you some code to produce Dataproc instances which do not allow HMAC authentication using sha1.

    Place code similar to this in a startup script or an initialization action that you reference when creating a cluster with gcloud dataproc clusters create:

    #!/bin/bash
    # remove mac specification from sshd configuration
    sed -i -e 's/^macs.*$//' /etc/ssh/sshd_config
    # place a negative MACs specification in the /etc/ssh/sshd_config.d/ config directory
    mkdir -p /etc/ssh/sshd_config.d
    ssh -Q mac | perl -e \
      '@mac=grep{ chomp; /sha1/ }; print("MACs -", join(",",@mac), $/)' >> \
      /etc/ssh/sshd_config.d/disable-mac-sha1.conf
    # reload the new ssh service configuration
    systemctl reload ssh.service
    

    If this code is hosted on GCS, you can refer to it with

    --initialization-actions=CLOUD_STORAGE_URI,[...]

    or

    --metadata startup-script-url=CLOUD_STORAGE_URI,[...]
  • Managing HPE SAS Controllers

    Notes to self. And anyone else who might find them useful. Following are some ssacli commands which I use infrequently enough that they fall out of cache. This may repeat information in other blogs, but since I search my posts first when commands slip my mind, I thought I’d include them here, too.

    hpacucli is the wrong command. Use ssacli instead.

    $ KR='/usr/share/keyrings/hpe.gpg'
    $ for fingerprint in \
      882F7199B20F94BD7E3E690EFADD8D64B1275EA3 \
      57446EFDE098E5C934B69C7DC208ADDE26C2B797 \
      476DADAC9E647EE27453F2A3B070680A5CE2D476 ; do \
        curl "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x${fingerprint}" \
          | gpg --no-default-keyring --keyring "${KR}" --import ; \
      done
    $ gpg --list-keys --no-default-keyring --keyring "${KR}" 
    /usr/share/keyrings/hpe.gpg
    ---------------------------
    pub   rsa2048 2012-12-04 [SC] [expired: 2022-12-02]
          476DADAC9E647EE27453F2A3B070680A5CE2D476
    uid           [ expired] Hewlett-Packard Company RSA (HP Codesigning Service)
    
    pub   rsa2048 2014-11-19 [SC] [expired: 2024-11-16]
          882F7199B20F94BD7E3E690EFADD8D64B1275EA3
    uid           [ expired] Hewlett-Packard Company RSA (HP Codesigning Service) - 1
    
    pub   rsa2048 2015-12-10 [SCEA] [expires: 2025-12-07]
          57446EFDE098E5C934B69C7DC208ADDE26C2B797
    uid           [ unknown] Hewlett Packard Enterprise Company RSA-2048-25 
    $ echo "deb [signed-by=${KR}] http://downloads.linux.hpe.com/SDR/repo/mcp bookworm/current non-free" \
      | sudo dd of=/etc/apt/sources.list.d status=none
    $ sudo apt-get update
    $ sudo apt-get install -y -qq ssacli > /dev/null 2>&1
    $ sudo ssacli ctrl all show status
    
    HPE Smart Array P408i-p SR Gen10 in Slot 3
       Controller Status: OK
       Cache Status: OK
       Battery/Capacitor Status: OK
    
    $ sudo ssacli ctrl all show detail
    HPE Smart Array P408i-p SR Gen10 in Slot 3
       Bus Interface: PCI
       Slot: 3
       Serial Number: PFJHD0ARCCR1QM
       RAID 6 Status: Enabled
       Controller Status: OK
       Hardware Revision: B
       Firmware Version: 2.65
       Firmware Supports Online Firmware Activation: True
       Driver Supports Online Firmware Activation: True
       Rebuild Priority: High
       Expand Priority: Medium
       Surface Scan Delay: 3 secs
       Surface Scan Mode: Idle
       Parallel Surface Scan Supported: Yes
       Current Parallel Surface Scan Count: 1
       Max Parallel Surface Scan Count: 16
       Queue Depth: Automatic
       Monitor and Performance Delay: 60  min
       Elevator Sort: Enabled
       Degraded Performance Optimization: Disabled
       Inconsistency Repair Policy: Disabled
       Write Cache Bypass Threshold Size: 1040 KiB
       Wait for Cache Room: Disabled
       Surface Analysis Inconsistency Notification: Disabled
       Post Prompt Timeout: 15 secs
       Cache Board Present: True
       Cache Status: OK
       Cache Ratio: 10% Read / 90% Write
       Configured Drive Write Cache Policy: Disable
       Unconfigured Drive Write Cache Policy: Default
       Total Cache Size: 2.0
       Total Cache Memory Available: 1.8
       Battery Backed Cache Size: 1.8
       No-Battery Write Cache: Disabled
       SSD Caching RAID5 WriteBack Enabled: True
       SSD Caching Version: 2
       Cache Backup Power Source: Batteries
       Battery/Capacitor Count: 1
       Battery/Capacitor Status: OK
       SATA NCQ Supported: True
       Spare Activation Mode: Activate on physical drive failure (default)
       Controller Temperature (C): 53
       Cache Module Temperature (C): 43
       Capacitor Temperature  (C): 40
       Number of Ports: 2 Internal only
       Encryption: Not Set
       Express Local Encryption: False
       Driver Name: smartpqi
       Driver Version: Linux 2.1.18-045
       PCI Address (Domain:Bus:Device.Function): 0000:11:00.0
       Negotiated PCIe Data Rate: PCIe 3.0 x8 (7880 MB/s)
       Controller Mode: Mixed
       Port Max Phy Rate Limiting Supported: False
       Latency Scheduler Setting: Disabled
       Current Power Mode: MaxPerformance
       Survival Mode: Enabled
       Host Serial Number: 2M20040D1Q
       Sanitize Erase Supported: True
       Sanitize Lock: None
       Sensor ID: 0
          Location: Capacitor
          Current Value (C): 40
          Max Value Since Power On: 42
       Sensor ID: 1
          Location: ASIC
          Current Value (C): 53
          Max Value Since Power On: 55
       Sensor ID: 2
          Location: Unknown
          Current Value (C): 43
          Max Value Since Power On: 45
       Sensor ID: 3
          Location: Cache
          Current Value (C): 43
          Max Value Since Power On: 44
       Primary Boot Volume: None
       Secondary Boot Volume: None
    
    $ sudo ssacli ctrl all show config
    
    HPE Smart Array P408i-p SR Gen10 in Slot 3  (sn: PFJHD0ARCCR1QM)
    
    
    
       Internal Drive Cage at Port 1I, Box 2, OK
    
    
    
       Internal Drive Cage at Port 2I, Box 2, OK
    
    
       Port Name: 1I (Mixed)
    
       Port Name: 2I (Mixed)
    
       Array A (SAS, Unused Space: 0  MB)
    
          logicaldrive 1 (1.64 TB, RAID 6, OK)
    
          physicaldrive 1I:2:1 (port 1I:box 2:bay 1, SAS HDD, 300 GB, OK)
          physicaldrive 1I:2:2 (port 1I:box 2:bay 2, SAS HDD, 1.2 TB, OK)
          physicaldrive 1I:2:3 (port 1I:box 2:bay 3, SAS HDD, 300 GB, OK)
          physicaldrive 1I:2:4 (port 1I:box 2:bay 4, SAS HDD, 1.2 TB, OK)
          physicaldrive 2I:2:5 (port 2I:box 2:bay 5, SAS HDD, 300 GB, OK)
          physicaldrive 2I:2:6 (port 2I:box 2:bay 6, SAS HDD, 300 GB, OK)
          physicaldrive 2I:2:7 (port 2I:box 2:bay 7, SAS HDD, 1.2 TB, OK)
          physicaldrive 2I:2:8 (port 2I:box 2:bay 8, SAS HDD, 1.2 TB, OK)
    
       SEP (Vendor ID HPE, Model Smart Adapter) 379  (WWID: 51402EC013705E88, Port: Unknown)
    
    $ sudo ssacli ctrl slot=3 pd 2I:2:7 show detail
    
    HPE Smart Array P408i-p SR Gen10 in Slot 3
    
       Array A
    
          physicaldrive 2I:2:7
             Port: 2I
             Box: 2
             Bay: 7
             Status: OK
             Drive Type: Data Drive
             Interface Type: SAS
             Size: 1.2 TB
             Drive exposed to OS: False
             Logical/Physical Block Size: 512/512
             Rotational Speed: 10000
             Firmware Revision: U850
             Serial Number: KZGN1BDE
             WWID: 5000CCA01D247239
             Model: HGST    HUC101212CSS600
             Current Temperature (C): 46
             Maximum Temperature (C): 51
             PHY Count: 2
             PHY Transfer Rate: 6.0Gbps, Unknown
             PHY Physical Link Rate: 6.0Gbps, Unknown
             PHY Maximum Link Rate: 6.0Gbps, 6.0Gbps
             Drive Authentication Status: OK
             Carrier Application Version: 11
             Carrier Bootloader Version: 6
             Sanitize Erase Supported: False
             Shingled Magnetic Recording Support: None
             Drive Unique ID: 5000CCA01D247238
    
    

    2024-12-09 update

    I was experiencing a disk failure or predictive failure when I walked into my office this afternoon. I checked this blog post and found the command I used to check the status of the sas array.

    cjac@server0:~$ sudo ssacli ctrl all show config
    
    HPE Smart Array P408i-p SR Gen10 in Slot 3  (sn: PFJHD0ARCCR1QM)
    
    
    
       Internal Drive Cage at Port 1I, Box 2, OK
    
    
    
       Internal Drive Cage at Port 2I, Box 2, OK
    
    
       Port Name: 1I (Mixed)
    
       Port Name: 2I (Mixed)
    
       Array A (SAS, Unused Space: 0  MB)
    
          logicaldrive 1 (1.64 TB, RAID 6, OK)
    
          physicaldrive 1I:2:1 (port 1I:box 2:bay 1, SAS HDD, 300 GB, OK)
          physicaldrive 1I:2:2 (port 1I:box 2:bay 2, SAS HDD, 1.2 TB, Predictive Failure)
          physicaldrive 1I:2:3 (port 1I:box 2:bay 3, SAS HDD, 300 GB, OK)
          physicaldrive 1I:2:4 (port 1I:box 2:bay 4, SAS HDD, 1.2 TB, OK)
          physicaldrive 2I:2:5 (port 2I:box 2:bay 5, SAS HDD, 300 GB, OK)
          physicaldrive 2I:2:6 (port 2I:box 2:bay 6, SAS HDD, 300 GB, OK)
          physicaldrive 2I:2:7 (port 2I:box 2:bay 7, SAS HDD, 1.2 TB, OK)
          physicaldrive 2I:2:8 (port 2I:box 2:bay 8, SAS HDD, 300 GB, OK)
    
       SEP (Vendor ID HPE, Model Smart Adapter) 379  (WWID: 51402EC013705E88, Port: Unknown)
    

    At this point I engaged the under-study to have the flashing disk replaced

    cjac@server0:~$ sudo ssacli ctrl all show config
    [sudo] password for cjac: 
    
    HPE Smart Array P408i-p SR Gen10 in Slot 3  (sn: PFJHD0ARCCR1QM)
    
    
    
       Internal Drive Cage at Port 1I, Box 2, OK
    
    
    
       Internal Drive Cage at Port 2I, Box 2, OK
    
    
       Port Name: 1I (Mixed)
    
       Port Name: 2I (Mixed)
    
       Array A (SAS, Unused Space: 0  MB)
    
          logicaldrive 1 (1.64 TB, RAID 6, Recovering, 56.43% complete)
    
          physicaldrive 1I:2:1 (port 1I:box 2:bay 1, SAS HDD, 300 GB, OK)
          physicaldrive 1I:2:2 (port 1I:box 2:bay 2, SAS HDD, 300 GB, Rebuilding)
          physicaldrive 1I:2:3 (port 1I:box 2:bay 3, SAS HDD, 300 GB, OK)
          physicaldrive 1I:2:4 (port 1I:box 2:bay 4, SAS HDD, 1.2 TB, OK)
          physicaldrive 2I:2:5 (port 2I:box 2:bay 5, SAS HDD, 300 GB, OK)
          physicaldrive 2I:2:6 (port 2I:box 2:bay 6, SAS HDD, 300 GB, OK)
          physicaldrive 2I:2:7 (port 2I:box 2:bay 7, SAS HDD, 1.2 TB, OK)
          physicaldrive 2I:2:8 (port 2I:box 2:bay 8, SAS HDD, 300 GB, OK)
    
       SEP (Vendor ID HPE, Model Smart Adapter) 379  (WWID: 51402EC013705E88, Port: Unknown)
    

    In the next and future output, I will elide duplicate lines

    cjac@server0:~$ date ; sudo ssacli ctrl all show config
    Mon Dec  9 07:36:44 PM PST 2024 ... logicaldrive 1 (1.64 TB, RAID 6, Recovering, 66.85% complete)...
    Mon Dec  9 07:39:25 PM PST 2024 ... logicaldrive 1 (1.64 TB, RAID 6, Recovering, 68.97% complete) ...
    cjac@server0:~$ date ; sudo ssacli ctrl all show config | grep Recovering
    Mon Dec  9 07:43:05 PM PST 2024 ... logicaldrive 1 (1.64 TB, RAID 6, Recovering, 71.85% complete)
    Mon Dec  9 07:43:57 PM PST 2024 ... logicaldrive 1 (1.64 TB, RAID 6, Recovering, 72.55% complete)
    cjac@server0:~$ sleep 5m ; date ; sudo ssacli ctrl all show config | grep Recovering
    Mon Dec  9 07:49:43 PM PST 2024 ... logicaldrive 1 (1.64 TB, RAID 6, Recovering, 77.00% complete)
    cjac@server0:~$ date ; sudo ssacli ctrl all show config | grep -e 1I:2:2 -e logicaldrive
    Mon Dec  9 11:36:14 PM PST 2024 ... logicaldrive 1 (1.64 TB, RAID 6, OK)
    physicaldrive 1I:2:2 (port 1I:box 2:bay 2, SAS HDD, 300 GB, OK)
    
  • Signed NVIDIA drivers on Google Cloud Dataproc 2.2

    Hello folks,

    I’ve been working this year on better integrating NVIDIA hardware with the Google Cloud Dataproc product (Hadoop on Google Cloud) running the default cluster node image. We have an open bug[1] in the initialization-actions repo regarding creation failures upon enabling secure boot. This is because with secure boot, kernel driver code has its signature verified before insmod places the symbols into kernel memory. The verification process involves reading trust root certificates from EFI variables, and validating that the signatures on the kernel driver either a) were made directly by one of the certificates in the boot sector or b) were made by certificates which chain up to one of them.

    This means that Dataproc disk images must have a certificate installed into them. My work on the internals will likely start producing images which have certificates from Google in them. In the meantime, however, our users are left without a mechanism to have both secure boot enabled and install out-of-tree kernel modules such as the NVIDIA GPU drivers. To that end, I’ve got PR #83[2] open with the GoogleCloudDataproc/custom-images github repository. This PR introduces a new argument to the custom image creation script, `–trusted-cert`, the argument of which is the path to a DER-encoded certificate to be included in the certificate database in the EFI variables of the disk’s boot sector.

    I’ve written up the instructions on creating a custom image with a trusted certificate here:

    https://github.com/cjac/custom-images/blob/secure-boot-custom-image/examples/secure-boot/README.md

    Here is a set of commands that can be used to create a Dataproc custom image with certificate installed to the EFI’s db variable. You can run these commands from the root directory of a checkout such as this:

    
    
    git clone https://github.com/cjac/custom-images.git --branch secure-boot-custom-image --single-branch
    pushd custom-images
    PROJECT_ID=your-project-here
    PROJECT_NUMBER=your-project-nnnn-here
    my_bucket=your-bucket-here
    custom_image_zone=your-zone-here
    
    gcloud projects add-iam-policy-binding ${PROJECT_ID} \
            --member=serviceAccount:${PROJECT_NUMBER}-compute@developer.gserviceaccount.com \
            --role=roles/secretmanager.secretAccessor
    gcloud config set project ${PROJECT_ID}
    
    gcloud auth login
    
    eval $(bash examples/secure-boot/create-key-pair.sh)
    metadata="public_secret_name=${public_secret_name}"
    metadata="${metadata},private_secret_name=${private_secret_name}"
    metadata="${metadata},secret_project=${secret_project}"
    metadata="${metadata},secret_version=${secret_version}"
    
    #dataproc_version=2.1-debian11
    dataproc_version=2.2-debian12
    #customization_script=examples/secure-boot/install-nvidia-driver-debian11.sh
    customization_script=examples/secure-boot/install-nvidia-driver-debian12.sh
    #image_name="nvidia-open-kernel-bullseye-$(date +%F)"
    image_name="nvidia-open-kernel-bookworm-$(date +%F)"
    disk_size_gb="50"
    
    python generate_custom_image.py \
        --image-name ${image_name} \
        --dataproc-version ${dataproc_version} \
        --trusted-cert "tls/db.der" \
        --customization-script ${customization_script} \
        --metadata "${metadata}" \
        --zone "${custom_image_zone}" \
        --disk-size "${disk_size_gb}" \
        --no-smoke-test \
        --gcs-bucket "${my_bucket}"
    popd
    

    I’d love to hear your feedback!

    [1] https://github.com/GoogleCloudDataproc/initialization-actions/issues/1058
    [2] https://github.com/GoogleCloudDataproc/custom-images/pull/83

  • IPv6 Multicast support on libvirt guests using macvtap

    #
    # Debian / libvirt
    #
    
    # By default, qemu guests network interfaces are created with the
    # trustGuestRxFilters attribute set to no.  This setting blocks
    # neighbor solicitation and other ipv6 multicast traffic.  To enable
    # neighbor solicitations, modify your interface definition in your
    # guest definition XML.
    
    # For example if you have a guest named bird0 with an interface
    # definition that looks like this:
    
    $ sudo virsh dumpxml bird0 | grep -A7 "type='direct'"
        <interface type='direct' trustGuestRxFilters='no'>
          <mac address='52:54:00:AA:BB:CC'/>
          <source dev='ens2f0np0' mode='bridge'/>
          <target dev='macvtap3'/>
          <model type='virtio'/>
          <alias name='net4'/>
          <address type='pci' domain='0x0000' bus='0x09' slot='0x00' function='0x0'/>
        </interface>
    
    # Then use 'virsh edit bird0' change the attribute in the <interface>
    # element to have the value 'yes' instead:
        <interface type='direct' trustGuestRxFilters='yes'>
          <mac address='52:54:00:AA:BB:CC'/>
          <source dev='ens2f0np0' mode='bridge'/>
          <target dev='macvtap3'/>
          <model type='virtio'/>
          <alias name='net4'/>
          <address type='pci' domain='0x0000' bus='0x09' slot='0x00' function='0x0'/>
        </interface>
    
    # If the trustGuestRxFilters attribute is missing, it defaults to no,
    # so be sure that the attribute exists and that the attribute has a
    # value of 'yes'
    
  • Converting a windows install to a libvirt VM

    Reduce the size of your c: partition to the smallest it can be and then turn off windows with the understanding that you will never boot this system on the iron ever again.
    Boot into a netinst installer image (no GUI). hold alt and press left arrow a few times until you get to a prompt to press enter. Press enter.

    In this example /dev/sda is your windows disk which contains the c: partition
    and /dev/disk/by-id/usb0 is the USB-3 attached SATA controller that you have your SSD attached to (please find an example attached). This SSD should be equal to or larger than the windows disk for best compatability.

    A photo of a USB-3 attached SATA controller

    To find the literal path names of your detected drives you can run fdisk -l. Pay attention to the names of the partitions and the sizes of the drives to help determine which is which.

    Once you have a shell in the netinst installer, you should maybe be able to run a command like the following. This will duplicate the disk located at if (in file) to the disk located at of (out file) while showing progress as the status.

    dd if=/dev/sda of=/dev/disk/by-id/usb0 status=progress

    If you confirm that dd is available on the netinst image and the previous command runs successfully, test that your windows partition is visible in the new disk’s partition table. The start block of the windows partition on each should match, as should the partition size.

    fdisk -l /dev/disk/by-id/usb0
    fdisk -l /dev/sda

    If the output from the first is the same as the output from the second, then you are probably safe to proceed.

    Once you confirm that you have made and tested a full copy of the blocks from your windows drive saved on your usb disk, nuke your windows partition table from orbit.

    dd if=/dev/zero of=/dev/sda bs=1M count=42

    You can press alt-f1 to return to the Debian installer now. Follow the instructions to install Debian. Don’t forget to remove all attached USB drives.

    Once you install Debian, press ctrl-alt-f3 to get a root shell.

    Add your user to the sudoers group:

    # adduser cjac sudoers

    log out

    # exit

    log in as your user and confirm that you have sudo

    $ sudo ls

    Don’t forget to read the spider man advice

    enter your password

    you’ll need to install virt-manager. I think this should help:

    $ sudo apt-get install virt-manager libvirt-daemon-driver-qemu qemu-system-x86

    insert the USB drive. You can now create a qcow2 file for your virtual machine.

    $ sudo qemu-img convert -O qcow2 \
    /dev/disk/by-id/usb0 \
    /var/lib/libvirt/images/windows.qcow2

    I personally create a volume group called /dev/vg00 for the stuff I want to run raw and instead of converting to qcow2 like all of the other users do, I instead write it to a new logical volume.

    sudo lvcreate /dev/vg00 -n windows -L 42G # or however large your drive was
    sudo dd if=/dev/disk/by-id/usb0 of=/dev/vg00/windows status=progress

    Now that you’ve got the qcow2 file created, press alt-left until you return to your GDM session.

    The apt-get install command above installed virt-manager, so log in to your system if you haven’t already and open up gnome-terminal by pressing the windows key or moving your mouse/gesture to the top left of your screen. Type in gnome-terminal and either press enter or click/tap on the icon.

    I like to run this full screen so that I feel like I’m in a space ship. If you like to feel like you’re in a spaceship, too, press F11.

    You can start virt-manager from this shell or you can press the windows key and type in virt-manager and press enter. You’ll want the shell to run commands such as virsh console windows or virsh list

    When virt-manager starts, right click on QEMU/KVM and select New.

    In the New VM window, select “Import existing disk image”

    When prompted for the path to the image, use the one we created with sudo qemu-img convert above.

    Select the version of Windows you want.

    Select memory and CPUs to allocate to the VM.

    Tick the Customize configuration before install box

    If you’re prompted to enable the ‘default’ network, do so now.

    The default hardware layout should probably suffice. Get it as close to the underlying hardware as it is convenient to do. But Windows is pretty lenient these days about virtualizing licensed windows instances so long as they’re not running in more than one place at a time.

    Good luck! Leave comments if you have questions.

  • First taste of Debian 12

    As some of you may know, the Debian project released v12, bookworm to stable on the 10th of this month. I haven’t had a reason to try it yet, but I’m downloading it now. My first thought is that it’s much larger than I expected. The normal sized version used to fit on a CD-ROM disk, so around 650MB. The netinst has until now been even smaller, with the most recent versions being about 256MB if I recall correctly. The netinst, now with proprietary firmware, weighs in over 700MB:

    2023-06-18 20:29:29 (6.85 MB/s) - ‘debian-12.0.0-amd64-netinst.iso’ saved [773849088/773849088]

    It looks like 738.0MB!

    The system I’m installing is for a piece of software I’m crafting for use by Remote Online Notaries. I’m building a disk image for the notary’s side of the connection. The notary will have a yubikey-style PGP card which they will use as a digital seal similar to the one required to perform notarial acts for the state of washington. I’ll leave some ramblings on the blog as I go through the process of implementation. Here’s a link to whet your appetite!

    https://app.leg.wa.gov/wac/default.aspx?cite=308-30-020

  • Early Access: Inserting JSON data to BigQuery from Spark on Dataproc

    Hello folks!

    We recently received a case letting us know that Dataproc 2.1.1 was unable to write to a BigQuery table with a column of type JSON. Although the BigQuery connector for Spark has had support for JSON columns since 0.28.0, the Dataproc images on the 2.1 line still cannot create tables with JSON columns or write to existing tables with JSON columns.

    The customer has graciously granted permission to share the code we developed to allow this operation. So if you are interested in working with JSON column tables on Dataproc 2.1 please continue reading!

    Use the following gcloud command to create your single-node dataproc cluster:

    IMAGE_VERSION=2.1.1-debian11
    REGION=us-west1
    ZONE=${REGION}-a
    CLUSTER_NAME=pick-a-cluster-name
    gcloud dataproc clusters create ${CLUSTER_NAME} \
        --region ${REGION} \
        --zone ${ZONE} \
        --single-node \
        --master-machine-type n1-standard-4 \
        --master-boot-disk-type pd-ssd \
        --master-boot-disk-size 50 \
        --image-version ${IMAGE_VERSION} \
        --max-idle=90m \
        --enable-component-gateway \
        --scopes 'https://www.googleapis.com/auth/cloud-platform'
    

    The following file is the Scala code used to write JSON structured data to a BigQuery table using Spark. The file following this one can be executed from your single-node Dataproc cluster.

    Main.scala

    import org.apache.spark.sql.functions.col
    import org.apache.spark.sql.types.{Metadata, StringType, StructField, StructType}
    import org.apache.spark.sql.{Row, SaveMode, SparkSession}
    import org.apache.spark.sql.avro
    import org.apache.avro.specific
    
      val env = "x"
      val my_bucket = "cjac-docker-on-yarn"
      val my_table = "dataset.testavro2"
        val spark = env match {
          case "local" =>
            SparkSession
              .builder()
              .config("temporaryGcsBucket", my_bucket)
              .master("local")
              .appName("isssue_115574")
              .getOrCreate()
          case _ =>
            SparkSession
              .builder()
              .config("temporaryGcsBucket", my_bucket)
              .appName("isssue_115574")
              .getOrCreate()
        }
    
      // create DF with some data
      val someData = Seq(
        Row("""{"name":"name1", "age": 10 }""", "id1"),
        Row("""{"name":"name2", "age": 20 }""", "id2")
      )
      val schema = StructType(
        Seq(
          StructField("user_age", StringType, true),
          StructField("id", StringType, true)
        )
      )
    
      val avroFileName = s"gs://${my_bucket}/issue_115574/someData.avro"
      
      val someDF = spark.createDataFrame(spark.sparkContext.parallelize(someData), schema)
      someDF.write.format("avro").mode("overwrite").save(avroFileName)
    
      val avroDF = spark.read.format("avro").load(avroFileName)
      // set metadata
      val dfJSON = avroDF
        .withColumn("user_age_no_metadata", col("user_age"))
        .withMetadata("user_age", Metadata.fromJson("""{"sqlType":"JSON"}"""))
    
      dfJSON.show()
      dfJSON.printSchema
    
      // write to BigQuery
      dfJSON.write.format("bigquery")
        .mode(SaveMode.Overwrite)
        .option("writeMethod", "indirect")
        .option("intermediateFormat", "avro")
        .option("useAvroLogicalTypes", "true")
        .option("table", my_table)
        .save()
    
    
    

    repro.sh:

    #!/bin/bash
    
    PROJECT_ID=set-yours-here
    DATASET_NAME=dataset
    TABLE_NAME=testavro2
    
    # We have to remove all of the existing spark bigquery jars from the local
    # filesystem, as we will be using the symbols from the
    # spark-3.3-bigquery-0.30.0.jar below.  Having existing jar files on the
    # local filesystem will result in those symbols having higher precedence
    # than the one loaded with the spark-shell.
    sudo find /usr -name 'spark*bigquery*jar' -delete
    
    # Remove the table from the bigquery dataset if it exists
    bq rm -f -t $PROJECT_ID:$DATASET_NAME.$TABLE_NAME
    
    # Create the table with a JSON type column
    bq mk --table $PROJECT_ID:$DATASET_NAME.$TABLE_NAME \
      user_age:JSON,id:STRING,user_age_no_metadata:STRING
    
    # Load the example Main.scala 
    spark-shell -i Main.scala \
      --jars /usr/lib/spark/external/spark-avro.jar,gs://spark-lib/bigquery/spark-3.3-bigquery-0.30.0.jar
    
    # Show the table schema when we use `bq mk --table` and then load the avro
    bq query --use_legacy_sql=false \
      "SELECT ddl FROM $DATASET_NAME.INFORMATION_SCHEMA.TABLES where table_name='$TABLE_NAME'"
    
    # Remove the table so that we can see that the table is created should it not exist
    bq rm -f -t $PROJECT_ID:$DATASET_NAME.$TABLE_NAME
    
    # Dynamically generate a DataFrame, store it to avro, load that avro,
    # and write the avro to BigQuery, creating the table if it does not already exist
    
    spark-shell -i Main.scala \
      --jars /usr/lib/spark/external/spark-avro.jar,gs://spark-lib/bigquery/spark-3.3-bigquery-0.30.0.jar
    
    # Show that the table schema does not differ from one created with a bq mk --table
    bq query --use_legacy_sql=false \
      "SELECT ddl FROM $DATASET_NAME.INFORMATION_SCHEMA.TABLES where table_name='$TABLE_NAME'"
    

    Google BigQuery has supported JSON data since October of 2022, but until now, it has not been possible, on generally available Dataproc clusters, to interact with these columns using the Spark BigQuery Connector.

    JSON column type support was introduced in spark-bigquery-connector release 0.28.0.

  • Instructions for installing Proxmox onto the Qotom device

    These instructions are for qotom devices Q515P and Q1075GE. You can order one from Amazon or directly from Cherry Ni <export03@qotom.com>. Instructions are for those coming from Windows.

    Prerequisites:

    • A USB keyboard and mouse
    • A powered HDMI monitor and an HDMI cable
    • A copy of the Proxmox VE Installer ISO
    • A USB disk from which to boot the installer
    • Software and instructions to burn the raw image to USB
    • The details of your wireless network including wireless network ID (SSID), WPA password, gateway address and network prefix length

    To find your windows network details, run the following command at the command prompt:

    netsh interface ip show addresses

    Here’s my output:

    PS C:\Users\cjcol> netsh interface ip show addresses "Wi-Fi"
    
    Configuration for interface "Wi-Fi"
        DHCP enabled:                         Yes
        IP Address:                           172.16.79.53
        Subnet Prefix:                        172.16.79.0/24 (mask 255.255.255.0)
        Default Gateway:                      172.16.79.1
        Gateway Metric:                       0
        InterfaceMetric:                      50
    

    Did you follow the instructions linked above in the “prerequisites” section? If not, take a moment to do so now.
    Open Rufus and select the proxmox iso which you downloaded.

    You may be warned that Rufus will be acting as dd.

    Don’t forget to select the USB drive that you want to write the image to. In my example, the device is creatively called “NO_LABEL”.

    You may be warned that re-imaging the USB disk will result in the previous data on the USB disk being lost.

    Once the process is complete, the application will indicate that it is complete.

    You should now have a USB disk with the Proxmox installer image on it. Place the USB disk into one of the blue, USB-3.0, USB-A slots on the Qotom device so that the system can read the installer image from it at full speed. The Proxmox installer requires a keyboard, video and mouse. Please attach these to the device along with inserting the USB disk you just created.

    Press the power button on the Qotom device. Press the F11 key repeatedly until you see the AMI BIOS menu. Press F11 a couple more times. You’ll be presented with a boot menu. One of the options will launch the Proxmox installer. By trial and error, I found that the correct boot menu option was “UEFI OS”

    Once you select the correct option, you will be presented with a menu that looks like this. Select the default option and install.

    During the install, you will be presented with an option of the block device to install to. I think there’s only a single block device in this celeron, but if there are more than one, I prefer the smaller one for the ProxMox OS. I also make a point to limit the size of the root filesystem to 16G. I think it will take up the entire volume group if you don’t set a limit.

    Okay, I’ll do another install and select the correct filesystem.

    If you read this far and want me to add some more screenshots and better instructions, leave a comment.