### SmartOS Configuration Example Source: https://github.com/tritondatacenter/smartos-docs/blob/master/docs/extra-configuration-options.md A comprehensive example of a /usbkey/config file, demonstrating how to configure a single NIC for both admin and external traffic with NAT enabled. ```bash # # This file was auto-generated and must be source-able by bash. # # admin_nic is the nic admin_ip will be connected to for headnode zones. admin_nic=aa:bb:cc:dd:ee:ff admin_ip=10.0.0.1 admin_netmask=255.255.0.0 admin_network=... admin_gateway=10.0.0.1 external_nic=aa:bb:cc:dd:ee:ff external0_ip=192.168.1.240 external0_netmask=255.255.255.0 external0_gateway=192.168.1.1 coal=true headnode_default_gateway=192.168.1.1 dns_resolvers=8.8.8.8,8.8.4.4 dns_domain=example.com ntp_hosts=pool.ntp.org compute_node_ntp_hosts=192.168.1.240 default_keymap=us ``` -------------------------------- ### Configure iPXE Boot Module for answers.json Source: https://github.com/tritondatacenter/smartos-docs/blob/master/docs/non-interactive-install.md This iPXE script demonstrates how to load the answers.json file and its optional SHA1 hash file over HTTP. This is useful for network-based installations. For HTTPS, ensure your iPXE binary has TLS support compiled in. ```ipxe module http://netboot.example.com/my/answers.json type=file name=answers.json module http://netboot.example.com/my/answers.json.hash type=file name=answers.json.hash ``` -------------------------------- ### Get Instance Details and Properties with vmadm Source: https://context7.com/tritondatacenter/smartos-docs/llms.txt This snippet shows how to retrieve detailed information about a specific instance using `vmadm get`. It demonstrates fetching the full JSON properties and extracting specific fields, such as network interface details, using the `json` tool for further processing. ```bash # Get full JSON properties of an instance vmadm get d6a0a022-3855-4762-a2e5-3f16969ca2fb # Get specific property using json tool vmadm get d6a0a022-3855-4762-a2e5-3f16969ca2fb | json nics ``` -------------------------------- ### Manage software packages Source: https://github.com/tritondatacenter/smartos-docs/blob/master/docs/the-linux-to-smartos-cheat-sheet.md Tools for listing and installing software packages across different operating systems. ```linux yum install pkg apt-get install pkg ``` ```smartos pkgin list pkgin install pkg ``` -------------------------------- ### Import Custom Image Locally (SmartOS) Source: https://context7.com/tritondatacenter/smartos-docs/llms.txt Installs a custom SmartOS image locally using its manifest and data files. The `-m` flag specifies the manifest, and `-f` specifies the image data file. ```bash # Import custom image locally imgadm install -m myimage.dsmanifest -f myimage.zfs.gz ``` -------------------------------- ### SmartOS Image File Structure Example Source: https://github.com/tritondatacenter/smartos-docs/blob/master/docs/managing-images.md This example shows the typical file structure for a SmartOS image, consisting of a `.dsmanifest` file containing metadata and a `.zfs.bz2` file containing the compressed ZFS dataset. These files are used to create new VMs. ```bash benr@magnolia:~/datasets$ ls -lh total 41M -rw-rw-r-- 1 benr benr 996 Sep 10 14:54 smartos-1.3.12.dsmanifest -rw-rw-r-- 1 benr benr 41M Jun 10 2011 smartos-1.3.12.zfs.bz2 ``` -------------------------------- ### Package Management with pkgin Source: https://context7.com/tritondatacenter/smartos-docs/llms.txt Manages software packages in SmartOS zones using the pkgsrc framework. Installs software under /opt/local. Requires root privileges for most operations. ```bash # Update package database (run before installing) pkgin update # List available packages pkgin av # Search for a package pkgin se nginx # nginx-1.19.0 Lightweight HTTP server and IMAP/POP3 proxy server # Install a package pkgin in nginx # Install multiple packages pkgin in nginx postgresql15-server redis # List installed packages pkgin ls # Remove a package pkgin rm nginx # Upgrade all packages pkgin upgrade # Show package info pkgin info nginx # List all pkgin commands pkgin # Commands: # update - update package database # avail - list available packages # list - list installed packages # install - install packages # remove - remove packages # search - search for packages ``` -------------------------------- ### Install Puppet via pkgin Source: https://github.com/tritondatacenter/smartos-docs/blob/master/docs/using-puppet.md Installs the Puppet configuration management software on SmartOS using the pkgin package manager. This command automatically resolves and installs required dependencies such as Ruby and Facter. ```shell # pkgin in ruby19-puppet ``` -------------------------------- ### Connect to VM Console Source: https://context7.com/tritondatacenter/smartos-docs/llms.txt This command allows direct access to the console of a running virtual machine, which is useful for initial setup, troubleshooting, or interactive use. It requires the VM's UUID. ```bash vmadm console a1b2c3d4-5678-90ab-cdef-1234567890ab ``` -------------------------------- ### Instance Metadata Management (Guest) Source: https://context7.com/tritondatacenter/smartos-docs/llms.txt Manages instance metadata from within the guest OS using 'mdata-*' commands. Allows listing, getting, putting (storing custom data), and deleting metadata keys. Useful for configuration injection and host-guest communication. ```bash # Inside an instance - list available metadata keys mdata-list # Retrieve metadata value mdata-get root_authorized_keys # Store custom metadata (accessible from hypervisor) mdata-put myapp-config '{"debug": true, "port": 8080}' # Delete metadata key mdata-delete myapp-config ``` -------------------------------- ### Instance Metadata Retrieval (Hypervisor) Source: https://context7.com/tritondatacenter/smartos-docs/llms.txt Retrieves instance metadata from the hypervisor using the 'vmadm get' command combined with 'json' to parse the customer_metadata. This allows inspecting metadata set by or for the instance. ```bash vmadm get d6a0a022-3855-4762-a2e5-3f16969ca2fb | json customer_metadata ``` -------------------------------- ### List ZFS Datasets Source: https://github.com/tritondatacenter/smartos-docs/blob/master/docs/configuring-nfs-in-smartos.md Lists ZFS datasets recursively, starting from the 'zones' pool. This command is used to check available space and understand the storage layout before setting up NFS shares. ```bash /usr/sbin/zfs list -r zones ``` -------------------------------- ### Example of cloud-init:user-data Metadata Source: https://github.com/tritondatacenter/smartos-docs/blob/master/docs/customer_metadata.md Demonstrates how to provide cloud-config data for instances supporting cloud-init. The value for the `cloud-init:user-data` key is a JSON stringified YAML document, typically used for initial instance configuration. ```json { "customer_metadata": { "cloud-init:user-data": "#cloud-config\npackage_update: true\npackage_upgrade: true\n" } } ``` -------------------------------- ### Create Chef Configuration Directory and Copy Files Source: https://github.com/tritondatacenter/smartos-docs/blob/master/docs/using-chef.md This snippet demonstrates the initial setup for Chef Knife configuration. It involves creating a dedicated directory for Chef configuration files and copying essential configuration and key files into it. Ensure you have downloaded 'knife.rb' and possess the necessary '.pem' key files. ```bash benr@magnolia:~$ mkdir ~/.chef benr@magnolia:~$ cp ~/Downloads/knife.rb ~/.chef/ benr@magnolia:~$ cp Downloads/*.pem ~/.chef ``` -------------------------------- ### Retrieve Service Property (Shell) Source: https://github.com/tritondatacenter/smartos-docs/blob/master/docs/basic-smf-commands.md Retrieves a specific property of a service using the 'svcprop' command. This example shows how to get the custom policy file path for the 'network/ipfilter' service. ```shell # svcprop -p firewall_config_default/custom_policy_file network/ipfilter :default /etc/ipf/ipf.conf ``` -------------------------------- ### Create Bhyve VM with Cloud-Init Source: https://context7.com/tritondatacenter/smartos-docs/llms.txt This snippet shows how to create a Bhyve VM and pass cloud-init configuration data directly within the `customer_metadata`. This enables automated setup of the VM upon its first boot, including user creation, sudo privileges, and SSH key injection. ```bash cat > /tmp/cloud-vm.json << 'EOF' { "brand": "bhyve", "alias": "cloud01", "ram": 1024, "vcpus": 1, "nics": [{"nic_tag": "admin", "ip": "dhcp", "model": "virtio", "primary": true}], "disks": [{"image_uuid": "3162a91e-8b5d-11e2-a78f-9780813f9142", "boot": true, "model": "virtio"}], "customer_metadata": { "cloud-init:user-data": "#cloud-config\n\nusers:\n - default\n - name: admin\n sudo: \"ALL=(ALL) NOPASSWD:ALL\"\n shell: /bin/bash\n ssh_authorized_keys:\n - ssh-rsa AAAAB3Nza... user@host" } } EOF vmadm create -f /tmp/cloud-vm.json ``` -------------------------------- ### Pass Cloud-Init Data to SmartOS VM Source: https://github.com/tritondatacenter/smartos-docs/blob/master/docs/how-to-create-an-hvm-zone.md Injects cloud-init data into a SmartOS zone/VM for automated setup tasks like user creation and package installation. The cloud-init data, typically in YAML format, needs to be properly escaped within the JSON zone definition. ```json "customer_metadata": { "cloud-init:user-data": "#cloud-config\n\nusers:\n - default\n - name: shaner\n ssh_import_id: shaner\n lock_passwd: false\n sudo: \"ALL=(ALL) NOPASSWD:ALL\"\n shell: /bin/bash" } ``` -------------------------------- ### Create Bhyve VM Manifest and Instance Source: https://context7.com/tritondatacenter/smartos-docs/llms.txt This snippet demonstrates how to define a Bhyve virtual machine's configuration in a JSON manifest and then create the VM using the `vmadm create` command. It includes network, disk, and customer metadata configurations, such as SSH keys for initial setup. For KVM, the 'brand' should be set to 'kvm'. ```bash cat > /tmp/linux01.json << 'EOF' { "brand": "bhyve", "alias": "linux01", "ram": 2048, "vcpus": 2, "resolvers": ["8.8.8.8", "8.8.4.4"], "nics": [ { "nic_tag": "admin", "ip": "10.0.0.20", "netmask": "255.255.255.0", "gateway": "10.0.0.1", "model": "virtio", "primary": true } ], "disks": [ { "image_uuid": "3162a91e-8b5d-11e2-a78f-9780813f9142", "boot": true, "model": "virtio" }, { "model": "virtio", "size": 51200 } ], "customer_metadata": { "root_authorized_keys": "ssh-rsa AAAAB3Nza... user@host" } } EOF vmadm create -f /tmp/linux01.json ``` -------------------------------- ### SmartOS Non-interactive Install Configuration (JSON) Source: https://github.com/tritondatacenter/smartos-docs/blob/master/docs/non-interactive-install.md This JSON file defines the parameters for a non-interactive SmartOS installation. It includes network configuration, DNS settings, NTP server, storage pool layout, and hostname. Ensure the file is valid JSON; otherwise, it will be ignored. ```json { "config_console": true, "skip_instructions": true, "simple_headers": true, "admin_mac": "52:54:00:2f:61:34", "admin_ip": "dhcp", "headnode_default_gateway": "none", "dns_resolver1": "8.8.8.8", "dns_resolver2": "8.8.4.4", "dns_search": "example.com", "ntp_host": "0.smartos.pool.ntp.org", "skip_ntp_check": true, "zpool_layout": "default", "zpool_confirm_layout": "yes", "bootpool": "none", "install_pkgsrc": "no", "root_password": "secret", "hostname": "brainiac", "skip_final_confirm": true } ``` -------------------------------- ### Add Custom Scripts at Boot (SmartOS) Source: https://context7.com/tritondatacenter/smartos-docs/llms.txt Allows the execution of custom scripts during the boot process. Scripts should be placed in `/opt/custom/bin`, and those in `/opt/custom/share/svc/svc-boot` will run automatically. ```bash # Custom scripts at boot mkdir -p /opt/custom/bin # Scripts in /opt/custom/share/svc/svc-boot will run at boot ``` -------------------------------- ### Manage LX Branded Zones (Linux Containers) Source: https://context7.com/tritondatacenter/smartos-docs/llms.txt This section details the process of deploying LX branded zones, which run Linux userland on the illumos kernel. It includes commands to list available LX images, import a specific image, define the zone's configuration in a JSON manifest, create the zone using `vmadm`, and log into the zone using `zlogin`. ```bash # List available LX images imgadm avail type=lx-dataset # Import Debian LX image imgadm import 7b5981c4-1889-11e7-b4c5-3f3bdfc9b6bb # Create LX zone manifest: /tmp/debian-lx.json cat > /tmp/debian-lx.json << 'EOF' { "brand": "lx", "image_uuid": "7b5981c4-1889-11e7-b4c5-3f3bdfc9b6bb", "alias": "debian01", "hostname": "debian01", "kernel_version": "4.3.0", "max_physical_memory": 1024, "quota": 25, "resolvers": ["8.8.8.8"], "nics": [ { "nic_tag": "admin", "ip": "10.0.0.30", "netmask": "255.255.255.0", "gateway": "10.0.0.1", "primary": true } ] } EOF # Create the LX zone vmadm create -f /tmp/debian-lx.json # Log into the LX zone (spawns shell as root) zlogin b2c3d4e5-6789-01ab-cdef-234567890abc ``` -------------------------------- ### Provision and Manage SmartOS Virtual Machines Source: https://github.com/tritondatacenter/smartos-docs/blob/master/docs/how-to-create-a-virtual-machine-from-scratch.md Shell commands for creating a virtual machine from a JSON specification and preparing the environment by placing an ISO image into the zone's root directory. ```bash # Create the VM vmadm create < vmspec.json # Prepare ISO in the zone root cd /zones/b8ab5fc1-8576-45ef-bb51-9826b52a4651/root/ curl -O http://mirrors.debian.com/path_to_an_iso/debian.iso ``` -------------------------------- ### Get SHA1 Hash of Image File (SmartOS) Source: https://context7.com/tritondatacenter/smartos-docs/llms.txt Calculates the SHA1 hash of the compressed image file. This hash is used in the image manifest for integrity verification. ```bash # Get SHA1 hash for manifest digest -a sha1 myimage.zfs.gz ``` -------------------------------- ### Implement SMF Method Script Source: https://github.com/tritondatacenter/smartos-docs/blob/master/docs/administering-the-global-zone.md A Bash script used as the execution method for an SMF service. It handles start and stop signals and includes standard SMF environment configurations. ```bash #!/bin/bash # Simple Ad Hoc SmartOS Setup Service set -o xtrace . /lib/svc/share/smf_include.sh cd / PATH=/usr/sbin:/usr/bin:/opt/custom/bin:/opt/custom/sbin; export PATH case "$1" in 'start') #### Insert code to execute on startup here. hostname "smartos01" && hostname > /etc/nodename ;; 'stop') ### Insert code to execute on shutdown here. ;; *) echo "Usage: $0 { start | stop }" exit $SMF_EXIT_ERR_FATAL ;; esac exit $SMF_EXIT_OK ``` -------------------------------- ### Lookup instances with vmadm Source: https://github.com/tritondatacenter/smartos-docs/blob/master/docs/managing-instances-with-vmamd.md Demonstrates how to search for instances using specific keys, pattern matching, and combined filters. It also shows how to output results in JSON format for detailed inspection. ```bash # Lookup by alias pattern vmadm lookup alias=~zone7 # Lookup and return full JSON vmadm lookup -j alias=~zone7 # Combine filters (RAM and alias pattern) vmadm lookup ram=128 alias=~^[ab] ``` -------------------------------- ### Boot VM from ISO using vmadm Source: https://github.com/tritondatacenter/smartos-docs/blob/master/docs/resizing-linux-vm-disks.md Commands to boot a specific virtual machine from a CD-ROM image and retrieve VNC connection details for GUI access. ```bash # Start VM with CD-ROM boot order vmadm start 708c73e3-48f2-4da5-a0a6-e161215a4215 order=cd,once=d cdrom=/gparted-live-0.12.1-1.iso,ide # Get VNC connection information vmadm info 708c73e3-48f2-4da5-a0a6-e161215a4215 vnc ``` -------------------------------- ### Enable and Verify Service (Shell) Source: https://github.com/tritondatacenter/smartos-docs/blob/master/docs/basic-smf-commands.md Enables a service using 'svcadm enable service_name' and then verifies its status with 'svcs -a | grep service_name'. A successfully enabled service will show an 'online' state. ```shell # Enable the service: svcadm enable service_name # Verify the service is enabled: svcs -a | grep service_name # Example output for an online service: # online 18:50:25 svc:/network/webmin:webmin ``` -------------------------------- ### Export and Compress Zone Dataset (SmartOS) Source: https://context7.com/tritondatacenter/smartos-docs/llms.txt Exports a ZFS snapshot of a zone's dataset and compresses it using gzip. The output is a `.zfs.gz` file, suitable for distribution. ```bash # Export and compress zfs send zones/d6a0a022-3855-4762-a2e5-3f16969ca2fb@image | gzip > myimage.zfs.gz ``` -------------------------------- ### View System Configuration (SmartOS) Source: https://context7.com/tritondatacenter/smartos-docs/llms.txt Displays the system's persistent configuration, including network settings and DNS resolvers. This information is typically found in `/usbkey/config`. ```bash # View system configuration cat /usbkey/config # admin_nic=00:53:00:ca:b1:e5 # admin_ip=10.0.0.1 # admin_netmask=255.255.255.0 # admin_gateway=10.0.0.254 # dns_resolvers=8.8.8.8,8.8.4.4 # dns_domain=example.com ``` -------------------------------- ### Manage VM Images with imgadm Source: https://github.com/tritondatacenter/smartos-docs/blob/master/docs/how-to-create-an-hvm-zone.md Commands to list available remote images, view locally installed images, and import specific VM images into the SmartOS host. ```shell imgadm avail type=zvol imgadm list imgadm import UUID ``` -------------------------------- ### Configure NICs in instance payload Source: https://github.com/tritondatacenter/smartos-docs/blob/master/docs/managing-nics.md Example JSON configuration for defining network interfaces within an instance creation payload, specifying nic_tags, IP addresses, and VLAN IDs. ```json "nics": [ { "nic_tag": "external", "ip": "198.51.100.21", "netmask": "255.255.255.0", "gateway": "198.51.100.1", "primary": true, "vlan_id": 128 }, { "nic_tag": "internal", "ip": "192.0.2.21", "netmask": "255.255.255.0", "gateway": "192.0.2.1", "vlan_id": 200 } ] ``` -------------------------------- ### Configure runtime linking Source: https://github.com/tritondatacenter/smartos-docs/blob/master/docs/the-linux-to-smartos-cheat-sheet.md Utilities to inspect and configure how dynamic libraries are loaded at runtime. ```linux ldconfig ldd binary ``` ```solaris crle ldd binary elfdump binary ``` -------------------------------- ### Prepare Zone for Imaging (SmartOS) Source: https://context7.com/tritondatacenter/smartos-docs/llms.txt Prepares a SmartOS zone for the imaging process. This command is executed from within the zone itself. ```bash # Prepare a zone for imaging (inside the zone) sm-prepare-image ``` -------------------------------- ### SMF Manifest for persist-syscfg Source: https://github.com/tritondatacenter/smartos-docs/blob/master/docs/persistent-users-and-rbac-in-the-global-zone.md The XML manifest defining the site/persist-syscfg service, which manages the persistence of system configuration files by executing a sync script on start and stop. ```xml ``` -------------------------------- ### Configure NIC in global zone Source: https://github.com/tritondatacenter/smartos-docs/blob/master/docs/managing-nics.md Example configuration for a storage nic_tag in the SmartOS node config file. It defines the physical NIC mapping, IP address, netmask, gateway, and VLAN ID. ```text storage_nic=00:53:00:ca:b1:e5 storage0_ip=198.51.100.7 storage0_netmask=255.255.255.0 storage0_gateway=198.51.100.1 storage0_vlan_id=128 ``` -------------------------------- ### Create Cores Dataset for Instance Migration Source: https://github.com/tritondatacenter/smartos-docs/blob/master/docs/managing-instances-with-vmamd.md Creates the `cores` dataset required for instance migration, specifying quota and compression options. This command uses `zfs create` and is essential before booting a migrated zone on the destination compute node. ```bash zfs create -o quota=1000m -o compression=gzip -o mountpoint=/zones/:zone_uuid/cores zones/cores/:zone_uuid ``` -------------------------------- ### Example of root_authorized_keys Metadata Source: https://github.com/tritondatacenter/smartos-docs/blob/master/docs/customer_metadata.md Illustrates the format for the `root_authorized_keys` metadata key. The value should be a string containing linefeed-separated SSH public keys, compatible with OpenSSH's authorized_keys file format. ```json { "customer_metadata": { "root_authorized_keys": "ecdsa-sha2-nistp256 ... \nssh-rsa ...\n" } } ``` -------------------------------- ### Control Instance Lifecycle with vmadm Source: https://context7.com/tritondatacenter/smartos-docs/llms.txt This section covers essential instance management operations using `vmadm`, including stopping, starting, rebooting, and deleting instances. Deleting an instance is a permanent action that destroys all associated data. ```bash # Stop an instance vmadm stop d6a0a022-3855-4762-a2e5-3f16969ca2fb # Start an instance vmadm start d6a0a022-3855-4762-a2e5-3f16969ca2fb # Reboot an instance vmadm reboot d6a0a022-3855-4762-a2e5-3f16969ca2fb # Delete an instance (permanently destroys all data) vmadm delete d6a0a022-3855-4762-a2e5-3f16969ca2fb ```