Creating a VM on a dedicated host
The VM you create will be linked to the host selected from a group of dedicated hosts. Once stopped, the VM becomes unavailable on the host, but it will be linked to the same host when you restart it.
If you do not have a group of dedicated hosts yet, create one.
To create a VM:
If you do not have the Yandex Cloud CLI yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder through the --folder-name
or --folder-id
parameter.
-
Get the ID of the dedicated host group to create your VM in:
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 to create your VM on:
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 this 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. It must match the platform of the dedicated host group: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, 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 this parameter as many times as needed. 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 a VM.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********
-
- Get the ID of the dedicated host group using the list REST API method for the HostGroup resource or the HostGroupService/List gRPC API call.
- Get 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 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 your VM via SSH.
Create a VM with the following parameters:
- 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 CLI yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder through the --folder-name
or --folder-id
parameter.
Run this 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.