[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-09-04 (世界標準時間)。"],[[["\u003cp\u003eBefore creating or managing virtual machines (VMs) using \u003ccode\u003egdcloud\u003c/code\u003e or \u003ccode\u003ekubectl\u003c/code\u003e, ensure you've installed and configured the \u003ccode\u003egdcloud\u003c/code\u003e CLI and have the necessary operating system environment.\u003c/p\u003e\n"],["\u003cp\u003eAccessing the Management API server for VM operations requires a kubeconfig file, which you can generate if you don't have one, and its path is needed to execute \u003ccode\u003ekubectl\u003c/code\u003e commands.\u003c/p\u003e\n"],["\u003cp\u003eTo perform VM-related tasks, users must be granted both the Project VirtualMachine Admin and Project Viewer roles, which can be assigned by a Project IAM Admin.\u003c/p\u003e\n"],["\u003cp\u003eCreating a VM instance requires a boot disk, which can be created using either a GDC-provided OS image or a custom OS image; it can also be created independently of instance creation and then attached.\u003c/p\u003e\n"],["\u003cp\u003eYou can create boot disks from both GDC-provided images and custom images, in both cases, you must ensure the disk's size is at least the \u003ccode\u003eminimumDiskSize\u003c/code\u003e of the chosen image, and it is possible to create one using either \u003ccode\u003egdcloud\u003c/code\u003e or \u003ccode\u003ekubectl\u003c/code\u003e.\u003c/p\u003e\n"]]],[],null,["# Create a customized boot disk\n\nBefore you begin\n----------------\n\nTo use `gdcloud` command-line interface (CLI) commands, ensure that you have downloaded, installed,\nand configured the [`gdcloud` CLI](/distributed-cloud/hosted/docs/latest/gdch/resources/gdcloud-overview).\nAll commands for Distributed Cloud use the `gdcloud` or\n`kubectl` CLI, and require an operating system (OS) environment.\n\n### Get the kubeconfig file path\n\nTo run commands against the Management API server, ensure you have the following\nresources:\n\n1. [Sign in and generate](/distributed-cloud/hosted/docs/latest/gdch/application/ao-user/iam/sign-in#cli) the\n kubeconfig file for the Management API server if you don't have one.\n\n2. Use the path to the kubeconfig file of the Management API server to replace\n \u003cvar translate=\"no\"\u003eMANAGEMENT_API_SERVER\u003c/var\u003e in these instructions.\n\n### Request permissions and access\n\nTo perform the tasks listed in this page, you must have the Project\nVirtualMachine Admin role. Follow the steps to\n[verify](/distributed-cloud/hosted/docs/latest/gdch/application/ao-user/vms/preparation#verify-user-access)\nthat you have the Project VirtualMachine Admin (`project-vm-admin`) role in the namespace\nof the project where the VM resides.\n\nFor VM operations using the GDC console or the gdcloud CLI,\nrequest your Project IAM Admin to assign you both the\nProject VirtualMachine Admin role and the Project Viewer (`project-viewer`)\nrole.\n\nCreate a boot disk\n------------------\n\nWhen you create a virtual machine (VM) instance, you must also create a boot\ndisk for the VM. You can use either a public image or a custom image.\n\nGDC automatically creates a boot persistent disk when you\n[create a VM instance](/distributed-cloud/hosted/docs/latest/gdch/application/ao-user/vms/create-a-vm/create-and-start).\nIf you require additional data storage disks for your instances,\n[add a persistent disk to your VM](/distributed-cloud/hosted/docs/latest/gdch/application/ao-user/vms/manage-storage/add-a-vm-disk).\n\nUse the procedures described on this page to create boot disks that you can\nuse later to create VMs.\n\nCreate a boot disk from an image\n--------------------------------\n\nYou can create a standalone boot persistent disk outside of instance creation\nand attach it to an instance afterwards. This section shows how to create a boot\ndisk from either a\n[GDC-provided OS image](/distributed-cloud/hosted/docs/latest/gdch/application/ao-user/vms/create-a-vm/create-and-start#create-vm-from-provided-image)\nor a\n[custom OS image](/distributed-cloud/hosted/docs/latest/gdch/application/ao-user/vms/create-a-vm/create-and-start#create-vm-from-custom).\n\n### Create a boot disk from a GDC-provided image\n\nBefore you create a boot disk by using a GDC-provided image,\nreview the list of available images. Then create a boot disk with the provided image. \n\n### gdcloud\n\n1. List all available images and their minimum disk size:\n\n gdcloud compute images list\n\n This command includes both Distributed Cloud-provided and custom\n images. Choose either one in the `vm-system` namespace.\n2. Select a Distributed Cloud-provided image to create the VM disk:\n\n gdcloud compute disks create \u003cvar translate=\"no\"\u003eBOOT_DISK_NAME\u003c/var\u003e \\\n --project=\u003cvar translate=\"no\"\u003ePROJECT\u003c/var\u003e \\\n --size=\u003cvar translate=\"no\"\u003eDISK_SIZE\u003c/var\u003e \\\n --image=\u003cvar translate=\"no\"\u003eIMAGE_NAME\u003c/var\u003e \\\n --image-project=vm-system\n\n Replace the variables using the following definitions:\n\n### kubectl\n\n1. List all available GDC-provided images:\n\n kubectl --kubeconfig \u003cvar translate=\"no\"\u003eMANAGEMENT_API_SERVER\u003c/var\u003e \\\n get virtualmachineimages.virtualmachine.gdc.goog --namespace vm-system\n\n2. Get the `minimumDiskSize` of a specific GDC-provided\n image. The size of the created customized boot disk must be at least the\n `minimumDiskSize`:\n\n kubectl --kubeconfig \u003cvar translate=\"no\"\u003eMANAGEMENT_API_SERVER\u003c/var\u003e \\\n get virtualmachineimages.virtualmachine.gdc.goog --namespace vm-system \\\n \u003cvar translate=\"no\"\u003eIMAGE_NAME\u003c/var\u003e -ojsonpath='{.spec.minimumDiskSize}'\n\n3. Create a `VirtualMachineDisk` object:\n\n kubectl --kubeconfig \u003cvar translate=\"no\"\u003eMANAGEMENT_API_SERVER\u003c/var\u003e apply -n \u003cvar translate=\"no\"\u003ePROJECT\u003c/var\u003e -f - \u003c\u003cEOF\n apiVersion: virtualmachine.gdc.goog/v1\n kind: VirtualMachineDisk\n metadata:\n name: \u003cvar translate=\"no\"\u003eBOOT_DISK_NAME\u003c/var\u003e\n spec:\n source:\n image:\n name: \u003cvar translate=\"no\"\u003eIMAGE_NAME\u003c/var\u003e\n namespace: vm-system\n size: \u003cvar translate=\"no\"\u003eDISK_SIZE\u003c/var\u003e\n EOF\n\n Replace the variables using the following definitions,\n\n### Create a boot disk from a custom image\n\nA custom image belongs exclusively to your project. To create a VM with a\ncustom image, you must first [create a custom image](/distributed-cloud/hosted/docs/latest/gdch/application/ao-user/vms/create-custom-images/create-custom-images)\nin the same project if you don't already have one.\n\nSet up the necessary [IAM roles](/distributed-cloud/hosted/docs/latest/gdch/application/ao-user/vms/preparation)\nto access custom images in your project if you haven't done so yet. Then proceed\nwith these instructions. \n\n### gdcloud\n\n1. List all custom images and their minimum disk size:\n\n gdcloud compute images list \\\n --project=\u003cvar translate=\"no\"\u003ePROJECT\u003c/var\u003e \\\n\n2. Select a custom image to create the VM disk:\n\n gdcloud compute disks create \u003cvar translate=\"no\"\u003eBOOT_DISK_NAME\u003c/var\u003e \\\n --project=\u003cvar translate=\"no\"\u003ePROJECT\u003c/var\u003e \\\n --size=\u003cvar translate=\"no\"\u003eDISK_SIZE\u003c/var\u003e \\\n --image=\u003cvar translate=\"no\"\u003eIMAGE_NAME\u003c/var\u003e \\\n --image-project=\u003cvar translate=\"no\"\u003ePROJECT\u003c/var\u003e\n\n Replace the variables using the following definitions:\n\n### API\n\n1. List all custom images:\n\n kubectl --kubeconfig \u003cvar translate=\"no\"\u003eMANAGEMENT_API_SERVER\u003c/var\u003e \\\n get virtualmachineimages.virtualmachine.gdc.goog --namespace \u003cvar translate=\"no\"\u003ePROJECT\u003c/var\u003e\n\n2. Get the `minimumDiskSize` of a specific customized image. The size of the\n created customized boot disk must be at least the `minimumDiskSize`:\n\n kubectl --kubeconfig \u003cvar translate=\"no\"\u003eMANAGEMENT_API_SERVER\u003c/var\u003e \\\n get virtualmachineimages.virtualmachine.gdc.goog --namespace vm-system \\\n \u003cvar translate=\"no\"\u003eIMAGE_NAME\u003c/var\u003e -ojsonpath='{.spec.minimumDiskSize}'\n\n3. Create a `VirtualMachineDisk` object:\n\n kubectl --kubeconfig \u003cvar translate=\"no\"\u003eMANAGEMENT_API_SERVER\u003c/var\u003e \\\n apply --namespace \u003cvar translate=\"no\"\u003ePROJECT\u003c/var\u003e -f - \u003c\u003cEOF\n apiVersion: virtualmachine.gdc.goog/v1\n kind: VirtualMachineDisk\n metadata:\n name: \u003cvar translate=\"no\"\u003eBOOT_DISK_NAME\u003c/var\u003e\n spec:\n source:\n image:\n name: \u003cvar translate=\"no\"\u003eIMAGE_NAME\u003c/var\u003e\n namespace: \u003cvar translate=\"no\"\u003ePROJECT\u003c/var\u003e\n size: \u003cvar translate=\"no\"\u003eDISK_SIZE\u003c/var\u003e\n EOF\n\n Replace the variables, using the following definitions:\n\nTo replace a boot disk, see the [Replace a boot disk](/distributed-cloud/hosted/docs/latest/gdch/application/ao-user/vms/manage-vm-boot-disks/replace-a-boot-disk)\npage."]]