Here are the steps how to migrate a GCP VM from one network to another. It involves recreating the instance in that network.
- Find the VM. Click the ‘Create Similar’ button.
- Select the new network. Save Network. Everything else should stay the same.
- Don’t click Create, but get the ‘Create Similar’ command line script only. Click Cancel after.
- Make sure to edit the hostname. GCP appends a ‘-1’ at the end of hostname.
- Edit VM to keep all disks. Delete VM. Make sure to preserve boot drive.
- Run the ‘Create Similar’ command line script you capture to create new VM in the new network.
- The new VM will be based on golden image.
- Stop VM. Swap new disks with old disks.
- Start VM.
If you have changed instance type to either C5 or M5 and it no longer boots, it’s due to the following reasons.
- The Elastic Network Adapter (ENA) enaSupport attribute is disabled for the instance.
- The ENA module isn’t installed on the instance
- The NVMe module isn’t installed on the instance, or, if installed, the NVMe module isn’t loaded in the initramfs image of the instance.
- You are trying to mount the file systems at boot time in the “/etc/fstab” file using a device name. Amazon Elastic Block Store (Amazon EBS) volumes are exposed as NVMe devices to these instance types, and the device names are changed. To avoid this, mount the file systems using UUID/Label. For more information, see Amazon EBS and NVMe.
You will need to run a Bash script to update the current instance to be able to support a C5 or M5 instance.
Here’s how to enable secondary private IPs for AWS EC2 instances.
- Add secondary private IPs to the instance.
- Editing the instance Networking > Manage IP Addresses.
- Add new private IP addresses.
- Set the route configuration for each secondary IP address.
- Config files are ifcfg-eth0:0, ifcfg-eth:0.1 and so on.
- Test each interface or IP to see if they respond to ping.
The following are steps on how to change the network of an instance from one VPC to another. This is assuming you want to keep the same server name, but will need to make a network change. Unfortunately, changing networks will require creating a new instance. The following are the steps to make that change.
- Keep track of all the disks.
- Keep all disks including boot.
- Stop the instance.
- Create an image of the boot drive. Wait for it to complete.
- Create a similar instance, but do not execute.
- Make the network changes. Save the GCloud CLI command.
- Delete the instance.
- Run the saved command from step 4. This creates a new instance.
- Stop the instance.
- Detach the boot disk.
- Attach all the other disks.
- Boot the instance.
Resolv.conf is a computer file used by various operating systems as a DNS resolver. The file is in plain text. It’s usually generated by the system administrator or a network program. The file is located in the /etc/ directory and contains the search domain as well a list of nameservers.
Here’s an example of the /etc/resolv.conf file.
search domain.com local.lan
If you have problems resolving domain names, check this file first.