[{"data":1,"prerenderedAt":1412},["ShallowReactive",2],{"docs-\u002Fdocs\u002Fapplications\u002Fvms":3},{"id":4,"title":5,"body":6,"description":1405,"extension":1406,"meta":1407,"navigation":241,"path":1408,"seo":1409,"stem":1410,"__hash__":1411},"docs\u002Fdocs\u002Fapplications\u002Fvms.md","Launch a VM",{"type":7,"value":8,"toc":1395},"minimark",[9,13,22,25,43,48,108,111,115,134,144,170,452,455,483,496,500,832,835,876,880,927,947,990,994,1032,1038,1042,1050,1076,1079,1120,1139,1210,1220,1236,1240,1245,1266,1269,1295,1299,1307,1329,1332,1350,1361,1391],[10,11,5],"h1",{"id":12},"launch-a-vm",[14,15,16,17,21],"p",{},"Every application group runs as containers unless you say otherwise. Add ",[18,19,20],"code",{},"type: vm"," and the same group runs as full virtual machines on the same cluster. This walkthrough builds a VM image, deploys two VMs with a bigger root disk and a data volume, and gets a shell in one. About thirty minutes, most of it image building.",[14,23,24],{},"There is no separate \"launch a VM\" command. A VM is always an instance in an application group, so it gets the same plan, confirmation, health check, generations and destroy as everything else.",[14,26,27,28,31,32,37,38,42],{},"You'll need the ",[18,29,30],{},"lab"," cluster from ",[33,34,36],"a",{"href":35},"\u002Fdocs\u002Fmachines\u002Fclusters","Form a cluster",". If you haven't deployed a container application yet, do ",[33,39,41],{"href":40},"\u002Fdocs\u002Fapplications\u002Ffirst-application","Launch your first application"," first; this page assumes it.",[44,45,47],"h2",{"id":46},"container-or-vm","Container or VM?",[49,50,51,64],"table",{},[52,53,54],"thead",{},[55,56,57,61],"tr",{},[58,59,60],"th",{},"Choose a container when",[58,62,63],{},"Choose a VM when",[65,66,67,76,84,92],"tbody",{},[55,68,69,73],{},[70,71,72],"td",{},"It's an ordinary service: a web app, a worker, a cache",[70,74,75],{},"It needs its own kernel: Docker or Kubernetes inside, kernel modules, a different kernel version",[55,77,78,81],{},[70,79,80],{},"You want fast starts (a second or two) and low overhead",[70,82,83],{},"You want a hardware boundary between it and the host, not just namespaces",[55,85,86,89],{},[70,87,88],{},"Many small instances per member",[70,90,91],{},"It needs a raw block device (a database, a filesystem you format yourself)",[55,93,94,96],{},[70,95],{},[70,97,98,99,102,103,107],{},"It runs PostgreSQL or ClickHouse through ",[18,100,101],{},"sg",": ",[33,104,106],{"href":105},"\u002Fdocs\u002Fapplications\u002Fdatabases","services"," always run in VMs",[14,109,110],{},"VMs cost more. Each one reserves its own memory, boots its own kernel and takes ten to twenty seconds to be ready.",[44,112,114],{"id":113},"_1-build-a-vm-image-10-minutes","1. Build a VM image (10 minutes)",[116,117,119],"note",{"kind":118},"warning",[14,120,121,125,126,129,130,133],{},[122,123,124],"strong",{},"An image built from a container can't boot as a VM."," LXD refuses with ",[18,127,128],{},"Error: Asked for a VM but image is of type container",". Build VM images from a VM, with ",[18,131,132],{},"--vm",".",[14,135,136,137,139,140,143],{},"The steps are the same as for a container, with three differences: ",[18,138,132],{}," on launch, a wait for the VM's agent, and ",[18,141,142],{},"cloud-init clean"," before publishing so every VM made from the image runs first-boot setup fresh.",[145,146,151],"pre",{"className":147,"code":148,"language":149,"meta":150,"style":150},"language-bash shiki shiki-themes github-dark-high-contrast","ssh root@203.0.113.10                 # any cluster member\n","bash","",[18,152,153],{"__ignoreMap":150},[154,155,158,162,166],"span",{"class":156,"line":157},"line",1,[154,159,161],{"class":160},"s_sBn","ssh",[154,163,165],{"class":164},"sTRMh"," root@203.0.113.10",[154,167,169],{"class":168},"sQrFR","                 # any cluster member\n",[145,171,173],{"className":147,"code":172,"language":149,"meta":150,"style":150},"cat > \u002Froot\u002Fhello.conf \u003C\u003C'EOF'\nserver {\n    listen 8080;\n    default_type text\u002Fplain;\n    location = \u002Fhealthz { return 200 \"ok\\n\"; }\n    location \u002F { return 200 \"hello from $hostname\\n\"; }\n}\nEOF\n\nlxc launch ubuntu:24.04 build-hello-vm --vm -c limits.cpu=2 -c limits.memory=2GiB\n\n# lxc exec into a VM needs the LXD agent, which starts a few seconds after boot.\nuntil lxc exec build-hello-vm -- true 2>\u002Fdev\u002Fnull; do sleep 3; done\nlxc exec build-hello-vm -- cloud-init status --wait\n\nlxc exec build-hello-vm -- sh -ec 'apt-get update -q && DEBIAN_FRONTEND=noninteractive apt-get install -y -q nginx'\nlxc file push \u002Froot\u002Fhello.conf build-hello-vm\u002Fetc\u002Fnginx\u002Fconf.d\u002Fhello.conf\nlxc exec build-hello-vm -- sh -ec 'rm -f \u002Fetc\u002Fnginx\u002Fsites-enabled\u002Fdefault && nginx -t && systemctl enable nginx && cloud-init clean --logs'\nlxc stop build-hello-vm\nlxc publish build-hello-vm --alias hello-vm-1\nlxc delete build-hello-vm\nexit\n",[18,174,175,194,200,206,212,218,224,230,236,243,276,281,287,330,350,355,375,391,409,420,436,446],{"__ignoreMap":150},[154,176,177,180,184,187,190],{"class":156,"line":157},[154,178,179],{"class":160},"cat",[154,181,183],{"class":182},"sWyjQ"," >",[154,185,186],{"class":164}," \u002Froot\u002Fhello.conf",[154,188,189],{"class":182}," \u003C\u003C",[154,191,193],{"class":192},"sMAXC","'EOF'\n",[154,195,197],{"class":156,"line":196},2,[154,198,199],{"class":164},"server {\n",[154,201,203],{"class":156,"line":202},3,[154,204,205],{"class":164},"    listen 8080;\n",[154,207,209],{"class":156,"line":208},4,[154,210,211],{"class":164},"    default_type text\u002Fplain;\n",[154,213,215],{"class":156,"line":214},5,[154,216,217],{"class":164},"    location = \u002Fhealthz { return 200 \"ok\\n\"; }\n",[154,219,221],{"class":156,"line":220},6,[154,222,223],{"class":164},"    location \u002F { return 200 \"hello from $hostname\\n\"; }\n",[154,225,227],{"class":156,"line":226},7,[154,228,229],{"class":164},"}\n",[154,231,233],{"class":156,"line":232},8,[154,234,235],{"class":192},"EOF\n",[154,237,239],{"class":156,"line":238},9,[154,240,242],{"emptyLinePlaceholder":241},true,"\n",[154,244,246,249,252,255,258,262,265,268,271,273],{"class":156,"line":245},10,[154,247,248],{"class":160},"lxc",[154,250,251],{"class":164}," launch",[154,253,254],{"class":164}," ubuntu:24.04",[154,256,257],{"class":164}," build-hello-vm",[154,259,261],{"class":260},"sCcAr"," --vm",[154,263,264],{"class":260}," -c",[154,266,267],{"class":164}," limits.cpu=",[154,269,270],{"class":260},"2",[154,272,264],{"class":260},[154,274,275],{"class":164}," limits.memory=2GiB\n",[154,277,279],{"class":156,"line":278},11,[154,280,242],{"emptyLinePlaceholder":241},[154,282,284],{"class":156,"line":283},12,[154,285,286],{"class":168},"# lxc exec into a VM needs the LXD agent, which starts a few seconds after boot.\n",[154,288,290,293,296,299,301,304,307,310,313,316,319,322,325,327],{"class":156,"line":289},13,[154,291,292],{"class":182},"until",[154,294,295],{"class":160}," lxc",[154,297,298],{"class":164}," exec",[154,300,257],{"class":164},[154,302,303],{"class":260}," --",[154,305,306],{"class":260}," true",[154,308,309],{"class":182}," 2>",[154,311,312],{"class":164},"\u002Fdev\u002Fnull",[154,314,315],{"class":192},"; ",[154,317,318],{"class":182},"do",[154,320,321],{"class":160}," sleep",[154,323,324],{"class":260}," 3",[154,326,315],{"class":192},[154,328,329],{"class":182},"done\n",[154,331,333,335,337,339,341,344,347],{"class":156,"line":332},14,[154,334,248],{"class":160},[154,336,298],{"class":164},[154,338,257],{"class":164},[154,340,303],{"class":260},[154,342,343],{"class":164}," cloud-init",[154,345,346],{"class":164}," status",[154,348,349],{"class":260}," --wait\n",[154,351,353],{"class":156,"line":352},15,[154,354,242],{"emptyLinePlaceholder":241},[154,356,358,360,362,364,366,369,372],{"class":156,"line":357},16,[154,359,248],{"class":160},[154,361,298],{"class":164},[154,363,257],{"class":164},[154,365,303],{"class":260},[154,367,368],{"class":164}," sh",[154,370,371],{"class":260}," -ec",[154,373,374],{"class":164}," 'apt-get update -q && DEBIAN_FRONTEND=noninteractive apt-get install -y -q nginx'\n",[154,376,378,380,383,386,388],{"class":156,"line":377},17,[154,379,248],{"class":160},[154,381,382],{"class":164}," file",[154,384,385],{"class":164}," push",[154,387,186],{"class":164},[154,389,390],{"class":164}," build-hello-vm\u002Fetc\u002Fnginx\u002Fconf.d\u002Fhello.conf\n",[154,392,394,396,398,400,402,404,406],{"class":156,"line":393},18,[154,395,248],{"class":160},[154,397,298],{"class":164},[154,399,257],{"class":164},[154,401,303],{"class":260},[154,403,368],{"class":164},[154,405,371],{"class":260},[154,407,408],{"class":164}," 'rm -f \u002Fetc\u002Fnginx\u002Fsites-enabled\u002Fdefault && nginx -t && systemctl enable nginx && cloud-init clean --logs'\n",[154,410,412,414,417],{"class":156,"line":411},19,[154,413,248],{"class":160},[154,415,416],{"class":164}," stop",[154,418,419],{"class":164}," build-hello-vm\n",[154,421,423,425,428,430,433],{"class":156,"line":422},20,[154,424,248],{"class":160},[154,426,427],{"class":164}," publish",[154,429,257],{"class":164},[154,431,432],{"class":260}," --alias",[154,434,435],{"class":164}," hello-vm-1\n",[154,437,439,441,444],{"class":156,"line":438},21,[154,440,248],{"class":160},[154,442,443],{"class":164}," delete",[154,445,419],{"class":164},[154,447,449],{"class":156,"line":448},22,[154,450,451],{"class":260},"exit\n",[14,453,454],{},"Check the image type:",[145,456,458],{"className":147,"code":457,"language":149,"meta":150,"style":150},"lxc image list hello-vm-1 -c lt\n# hello-vm-1 | VIRTUAL-MACHINE\n",[18,459,460,478],{"__ignoreMap":150},[154,461,462,464,467,470,473,475],{"class":156,"line":157},[154,463,248],{"class":160},[154,465,466],{"class":164}," image",[154,468,469],{"class":164}," list",[154,471,472],{"class":164}," hello-vm-1",[154,474,264],{"class":260},[154,476,477],{"class":164}," lt\n",[154,479,480],{"class":156,"line":196},[154,481,482],{"class":168},"# hello-vm-1 | VIRTUAL-MACHINE\n",[116,484,486],{"kind":485},"tip",[14,487,488,491,492,495],{},[18,489,490],{},"ubuntu:24.04"," and ",[18,493,494],{},"ubuntu:22.04"," from the public remote work as VM images as they are, so you can skip this step to experiment. You'd then install your software inside the running VM by hand, which is lost when an image upgrade recreates it.",[44,497,499],{"id":498},"_2-write-applicationyaml-3-minutes","2. Write application.yaml (3 minutes)",[145,501,505],{"className":502,"code":503,"language":504,"meta":150,"style":150},"language-yaml shiki shiki-themes github-dark-high-contrast","api_version: genesis\u002Fv1\napplication:\n  name: vmdemo\n  cluster: lab\n  groups:\n    - name: app\n      count: 2\n      type: vm\n      image: hello-vm-1\n      target: {app-0: node-a, app-1: node-b}\n      size: {cpu: 2, memory: 2GiB, root_disk: 20GiB}\n      volumes:\n        - name: data0\n          pool: default\n          size: 10GiB\n          content_type: block\n          attach: [app-0]\n          mount: \u002Fsrv\u002Fdata\n        - name: data1\n          pool: default\n          size: 10GiB\n          content_type: block\n          attach: [app-1]\n          mount: \u002Fsrv\u002Fdata\n      expose:\n        - port: 8080\u002Ftcp\n      health: [\u002Fusr\u002Fbin\u002Fcurl, -fsS, http:\u002F\u002F127.0.0.1:8080\u002Fhealthz]\n","yaml",[18,506,507,518,526,536,546,553,566,576,586,596,625,661,668,680,690,700,710,723,733,744,752,760,768,779,788,796,809],{"__ignoreMap":150},[154,508,509,513,515],{"class":156,"line":157},[154,510,512],{"class":511},"sKpQp","api_version",[154,514,102],{"class":192},[154,516,517],{"class":164},"genesis\u002Fv1\n",[154,519,520,523],{"class":156,"line":196},[154,521,522],{"class":511},"application",[154,524,525],{"class":192},":\n",[154,527,528,531,533],{"class":156,"line":202},[154,529,530],{"class":511},"  name",[154,532,102],{"class":192},[154,534,535],{"class":164},"vmdemo\n",[154,537,538,541,543],{"class":156,"line":208},[154,539,540],{"class":511},"  cluster",[154,542,102],{"class":192},[154,544,545],{"class":164},"lab\n",[154,547,548,551],{"class":156,"line":214},[154,549,550],{"class":511},"  groups",[154,552,525],{"class":192},[154,554,555,558,561,563],{"class":156,"line":220},[154,556,557],{"class":192},"    - ",[154,559,560],{"class":511},"name",[154,562,102],{"class":192},[154,564,565],{"class":164},"app\n",[154,567,568,571,573],{"class":156,"line":226},[154,569,570],{"class":511},"      count",[154,572,102],{"class":192},[154,574,575],{"class":260},"2\n",[154,577,578,581,583],{"class":156,"line":232},[154,579,580],{"class":511},"      type",[154,582,102],{"class":192},[154,584,585],{"class":164},"vm\n",[154,587,588,591,593],{"class":156,"line":238},[154,589,590],{"class":511},"      image",[154,592,102],{"class":192},[154,594,595],{"class":164},"hello-vm-1\n",[154,597,598,601,604,607,609,612,615,618,620,623],{"class":156,"line":245},[154,599,600],{"class":511},"      target",[154,602,603],{"class":192},": {",[154,605,606],{"class":511},"app-0",[154,608,102],{"class":192},[154,610,611],{"class":164},"node-a",[154,613,614],{"class":192},", ",[154,616,617],{"class":511},"app-1",[154,619,102],{"class":192},[154,621,622],{"class":164},"node-b",[154,624,229],{"class":192},[154,626,627,630,632,635,637,639,641,644,646,649,651,654,656,659],{"class":156,"line":278},[154,628,629],{"class":511},"      size",[154,631,603],{"class":192},[154,633,634],{"class":511},"cpu",[154,636,102],{"class":192},[154,638,270],{"class":260},[154,640,614],{"class":192},[154,642,643],{"class":511},"memory",[154,645,102],{"class":192},[154,647,648],{"class":164},"2GiB",[154,650,614],{"class":192},[154,652,653],{"class":511},"root_disk",[154,655,102],{"class":192},[154,657,658],{"class":164},"20GiB",[154,660,229],{"class":192},[154,662,663,666],{"class":156,"line":283},[154,664,665],{"class":511},"      volumes",[154,667,525],{"class":192},[154,669,670,673,675,677],{"class":156,"line":289},[154,671,672],{"class":192},"        - ",[154,674,560],{"class":511},[154,676,102],{"class":192},[154,678,679],{"class":164},"data0\n",[154,681,682,685,687],{"class":156,"line":332},[154,683,684],{"class":511},"          pool",[154,686,102],{"class":192},[154,688,689],{"class":164},"default\n",[154,691,692,695,697],{"class":156,"line":352},[154,693,694],{"class":511},"          size",[154,696,102],{"class":192},[154,698,699],{"class":164},"10GiB\n",[154,701,702,705,707],{"class":156,"line":357},[154,703,704],{"class":511},"          content_type",[154,706,102],{"class":192},[154,708,709],{"class":164},"block\n",[154,711,712,715,718,720],{"class":156,"line":377},[154,713,714],{"class":511},"          attach",[154,716,717],{"class":192},": [",[154,719,606],{"class":164},[154,721,722],{"class":192},"]\n",[154,724,725,728,730],{"class":156,"line":393},[154,726,727],{"class":511},"          mount",[154,729,102],{"class":192},[154,731,732],{"class":164},"\u002Fsrv\u002Fdata\n",[154,734,735,737,739,741],{"class":156,"line":411},[154,736,672],{"class":192},[154,738,560],{"class":511},[154,740,102],{"class":192},[154,742,743],{"class":164},"data1\n",[154,745,746,748,750],{"class":156,"line":422},[154,747,684],{"class":511},[154,749,102],{"class":192},[154,751,689],{"class":164},[154,753,754,756,758],{"class":156,"line":438},[154,755,694],{"class":511},[154,757,102],{"class":192},[154,759,699],{"class":164},[154,761,762,764,766],{"class":156,"line":448},[154,763,704],{"class":511},[154,765,102],{"class":192},[154,767,709],{"class":164},[154,769,771,773,775,777],{"class":156,"line":770},23,[154,772,714],{"class":511},[154,774,717],{"class":192},[154,776,617],{"class":164},[154,778,722],{"class":192},[154,780,782,784,786],{"class":156,"line":781},24,[154,783,727],{"class":511},[154,785,102],{"class":192},[154,787,732],{"class":164},[154,789,791,794],{"class":156,"line":790},25,[154,792,793],{"class":511},"      expose",[154,795,525],{"class":192},[154,797,799,801,804,806],{"class":156,"line":798},26,[154,800,672],{"class":192},[154,802,803],{"class":511},"port",[154,805,102],{"class":192},[154,807,808],{"class":164},"8080\u002Ftcp\n",[154,810,812,815,817,820,822,825,827,830],{"class":156,"line":811},27,[154,813,814],{"class":511},"      health",[154,816,717],{"class":192},[154,818,819],{"class":164},"\u002Fusr\u002Fbin\u002Fcurl",[154,821,614],{"class":192},[154,823,824],{"class":164},"-fsS",[154,826,614],{"class":192},[154,828,829],{"class":164},"http:\u002F\u002F127.0.0.1:8080\u002Fhealthz",[154,831,722],{"class":192},[14,833,834],{},"What's different from a container group:",[836,837,838,852,860,868],"ul",{},[839,840,841,845,846,848,849,133],"li",{},[122,842,843],{},[18,844,20],{}," makes ",[18,847,101],{}," create each instance with ",[18,850,851],{},"lxc init … --vm",[839,853,854,859],{},[122,855,856],{},[18,857,858],{},"size.memory"," is the VM's RAM. Unlike a container limit, a VM's kernel uses what it's given and rarely hands it back, so plan for the full amount: two of these take 4GiB from the members.",[839,861,862,867],{},[122,863,864],{},[18,865,866],{},"size.root_disk"," sizes the VM's own disk. Leave it out and you get the pool's default (10GiB on a stock LXD). It can grow later; it never shrinks.",[839,869,870,875],{},[122,871,872],{},[18,873,874],{},"content_type: block"," volumes attach only to VMs. Each instance gets its own here, since a volume used by two instances must stay on one member.",[44,877,879],{"id":878},"_3-deploy-5-minutes","3. Deploy (5 minutes)",[145,881,883],{"className":147,"code":882,"language":149,"meta":150,"style":150},"sg application init --config application.yaml\nsg application plan --config application.yaml\nsg application deploy --config application.yaml\n",[18,884,885,901,914],{"__ignoreMap":150},[154,886,887,889,892,895,898],{"class":156,"line":157},[154,888,101],{"class":160},[154,890,891],{"class":164}," application",[154,893,894],{"class":164}," init",[154,896,897],{"class":260}," --config",[154,899,900],{"class":164}," application.yaml\n",[154,902,903,905,907,910,912],{"class":156,"line":196},[154,904,101],{"class":160},[154,906,891],{"class":164},[154,908,909],{"class":164}," plan",[154,911,897],{"class":260},[154,913,900],{"class":164},[154,915,916,918,920,923,925],{"class":156,"line":202},[154,917,101],{"class":160},[154,919,891],{"class":164},[154,921,922],{"class":164}," deploy",[154,924,897],{"class":260},[154,926,900],{"class":164},[14,928,929,930,491,933,936,937,940,941,936,944,946],{},"The plan shows ",[18,931,932],{},"volumes.data0",[18,934,935],{},"volumes.data1"," (",[18,938,939],{},"medium",", the volumes don't exist yet) and ",[18,942,943],{},"instances.app",[18,945,939],{},", both instances absent), the same shape as a container deploy.",[116,948,949,983],{"kind":118},[14,950,951,965,966,968,969,972,973,975,976,979,980,133],{},[122,952,953,954,957,958,961,962,133],{},"Known gap in ",[18,955,956],{},"0.1.0-dev",": the first deploy of a VM group with ",[18,959,960],{},"health"," may stop at ",[18,963,964],{},"app.health"," ",[18,967,101],{}," starts the VM, sees it ",[18,970,971],{},"Running",", and runs the health command once. A VM reports ",[18,974,971],{}," about ten seconds before ",[18,977,978],{},"lxc exec"," works, so that one attempt can fail with ",[18,981,982],{},"LXD VM agent is not currently running",[14,984,985,986,989],{},"If it happens, nothing is lost. Wait a few seconds and run ",[18,987,988],{},"sg application deploy"," again. The instances already exist and are running, so the second deploy is a check-only run; when the checks pass, it records the generation.",[44,991,993],{"id":992},"_4-check-it-2-minutes","4. Check it (2 minutes)",[145,995,997],{"className":147,"code":996,"language":149,"meta":150,"style":150},"sg application status --config application.yaml\ncurl http:\u002F\u002F100.64.0.11:8080\u002F          # hello from vmdemo-app-0\ncurl http:\u002F\u002F100.64.0.12:8080\u002F          # hello from vmdemo-app-1\n",[18,998,999,1011,1022],{"__ignoreMap":150},[154,1000,1001,1003,1005,1007,1009],{"class":156,"line":157},[154,1002,101],{"class":160},[154,1004,891],{"class":164},[154,1006,346],{"class":164},[154,1008,897],{"class":260},[154,1010,900],{"class":164},[154,1012,1013,1016,1019],{"class":156,"line":196},[154,1014,1015],{"class":160},"curl",[154,1017,1018],{"class":164}," http:\u002F\u002F100.64.0.11:8080\u002F",[154,1020,1021],{"class":168},"          # hello from vmdemo-app-0\n",[154,1023,1024,1026,1029],{"class":156,"line":202},[154,1025,1015],{"class":160},[154,1027,1028],{"class":164}," http:\u002F\u002F100.64.0.12:8080\u002F",[154,1030,1031],{"class":168},"          # hello from vmdemo-app-1\n",[14,1033,1034,1037],{},[18,1035,1036],{},"status"," runs your health command in each VM, exactly as for containers.",[44,1039,1041],{"id":1040},"_5-get-a-shell-2-minutes","5. Get a shell (2 minutes)",[14,1043,1044,1046,1047,1049],{},[18,1045,101],{}," doesn't set up SSH into instances, VM or container. Use ",[18,1048,248],{}," on the member that holds the instance:",[145,1051,1053],{"className":147,"code":1052,"language":149,"meta":150,"style":150},"ssh root@203.0.113.10\nlxc exec vmdemo-app-0 -- bash\n",[18,1054,1055,1062],{"__ignoreMap":150},[154,1056,1057,1059],{"class":156,"line":157},[154,1058,161],{"class":160},[154,1060,1061],{"class":164}," root@203.0.113.10\n",[154,1063,1064,1066,1068,1071,1073],{"class":156,"line":196},[154,1065,248],{"class":160},[154,1067,298],{"class":164},[154,1069,1070],{"class":164}," vmdemo-app-0",[154,1072,303],{"class":260},[154,1074,1075],{"class":164}," bash\n",[14,1077,1078],{},"Inside, look at the disks:",[145,1080,1082],{"className":147,"code":1081,"language":149,"meta":150,"style":150},"lsblk -o NAME,SIZE,TYPE,MOUNTPOINT\nls -l \u002Fdev\u002Fdisk\u002Fby-id\u002F | grep sg--volume\n# scsi-0QEMU_QEMU_HARDDISK_lxd_sg--volume--data0 -> ..\u002F..\u002Fsdb\n",[18,1083,1084,1095,1115],{"__ignoreMap":150},[154,1085,1086,1089,1092],{"class":156,"line":157},[154,1087,1088],{"class":160},"lsblk",[154,1090,1091],{"class":260}," -o",[154,1093,1094],{"class":164}," NAME,SIZE,TYPE,MOUNTPOINT\n",[154,1096,1097,1100,1103,1106,1109,1112],{"class":156,"line":196},[154,1098,1099],{"class":160},"ls",[154,1101,1102],{"class":260}," -l",[154,1104,1105],{"class":164}," \u002Fdev\u002Fdisk\u002Fby-id\u002F",[154,1107,1108],{"class":182}," |",[154,1110,1111],{"class":160}," grep",[154,1113,1114],{"class":164}," sg--volume\n",[154,1116,1117],{"class":156,"line":202},[154,1118,1119],{"class":168},"# scsi-0QEMU_QEMU_HARDDISK_lxd_sg--volume--data0 -> ..\u002F..\u002Fsdb\n",[14,1121,1122,1123,1126,1127,1130,1131,1134,1135,1138],{},"The root disk is 20G, and the block volume is a second, ",[122,1124,1125],{},"raw"," disk. The ",[18,1128,1129],{},"mount"," field doesn't mount a block volume. Format and mount it yourself the first time, using the stable ",[18,1132,1133],{},"by-id"," name (the dashes in ",[18,1136,1137],{},"sg-volume-"," are doubled):",[145,1140,1142],{"className":147,"code":1141,"language":149,"meta":150,"style":150},"dev=\u002Fdev\u002Fdisk\u002Fby-id\u002Fscsi-0QEMU_QEMU_HARDDISK_lxd_sg--volume--data0\nmkfs.ext4 -L data \"$dev\"\nmkdir -p \u002Fsrv\u002Fdata\necho \"$dev \u002Fsrv\u002Fdata ext4 defaults,nofail 0 2\" >> \u002Fetc\u002Ffstab\nmount \u002Fsrv\u002Fdata\n",[18,1143,1144,1155,1175,1186,1204],{"__ignoreMap":150},[154,1145,1146,1149,1152],{"class":156,"line":157},[154,1147,1148],{"class":192},"dev",[154,1150,1151],{"class":182},"=",[154,1153,1154],{"class":164},"\u002Fdev\u002Fdisk\u002Fby-id\u002Fscsi-0QEMU_QEMU_HARDDISK_lxd_sg--volume--data0\n",[154,1156,1157,1160,1163,1166,1169,1172],{"class":156,"line":196},[154,1158,1159],{"class":160},"mkfs.ext4",[154,1161,1162],{"class":260}," -L",[154,1164,1165],{"class":164}," data",[154,1167,1168],{"class":164}," \"",[154,1170,1171],{"class":192},"$dev",[154,1173,1174],{"class":164},"\"\n",[154,1176,1177,1180,1183],{"class":156,"line":202},[154,1178,1179],{"class":160},"mkdir",[154,1181,1182],{"class":260}," -p",[154,1184,1185],{"class":164}," \u002Fsrv\u002Fdata\n",[154,1187,1188,1191,1193,1195,1198,1201],{"class":156,"line":208},[154,1189,1190],{"class":260},"echo",[154,1192,1168],{"class":164},[154,1194,1171],{"class":192},[154,1196,1197],{"class":164}," \u002Fsrv\u002Fdata ext4 defaults,nofail 0 2\"",[154,1199,1200],{"class":182}," >>",[154,1202,1203],{"class":164}," \u002Fetc\u002Ffstab\n",[154,1205,1206,1208],{"class":156,"line":214},[154,1207,1129],{"class":160},[154,1209,1185],{"class":164},[14,1211,1212,1213,1216,1217,1219],{},"The data lives on the volume and survives restarts, image upgrades and rollbacks. The ",[18,1214,1215],{},"fstab"," line lives on the root disk, so an image upgrade (which recreates the VM) loses it. Bake the ",[18,1218,1215],{}," line and the mount point into your image, or mount from your app's start-up script, rather than editing each VM by hand.",[116,1221,1222],{"kind":485},[14,1223,1224,1225,1228,1229,1232,1233,1235],{},"If you only need files, not a raw disk, leave out ",[18,1226,1227],{},"content_type"," (or set ",[18,1230,1231],{},"filesystem","). A filesystem volume is mounted at its ",[18,1234,1129],{}," path automatically, in VMs too.",[44,1237,1239],{"id":1238},"_6-health-checks-for-vms","6. Health checks for VMs",[14,1241,1242,1244],{},[18,1243,960],{}," is required for container groups and optional for VM groups. Leave it out and:",[836,1246,1247,1250,1263],{},[839,1248,1249],{},"deploy can't tell whether your software started, only that the VM is running;",[839,1251,1252,1254,1255,1258,1259,1262],{},[18,1253,1036],{}," shows ",[18,1256,1257],{},"not-configured"," instead of ",[18,1260,1261],{},"healthy",";",[839,1264,1265],{},"only the exposed-port check stands between a broken image and a new generation, and a later rollback can land on it.",[14,1267,1268],{},"Keep it unless the VM has nothing to check. When it does nothing more than run its init system, this waits for boot to finish and fails if any unit failed:",[145,1270,1272],{"className":502,"code":1271,"language":504,"meta":150,"style":150},"      health: [\u002Fusr\u002Fbin\u002Fsystemctl, is-system-running, --wait]\n",[18,1273,1274],{"__ignoreMap":150},[154,1275,1276,1278,1280,1283,1285,1288,1290,1293],{"class":156,"line":157},[154,1277,814],{"class":511},[154,1279,717],{"class":192},[154,1281,1282],{"class":164},"\u002Fusr\u002Fbin\u002Fsystemctl",[154,1284,614],{"class":192},[154,1286,1287],{"class":164},"is-system-running",[154,1289,614],{"class":192},[154,1291,1292],{"class":164},"--wait",[154,1294,722],{"class":192},[44,1296,1298],{"id":1297},"_7-change-it-and-clean-up","7. Change it and clean up",[14,1300,1301,1302,1306],{},"Everything on ",[33,1303,1305],{"href":1304},"\u002Fdocs\u002Fapplications\u002Fday-two","Scale, upgrade and roll back"," works for VMs. Two things to keep in mind:",[836,1308,1309,1319],{},[839,1310,1311,1312,1315,1316,1318],{},"An image upgrade ",[122,1313,1314],{},"recreates"," each VM. Anything not on a volume or in the image is gone, including that ",[18,1317,1215],{}," edit.",[839,1320,1321,1324,1325,1328],{},[18,1322,1323],{},"scale"," changes only ",[18,1326,1327],{},"count"," and placement. It doesn't add volumes, so new instances in a group like this one start without a data disk until you add a volume entry for them and deploy.",[14,1330,1331],{},"When you're done:",[145,1333,1335],{"className":147,"code":1334,"language":149,"meta":150,"style":150},"sg application destroy --config application.yaml\n",[18,1336,1337],{"__ignoreMap":150},[154,1338,1339,1341,1343,1346,1348],{"class":156,"line":157},[154,1340,101],{"class":160},[154,1342,891],{"class":164},[154,1344,1345],{"class":164}," destroy",[154,1347,897],{"class":260},[154,1349,900],{"class":164},[14,1351,1352,1353,1356,1357,133],{},"This deletes the VMs ",[122,1354,1355],{},"and the block volumes with their data",". See ",[33,1358,1360],{"href":1359},"\u002Fdocs\u002Fapplications\u002Fdestroy","Destroy and data safety",[116,1362,1364],{"kind":1363},"check",[836,1365,1366,1375,1386],{},[839,1367,1368,1371,1372,133],{},[18,1369,1370],{},"lxc image list hello-vm-1 -c lt"," says ",[18,1373,1374],{},"VIRTUAL-MACHINE",[839,1376,1377,1380,1381,491,1384,133],{},[18,1378,1379],{},"sg application status"," shows both VMs ",[18,1382,1383],{},"RUNNING",[18,1385,1261],{},[839,1387,1388,1390],{},[18,1389,1088],{}," inside a VM shows a 20G root disk and the 10G volume.",[1392,1393,1394],"style",{},"html pre.shiki code .s_sBn, html code.shiki .s_sBn{--shiki-default:#FFB757}html pre.shiki code .sTRMh, html code.shiki .sTRMh{--shiki-default:#ADDCFF}html pre.shiki code .sQrFR, html code.shiki .sQrFR{--shiki-default:#BDC4CC}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html pre.shiki code .sWyjQ, html code.shiki .sWyjQ{--shiki-default:#FF9492}html pre.shiki code .sMAXC, html code.shiki .sMAXC{--shiki-default:#F0F3F6}html pre.shiki code .sCcAr, html code.shiki .sCcAr{--shiki-default:#91CBFF}html pre.shiki code .sKpQp, html code.shiki .sKpQp{--shiki-default:#72F088}",{"title":150,"searchDepth":196,"depth":196,"links":1396},[1397,1398,1399,1400,1401,1402,1403,1404],{"id":46,"depth":196,"text":47},{"id":113,"depth":196,"text":114},{"id":498,"depth":196,"text":499},{"id":878,"depth":196,"text":879},{"id":992,"depth":196,"text":993},{"id":1040,"depth":196,"text":1041},{"id":1238,"depth":196,"text":1239},{"id":1297,"depth":196,"text":1298},"Run an application group as virtual machines. When to choose a VM, how to build a VM image, root disks, block volumes, health checks and getting a shell.","md",{},"\u002Fdocs\u002Fapplications\u002Fvms",{"title":5,"description":1405},"docs\u002Fapplications\u002Fvms","VGi1vV1-r5jLyXVjLsr-ebnyDo2eYC5wnffRlK24QJk",1796464240884]