Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Menyalin sistem file mesin sumber
Modernisasi komponen aplikasi memerlukan
pembuatan salinan sistem file mesin sumber.
Halaman ini menjelaskan langkah-langkah yang diperlukan untuk menyalin sistem file mesin sumber
bersama dengan beberapa spesifikasi untuk mengurangi ukuran sistem file yang disalin.
Membuat salinan lokal sistem file mesin sumber Linux
CLI Migrate to Containers mendukung akses ke mesin sumber menggunakan koneksi SSH langsung atau menggunakan gcloud.
SSH Langsung
Untuk menyalin menggunakan akses SSH langsung, jalankan perintah berikut:
OUTPUT_FILESYSTEM_DIR: jalur untuk output direktori
di komputer lokal tempat Anda ingin menyalin sistem file
mesin sumber
Jika mesin sumber tidak memiliki IP publik, Anda dapat melakukan salah satu tindakan berikut:
Jika Anda menjalankan CLI Migrate to Containers dari komputer di jaringan internal yang sama, gunakan flag --internal-ip.
Jika Anda menjalankan di jaringan lain, gunakan flag
--tunnel-through-iap.
Untuk mengetahui informasi selengkapnya tentang flag ini, lihat
dokumentasi gcloud.
Setelah penyalinan selesai, salinan sistem file mesin sumber
tersedia di direktori output yang ditentukan.
Mengurangi ukuran sistem file yang disalin
Bergantung pada mesin sumber, sistem file yang disalin mungkin sangat besar. Makin besar salinan, makin lama waktu yang diperlukan untuk menyelesaikan setiap operasi dan, jika tidak ada cukup ruang, operasi salinan akan gagal.
CLI Migrate to Containers menerapkan filter untuk mengurangi ukuran salinan,
tetapi dengan pengetahuan yang diberikan tentang komponen aplikasi, Anda dapat mengubah
filter untuk lebih mengurangi ukuran salinan.
Saat Anda menjalankan perintah copy lagi dengan filter yang diubah, konten
direktori output akan diperbarui sesuai dengan perubahan yang Anda terapkan di
file filter.
Untuk mengubah filter default, ikuti langkah-langkah berikut:
Dapatkan daftar filter default:
./m2c copy default-filters > filters.txt
Edit file filters.txt untuk menghapus direktori yang tidak relevan. File ini menggunakan format aturan filter rsync, seperti yang ditentukan di halaman dokumentasi rsync.
Gunakan flag --filters untuk menentukan file filter dengan perintah copy.
Membuat salinan lokal sistem file mesin sumber Windows
Untuk mesin sumber Windows, Anda perlu menyalin image disk dalam format VHD atau VHDX
untuk proses migrasi. Namun, CLI Migrate to Containers tidak mendukung ekspor image disk dari platform sumber ke komputer lokal.
Untuk mengekspor disk instance virtual machine (VM) Compute Engine, pertama-tama
buat image dari disk,
lalu ekspor image ke mesin lokal.
Untuk mengekspor image dari Compute Engine, lakukan langkah-langkah berikut:
Untuk mengekspor image disk VM VMware, selesaikan langkah-langkah untuk
mengekspor image ke file VMDK terlebih dahulu. Kemudian, konversikan file VMDK menjadi file VHD menggunakan alat pihak ketiga seperti qemu-img.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-08-19 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)."]]