Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Dateisystem der Quellmaschine kopieren
Für die Modernisierung einer Anwendungskomponente muss eine Kopie des Dateisystems der Quellmaschine erstellt werden.
Auf dieser Seite werden die Schritte beschrieben, die zum Kopieren des Dateisystems der Quellmaschine erforderlich sind. Außerdem werden einige Spezifikationen beschrieben, mit denen Sie die Größe des kopierten Dateisystems reduzieren können.
Lokale Kopie des Linux-Quelldateisystems erstellen
Die Migrate to Containers-Befehlszeile unterstützt den Zugriff auf Quellmaschinen über eine direkte SSH-Verbindung oder mithilfe von gcloud.
Direkter SSH-Zugriff
Führen Sie den folgenden Befehl aus, um mit direktem SSH-Zugriff zu kopieren:
Nach Abschluss des Kopiervorgangs ist im angegebenen Ausgabeverzeichnis eine Kopie des Dateisystems der Quellmaschine verfügbar.
Größe des kopierten Dateisystems reduzieren
Je nach Quellcomputer ist das kopierte Dateisystem möglicherweise sehr groß. Je größer der Kopiervorgang, desto länger dauert es, bis der Vorgang abgeschlossen ist. Wenn nicht genügend Speicherplatz vorhanden ist, schlägt der Kopiervorgang fehl.
Die Migrate to Containers-Befehlszeile wendet Filter an, um die Größe der Kopie zu reduzieren. Mit den vorhandenen Kenntnissen der Anwendungskomponente können Sie die Filter jedoch ändern, um die Größe der Kopie weiter zu reduzieren.
Wenn Sie den Befehl copy noch einmal mit den geänderten Filtern ausführen, wird der Inhalt des Ausgabeverzeichnisses entsprechend den Änderungen aktualisiert, die Sie in der Filterdatei angewendet haben.
So ändern Sie die Standardfilter:
Rufen Sie eine Liste der Standardfilter ab:
./m2c copy default-filters > filters.txt
Bearbeiten Sie die Datei filters.txt, um irrelevante Verzeichnisse zu entfernen. Die Datei verwendet das Filterregelformat rsync, wie auf der Dokumentationsseite rsync angegeben.
Verwenden Sie das Flag --filters, um die Filterdatei mit dem Befehl copy anzugeben.
Erstellen Sie eine lokale Kopie des Windows-Quelldateisystems der Maschine.
Bei Windows-Quellmaschinen müssen Sie die Laufwerk-Images im VHD- oder VHDX-Format für den Migrationsprozess kopieren. Das Migrate to Containers CLI unterstützt jedoch nicht den Export von Laufwerk-Images von Ihrer Quellplattform auf Ihren lokalen Computer.
Sie exportieren ein Compute Engine-VM-Instanzlaufwerk, indem Sie zuerst ein Image vom Laufwerk erstellen und es dann auf den lokalen Computer exportieren.
Führen Sie zuerst die Schritte zum Exportieren eines Images in eine VMDK-Datei aus, um VMware-VM-Laufwerk-Images zu exportieren. Konvertieren Sie die VMDK-Datei dann mithilfe von Drittanbietertools wie qemu-img in eine VHD-Datei.
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-08-31 (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)."]]