Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Copia il file system della macchina di origine
La modernizzazione di un componente dell'applicazione richiede la creazione di una copia del file system della macchina di origine.
Questa pagina descrive i passaggi necessari per copiare il file system della macchina di origine, nonché alcune specifiche per ridurre le dimensioni del file system copiato.
Crea una copia locale del file system della macchina di origine Linux
Il client a riga di comando Migrate to Containers supporta l'accesso alle macchine di origine tramite connessione SSH diretta o tramite gcloud.
SSH diretto
Per eseguire la copia utilizzando l'accesso SSH diretto, esegui il seguente comando:
OUTPUT_FILESYSTEM_DIR: il percorso della directory di output
sulla tua macchina locale in cui vuoi copiare il sistema di file della macchina di origine
Se la macchina di origine non ha un indirizzo IP pubblico, puoi eseguire una delle seguenti operazioni:
Se esegui l'interfaccia a riga di comando Migrate to Containers da una macchina della stessa rete interna, utilizza il flag --internal-ip.
Se esegui l'operazione su un'altra rete, utilizza il --tunnel-through-iap
flag.
Al termine della copia, una copia del file system della macchina di origine è disponibile nella directory di output specificata.
Riduci le dimensioni del file system copiato
A seconda della macchina di origine, il file system copiato potrebbe essere molto grande. Quanto più grande è la copia, più tempo occorre per completare ogni operazione e, se lo spazio non è sufficiente, l'operazione di copia non va a buon fine.
L'interfaccia a riga di comando Migrate to Containers applica filtri per ridurre le dimensioni della copia, ma con le conoscenze del componente dell'applicazione, puoi modificare i filtri per ridurre ulteriormente le dimensioni della copia.
Quando esegui di nuovo il comando copy con i filtri modificati, i contenuti della directory di output vengono aggiornati in base alle modifiche applicate nel file del filtro.
Per modificare i filtri predefiniti:
Per visualizzare un elenco dei filtri predefiniti:
./m2c copy default-filters > filters.txt
Modifica il file filters.txt per rimuovere le directory non pertinenti. Il file utilizza il formato della regola di filtro rsync, come specificato nella pagina della documentazione di rsync.
Utilizza il flag --filters per specificare il file del filtro con il comando copy.
Crea una copia locale del file system della macchina di origine Windows
Per le macchine di origine Windows, devi copiare le immagini dei dischi in formato VHD o VHDX per la procedura di migrazione. Tuttavia, l'interfaccia a riga di comando Migrate to Containers non supporta l'esportazione delle immagini disco dalla piattaforma di origine alla macchina locale.
Per esportare un disco di un'istanza di macchina virtuale (VM) Compute Engine, crea prima un'immagine dal disco e poi esporta l'immagine nella macchina locale.
Per esportare un'immagine da Compute Engine, svolgi i seguenti passaggi:
Per esportare le immagini dei dischi delle VM VMware, completa prima i passaggi per
esportare un'immagine in un file VMDK. Poi, converti il file VMDK in un file VHD utilizzando strumenti di terze parti come qemu-img.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-09-04 UTC."],[],[],null,["# Copy the source machine's file system\n=====================================\n\nModernization of an application component requires\ncreating a copy of the source machine's file system.\n\nThis page describes the steps required to copy the source machine's file system\nalong with some specifications for reducing the size of the copied file system.\n\nCreate a local copy of the Linux source machine file system\n-----------------------------------------------------------\n\nThe Migrate to Containers CLI supports access to source machines using either direct\nSSH connection or by using `gcloud`.\n**Note:** The user that you use to access the source machine must be a sudoer to be able to access all files and directories relevant to modernization. If sudo is disabled for all users including root, use the root user and use the flag `--remote-sudo=false`. \n\n### Direct SSH\n\nTo copy using direct SSH access, run the following command: \n\n ./m2c copy ssh [\u003cvar translate=\"no\"\u003eUSERNAME\u003c/var\u003e@]\u003cvar translate=\"no\"\u003eHOSTNAME\u003c/var\u003e \\\n -i \u003cvar translate=\"no\"\u003ePATH_TO_PRIVATE_KEY\u003c/var\u003e \\\n -o \u003cvar translate=\"no\"\u003eOUTPUT_FILESYSTEM_DIR\u003c/var\u003e\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eUSERNAME\u003c/var\u003e: your username\n- \u003cvar translate=\"no\"\u003eHOSTNAME\u003c/var\u003e: the hostname\n- \u003cvar translate=\"no\"\u003ePATH_TO_PRIVATE_KEY\u003c/var\u003e: the path to private key\n- \u003cvar translate=\"no\"\u003eOUTPUT_FILESYSTEM_DIR\u003c/var\u003e: the path for the output directory on your local machine where you want to copy the source machine's file system\n\n### gcloud\n\nIf the source machine has a public IP, run the following command: \n\n ./m2c copy gcloud \\\n -p \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e \\\n -z \u003cvar translate=\"no\"\u003eZONE\u003c/var\u003e \\\n -n \u003cvar translate=\"no\"\u003eVM_NAME\u003c/var\u003e \\\n -o \u003cvar translate=\"no\"\u003eOUTPUT_FILESYSTEM_DIR\u003c/var\u003e\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: the project ID\n- \u003cvar translate=\"no\"\u003eZONE\u003c/var\u003e: the zone of your VM\n- \u003cvar translate=\"no\"\u003eVM_NAME\u003c/var\u003e: the name of the source VM\n- \u003cvar translate=\"no\"\u003eOUTPUT_FILESYSTEM_DIR\u003c/var\u003e: the path for the directory output on your local machine where you want to copy the source machine's file system\n\nIf the source machine doesn't have a public IP, you can do one of the following:\n\n- If you are running the Migrate to Containers CLI from a machine in the same internal network, Use the `--internal-ip` flag.\n- If you are running on a different network, use the `--tunnel-through-iap` flag.\n\nFor more information about these flags, see the\n[gcloud documentation](/sdk/gcloud/reference/compute/ssh#:%7E:text=can%20be%20specified%3A-,%2D%2Dinternal%2Dip,-Connect%20to%20instances).\n\nAfter the copy is complete, a copy of the source machine's file system is\navailable in the specified output directory.\n\n### Reduce the size of the copied file system\n\nDepending on the source machine, the copied file system might be very large. The\nlarger the copy, the longer it takes for each operation to complete and, if\nthere's not enough space, the copy operation fails.\n\nThe Migrate to Containers CLI applies filters to reduce the size of the copy,\nbut with the given knowledge of the application component, you can modify the\nfilters to further reduce the size of the copy.\n\nWhen you run the `copy` command again with the modified filters, the contents of\nthe output directory are updated according to the changes you applied in the\nfilter file.\n\nTo modify the default filters, follow these steps:\n\n1. Get a list of the default filters:\n\n ./m2c copy default-filters \u003e filters.txt\n\n2. Edit the file `filters.txt` to remove irrelevant directories. The file uses\n the `rsync` filter rule format, as specified in the [`rsync` documentation page](https://linux.die.net/man/1/rsync#Filter%20Rules).\n\n3. Use the `--filters` flag to specify the filter file with the `copy` command.\n\n ### Direct SSH\n\n ./m2c copy ssh [\u003cvar translate=\"no\"\u003eUSERNAME\u003c/var\u003e@]\u003cvar translate=\"no\"\u003eHOSTNAME\u003c/var\u003e \\\n -i \u003cvar translate=\"no\"\u003ePATH_TO_PRIVATE_KEY\u003c/var\u003e \\\n -o \u003cvar translate=\"no\"\u003eOUTPUT_FILESYSTEM_DIR\u003c/var\u003e \\\n --filters filters.txt\n\n ### gcloud\n\n ./m2c copy gcloud \\\n -p \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e \\\n -z \u003cvar translate=\"no\"\u003eZONE\u003c/var\u003e \\\n -n \u003cvar translate=\"no\"\u003eVM_NAME\u003c/var\u003e \\\n -o \u003cvar translate=\"no\"\u003eOUTPUT_FILESYSTEM_DIR\u003c/var\u003e \\\n --filters filters.txt\n\nCreate a local copy of the Windows source machine file system\n-------------------------------------------------------------\n\nFor Windows source machines, you need to copy the disk images in VHD or VHDX\nformat for the migration process. However, Migrate to Containers CLI does not support\nexporting disk images from your source platform to your local machine.\n\n- To export a Compute Engine virtual machine (VM) instance disk, first\n [create an image from the disk](/compute/docs/instances/windows/creating-windows-os-image)\n and then export the image to the local machine.\n\n- To export an image from Compute Engine, perform the following steps:\n\n 1. Export the image to Cloud Storage using the [`gcloud compute images export` command](/sdk/gcloud/reference/compute/images/export):\n\n ```\n gcloud compute images export \\\n --export-format vhdx \\\n --destination-uri DESTINATION_URI \\\n --image IMAGE_NAME\n ```\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eDESTINATION_URI\u003c/var\u003e: the Cloud Storage URI destination for the exported image file.\n - \u003cvar translate=\"no\"\u003eIMAGE_NAME\u003c/var\u003e: the name of the disk image to export.\n 2. Download the image on your local machine:\n\n ```\n gcloud storage cp DESTINATION_URI LOCAL_PATH\n ```\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eDESTINATION_URI\u003c/var\u003e: the Cloud Storage URI destination of the exported image file\n - \u003cvar translate=\"no\"\u003eLOCAL_PATH\u003c/var\u003e: the path to the local folder where you want to download the image\n\n For more information, see [Export a custom image to Cloud Storage](/compute/docs/images/export-image).\n- For more information on exporting Amazon EC2 images, see\n [Exporting an instance as a VM using VM Import/Export](https://docs.aws.amazon.com/vm-import/latest/userguide/vmexport.html).\n\n | **Note:** When you create the JSON file for exporting an image, omit the `ContainerFormat` field, and set `DiskImageFormat` to `\"VHD\"`.\n- For more information on exporting Azure Cloud Compute images, see\n [Download a Windows VHD from Azure](https://learn.microsoft.com/en-us/azure/virtual-machines/windows/download-vhd?tabs=azure-portal).\n\n- To export VMware VM disk images, first complete the steps to\n [export an image to a VMDK file](https://docs.vmware.com/en/VMware-vSphere/7.0/com.vmware.vsphere-lifecycle-manager.doc/GUID-A3E9D4BA-CAAC-4F2C-B97F-C0904ECE5E14.html). Then, convert the VMDK file to\n a VHD file using third-party tools such as [qemu-img](https://cloudbase.it/qemu-img-windows/).\n\nWhat's next\n-----------\n\n- Learn how to [create a migration plan](/migrate/containers/docs/m2c-cli/create-a-migration-plan)."]]