github.com/GoogleCloudPlatform/compute-image-tools/cli_tools@v0.0.0-20240516224744-de2dabc4ed1b/gce_export/README.md (about)

     1  ## Compute Engine Image Export
     2  
     3  The `gce_export` tool streams a local disk to a Google Compute Engine image 
     4  file in a Google Cloud Storage bucket (steps 9 and 10 in the
     5  [image export documentation](https://cloud.google.com/compute/docs/images/export-image)).
     6  When exporting to GCS, no local file is created so no additional disk space needs to be allocated. 
     7  Once complete the image file can be imported in GCE as described in the 
     8  [image import documentation](https://cloud.google.com/compute/docs/images/import-existing-image).
     9  
    10  This tool can also be used to export the image to local disk.
    11  
    12  ### Build
    13  Download and install [Go](https://golang.org/doc/install). Then pull and 
    14  install the `gce_export` tool, this should place the binary in the 
    15  [Go bin directory](https://golang.org/doc/code.html#GOPATH):
    16  
    17  ```
    18  go get github.com/GoogleCloudPlatform/compute-image-tools/cli_tools/gce_export
    19  ```
    20  
    21  ### Flags
    22  
    23  + `-disk` disk to export, on linux this would be something like `/dev/sdb`, and on
    24  Windows `\\.\PhysicalDrive1`
    25  + `-buffer_prefix` if set will use this local path as the local buffer prefix, on linux this would
    26  be something like `/my_folder`, and on Windows `\\.\PhysicalDrive2\path`.
    27  + `-gcs_path` GCS path to upload the image to, in the form of gs://my-bucket/image.tar.gz
    28  + `-oauth` path to oauth json file for authenticating to the GCS bucket
    29  + `-licenses` (optional) comma separated list of licenses to add to the image
    30  + `-y` skip confirmation prompt
    31  
    32  ### Usage
    33  
    34  While you can export a disk with currently mounted partitions, or even the disk
    35  containing the current root partition it is recommended to unmount all partitions
    36  prior to running `gce_export`.
    37  
    38  #### Linux:
    39  
    40  This will stream `/dev/sdb` to the GCS path gs://some-bucket/linux.tar.gz
    41  
    42  ```
    43  gce_export -disk /dev/sdb -gcs_path gs://some-bucket/linux.tar.gz
    44  ```
    45  
    46  This will stream `/dev/sdb` to the local path /my_folder/linux.tar.gz
    47  
    48  ```
    49  gce_export -disk /dev/sdb -local_path /my_folder/linux.tar.gz
    50  ```
    51  
    52  #### Windows:
    53  
    54  This will stream `\\.\PhysicalDrive1` to the GCS path
    55  gs://some-bucket/path/windows.tar.gz
    56  
    57  ```
    58  gce_export.exe -disk \\.\PhysicalDrive1 -gcs_path gs://some-bucket/windows.tar.gz
    59  ```
    60  
    61  This will stream `\\.\PhysicalDrive1` to the local path
    62  `\\.\PhysicalDrive2\path\windows.tar.gz`
    63  
    64  ```
    65  gce_export.exe -disk \\.\PhysicalDrive1 -local_path \\.\PhysicalDrive2\path\windows.tar.gz
    66  ```
    67