Creating a VM on a dedicated host
A created VM will be linked to the host selected from a group of dedicated hosts. When the VM is stopped, it will not be available on the host, and when it is restarted, it will be linked to the same host from the group.
If you do not have a group of dedicated hosts, create one.
To create a VM:
If you do not have the Yandex Cloud command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
-
Get the group ID for the dedicated host group where you need to create the VM:
yc compute host-group list
Result:
+------------------------------+-------+--------------+-------+---------------+ | ID | CORES | MEMORY | DISKS | DISK SIZE | +------------------------------+-------+--------------+-------+---------------+ ... | intel-6338-c108-m704-n3200x6 | 108 | 755914244096 | 6 | 3198924357632 | +------------------------------+-------+--------------+-------+---------------+
-
Retrieve the ID of the group's dedicated host where you need to create the VM:
yc compute host-group list-hosts <dedicated_host_group_ID>
Result:
+----------------------+----------------------+ | ID | SERVER ID | +----------------------+----------------------+ | fhm1ab2mhnf3******** | fhmlabct12vp******** | | fhmabcun12kb******** | fhm1a2bcsl13******** | +----------------------+----------------------+
-
Get a list of available subnets:
yc vpc subnet list
Result:
+----------------------+-----------------------+----------------------+----------------+---------------+-----------------+ | ID | NAME | NETWORK ID | ROUTE TABLE ID | ZONE | RANGE | +----------------------+-----------------------+----------------------+----------------+---------------+-----------------+ | b0c6n43f9lgh******** | default-ru-central1-d | enpe3m3fa00u******** | | ru-central1-d | [10.130.0.0/24] | | e2l2da8a20b3******** | default-ru-central1-b | enpe3m3fa00u******** | | ru-central1-b | [10.129.0.0/24] | | e9bnlm18l70a******** | default-ru-central1-a | enpe3m3fa00u******** | | ru-central1-a | [10.128.0.0/24] | +----------------------+-----------------------+----------------------+----------------+---------------+-----------------+
-
Run the following command to create a VM:
yc compute instance create \ --host-id <dedicated_host_ID> \ --zone <availability_zone> \ --platform <platform_ID> \ --network-interface subnet-name=<subnet_name> \ --attach-local-disk size=<disk_size>
Where:
-
--host-id
: Dedicated host ID. -
--zone
: Availability zone where the group of dedicated hosts resides. -
--platform
: Platform that be the same as the platform for the group of dedicated hosts:standard-v3
: For hosts based on Intel® Ice Lake.standard-v2
: For archived hosts based on Intel Cascade Lake.
-
--network-interface
: VM network interface description:subnet-name
: Name of the subnet in the availability zone.
-
--attach-local-disk
: Properties of the local disk being attached to the VM:size
: Disk size in bytes. You can find the possible values in the list of dedicated host types and theyc compute host-type list
command output. For example, for theintel-6338-c108-m704-n3200x6
host type, you should specify3198924357632
(~ 2.91 TB). You cannot set a size different from the host disk size.
The
--attach-local-disk
parameter is optional. To attach multiple local disks, specify the parameter as many times as required. For more information, see Local and network disks.
To specify other VM properties, use the
yc compute instance create
command parameters as described in the CLI reference. For more information, see VMs in Compute Cloud and Creating VMs.Result:
done (41s) id: fhm1abc23407******** folder_id: m4n56op78mev******** created_at: "2020-10-13T08:00:55Z" zone_id: ru-central1-a ... placement_policy: host_affinity_rules: - key: yc.hostId op: IN values: - fhm1ab2mhnf3********
-
- Find out the ID of the dedicated host group using the list REST API method for the HostGroup resource or the HostGroupService/List gRPC API call.
- Find out the IDs of dedicated hosts in the group using the listHosts REST API method for the HostGroup resource or the HostGroupService/ListHosts gRPC API call.
- Create a VM instance using the create REST API method for the Instance resource or the InstanceService/Create gRPC API call.
If you attached local disks to your VM, partition and mount them after the VM is created.
Example of creating a VM with a local disk on a dedicated host
Before creating a VM:
- Create a dedicated host group and get its ID using the
yc compute host-group list
CLI command. - Get a list of IDs of dedicated hosts in the group using the
yc compute host-group list-hosts
CLI command. - Generate a key pair to connect to the VM via SSH.
Create a VM with the following characteristics:
- Location: Dedicated host
- Platform: Intel Ice Lake
- Number of vCPUs: 64
- Amount of RAM: 704 GB
- Number of local disks: 1
- Local disk size: 3,198,924,357,632 B (~2.91 TB)
- Operating system: Ubuntu 22.04 LTS
To do this, follow these steps:
If you do not have the Yandex Cloud command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
Run the following command to create a VM:
yc compute instance create \
--cloud-id <cloud_ID> \
--folder-id <folder_ID> \
--zone <availability_zone> \
--name <VM_name> \
--platform standard-v3 \
--cores 64 \
--memory 704 \
--host-id <dedicated_host_ID> \
--network-interface subnet-id=<subnet_ID> \
--attach-local-disk "size=3198924357632" \
--ssh-key <path_to_public_SSH_key_file> \
--create-boot-disk name=boot-disk,size=1000,image-folder-id=standard-images,image-family=ubuntu-2204-lts
Where:
-
--cloud-id
: Cloud ID. -
--folder-id
: Folder ID. -
--zone
: Availability zone where the group of dedicated hosts resides. -
--name
: VM name. -
--platform
: VM platform. -
--cores
: Number of vCPUs. -
--memory
: Amount of RAM. -
--host-id
: Dedicated host ID. -
--network-interface
: VM network interface description:subnet-id
: ID of the subnet in the availability zone hosting the VM.
-
--attach-local-disk
: Description of the local disk being attached:size
: Disk size.
-
--ssh-key
: Public SSH key path. The VM will automatically create a user namedyc-user
for this key. -
--create-boot-disk
: Boot disk parameters.
Result:
done (20s)
id: fhmbdt1jj2k3********
folder_id: m4n56op78mev********
created_at: "2023-01-27T12:06:52Z"
zone_id: ru-central1-a
...
placement_policy:
host_affinity_rules:
- key: yc.hostId
op: IN
values:
- fhm1ceqtmivg********
Intel is a trademark of Intel Corporation or its subsidiaries.