{"id":18363960,"url":"https://github.com/tritondatacenter/mi-debian-hvm","last_synced_at":"2025-04-06T15:32:00.580Z","repository":{"id":15225866,"uuid":"17954505","full_name":"TritonDataCenter/mi-debian-hvm","owner":"TritonDataCenter","description":"Repo to create the machine image for debian images in the Joyent Cloud","archived":false,"fork":false,"pushed_at":"2022-02-28T18:51:24.000Z","size":192,"stargazers_count":3,"open_issues_count":3,"forks_count":7,"subscribers_count":41,"default_branch":"master","last_synced_at":"2025-03-22T02:41:28.758Z","etag":null,"topics":["debian"],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TritonDataCenter.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-03-20T18:52:05.000Z","updated_at":"2022-12-09T20:40:30.000Z","dependencies_parsed_at":"2022-09-12T06:11:42.842Z","dependency_job_id":null,"html_url":"https://github.com/TritonDataCenter/mi-debian-hvm","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TritonDataCenter%2Fmi-debian-hvm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TritonDataCenter%2Fmi-debian-hvm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TritonDataCenter%2Fmi-debian-hvm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TritonDataCenter%2Fmi-debian-hvm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TritonDataCenter","download_url":"https://codeload.github.com/TritonDataCenter/mi-debian-hvm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247502936,"owners_count":20949355,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["debian"],"created_at":"2024-11-05T23:08:45.030Z","updated_at":"2025-04-06T15:32:00.321Z","avatar_url":"https://github.com/TritonDataCenter.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!--\n    This Source Code Form is subject to the terms of the Mozilla Public\n    License, v. 2.0. If a copy of the MPL was not distributed with this\n    file, You can obtain one at http://mozilla.org/MPL/2.0/.\n--\u003e\n\n\u003c!--\n    Copyright 2020 Joyent, Inc.\n--\u003e\n\n# Debian Image Builder\n\nThis repo allows one to create custom Debian images for use with Triton.\nOther [repositories](https://github.com/joyent?q=mi--hvm) provide equivalent\nfunctionality for other distribution types.\n\n## Requirements\n\nIn order to use this repo, you need to have a SmartOS \"joyent\" brand zone that\nis capable of running qemu.  In order to run qemu the instance needs\ncustomization beyond what can be done with Triton APIs.  That is, an operator\nneeds to customize the instance.  This is typically accomplished by running the\nfollowing commands on the appropriate compute node:\n\n```\nuuid=XXX\t# Change this to the instance uuid\n\ntopds=zones/$uuid/data\nzfs create -o zoned=on -o mountpoint=/data $topds\n\nzonecfg -z $uuid \u003c\u003cEOF\nadd dataset\nset name=$topds\nend\nadd fs\nset dir=/smartdc\nset special=/smartdc\nset type=lofs\nset options=ro\nend\nadd device\nset match=kvm\nend\nEOF\n```\n\n## Setup\n\nThis relies on the sdc-vmtools repo as a submodule.  You can get the right\nversion of that with:\n\n```\ngit submodules update --init\n```\n\nIf you forget to do that, `create-image` will do it before it tries to use\nanything from that submodule.\n\n## Using\n\nTo generate a Debian `\u003cversion\u003e` image run:\n\n```\n# ./create-image -r \u003cversion\u003e\n```\n\n\n```\n$ ./create-image -h\nUsage:\n        ./create-image [options] [command ...]\noption:\n        -h          This message\n        -r          Distro release\n\nCommands:\n        fetch       Fetch the installation ISO\n        iso         Create a kickstart ISO\n        image       Generate the image\n```\n\n### fetch\n\nDownload the distribution's netinst media (.iso) and verify its integrity.\nIf the required ISO already exists, its integrity is verified.  If it is found\nto be corrupt it is fetched again.\n\nThis image will be automatically mounted at `/cdrom` during installation.\n\n### iso\n\nGenerate an installer ISO image.  This will contain the following:\n\n* `preseed.cfg` - From `debian-\u003crelease\u003e/preseed.cfg`.\n* `sdc-vmtools` - The current content of the\n  [sdc-vmtools](https://github.com/joyent/sdc-vmtools) repo.\n* `early-command` - A preinstallation script, from\n  `debian-\u003crelease\u003e/early-command`\n* `late-command` - A postinstallation script, from\n  `debian-\u003crelease\u003e/late-command`\n\nThis image is automatically mounted when the debian installer needs it, but is\nnot automatically mounted in the chroot (`/target`) while `late-command` is\nrunning.  For that reason, each release's late command needs to mount it at\n`/target/cdrom` prior to running `late-command`.\n\n\n### image\n\nThis runs qemu in a way that allows unattended installation using the media\ndescribed above.  Once qemu exits, a Triton-compatible\nimage is generated and stored in the current `bits/\u003cstamp\u003e` directory as\n`debian-\u003crelease\u003e-\u003ctimestamp\u003e.{json,tar.gz}`.\n\nThe actual image creation is handled by `sdc-vmutils/bin/create-hybrid-image`.\n\n\n### upload\n\nThis invokes\n[bits-upload.sh](https://github.com/joyent/eng/blob/master/tools/bits-upload.sh)\nto upload the image to manta and updates.joyent.com.\n\n\n## Default Settings For Images\n\nEach image has the following characteristics.  See\n`debian-\u003crelease\u003e/preseed.cfg` for details on which packages are included.\n\n* Disk is 10GB in size (8GB for / and the rest for swap)\n* Stock Kernel\n* US Keyboard and Language\n* Firewall enabled with SSH allowed\n* Timezone is set to UTC\n* Console is on ttyS0\n* Root password is blank: console login is allowed without a password\n* Configuration from the SmartOS metadata service is performed using cloud-init.\n\n## Development\n\nThe following serves as a guide for adding support for new Debian-like\ndistributions and versions of existing distributions.\n\nDistribution-specific content is found in a per-distro subdirectory.  For\nexample, Debian 10 bits are in the `debian-10` directory.  Directory names are\nalways lower-case.\n\nThe following subsections describe the content that may be in a per-distro\ndirectory.\n\n### preseed.cfg file\n\nThe [preseed](https://wiki.debian.org/DebianInstaller/Preseed) configuration\nfile.  Notable parts of this include:\n\n* `cloud-init` is installed, as it is responsible for interacting with the\n  host's metadata service to configure networking, run user scripts, etc.  It\n  requires `pyserial`, but for \"reasons\" the cloud-init developers have avoided\n  adding pyserial as a dependency.\n* `cloud-init` requires configuration in\n  `/etc/cloud/cloud.cfg.d/90\\_smartos.cfg` to only enable the SmartOS\n  datasource, among other things.\n* A `preseed/early\\_command` (`debian-\u003crelease\u003e/early-command`) is used to tail\n  the installation log and write it to `/dev/ttyS0`.  This script is run under\n  busybox, so avoid the use of anything too fancy.  `qemu` runs in such a way\n  that the guest's `ttyS0` appears on `qemu`'s `stdout`, thus allowing the\n  installation log to be captured by Jenkins or similar automation that may be\n  creating an image.\n* A `preseed/late\\_command` (`debian-\u003crelease\u003e/late-command`) runs at the end of\n  the installation to perform the final tweaks on the image.  It runs chroot'd\n  in the installed image.\n\nThe early and late command scripts need to communicate their successful\nexecution to `build-image`.  To do this, they need to emit\n`JOYENT_STATUS_PRE=ok` (for early command) and `JOYENT_STATUS_POST=ok` (for late\ncommand) to `/dev/ttyS0`.  `build-image` looks for these markers at the\nbeginning of a line.  The typical way to emit these markers is by adding the\nfollowing to the beginning of the script:\n\n```\n#! /bin/bash\n\njoyent_status=fail\ntrap '(echo \"\"; echo JOYENT_STATUS_POST=$joyent_status; echo \"\") \u003e\u003e/dev/ttyS0' \\\n    EXIT\n\nset -ex\n```\n\nand end with:\n\n```\nset +x\njoyent_status=ok\n```\n\n`create-image` will verify that all `JOYENT_STATUS_\u003cfoo\u003e` tags are set to `ok`,\nwhich only happens if the script in that section runs to completion.\n\n### keys directory\n\nEach GPG key found in the keys directory will be imported into the keyring of\nthe user running this command.  These keys are used for authenticating the media\nthat is downloaded by the `fetch` command.\n\n### create-image-overrides.sh\n\nIf the distribution requires overrides of any functionality, it should be added\nhere.  This file is sourced by `create-image` just before processing commands.\nIn general, the global variables that are all-uppercase are good candidates for\nbeing overridden.\n\nThis file does not exist if not needed.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftritondatacenter%2Fmi-debian-hvm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftritondatacenter%2Fmi-debian-hvm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftritondatacenter%2Fmi-debian-hvm/lists"}