Skip to main content

GPT Image

Create GUID Partition Table disk images on local disks. Written in pure Python gpt-image allows GPT disk images to be built on a local filesystem and exported to a destination device.

This is useful for creating a disk image on SD Cards or embedded devices.

Quick Start

import gpt_image

# create a new, 16 MB disk, size is in bytes
disk = gpt_image.disk.Disk("disk-image.raw")
disk.create(16 * 1024 * 1024)

# create a 2MB Linux partition named "boot"
boot_part = gpt_image.partition.Partition(
		"boot", 
		2 * 1024 * 1024, 
		gpt_image.partition.Partition.EFI_SYSTEM_PARTITION
	)
disk.table.partitions.add(boot_part)

# create an 8MB Linux partition named "data"
data_part = gpt_image.partition.Partition(
		"data", 
		8 * 1024 * 1024, 
		gpt_image.partition.Partition.LINUX_FILE_SYSTEM
	)
disk.table.partitions.add(data_part)

# commit the change to disk
disk.write()

# dump the current GPT information:

print(disk)

The final print(disk) command will output a JSON document of the current GPT configuration:

{
  "path": "disk-image.raw",
  "image_size": 16777216,
  "sector_size": 512,
  "primary_header": {
    "backup": false,
    "signature": "EFI PART",
    "revision": "\u0000\u0000\u0001\u0000",
    "header_size": 92,
    "header_crc32": 3533962731,
    "reserved": 0,
    "my_lba": 1,
    "alternate_lba": 32767,
    "first_usable_lba": 34,
    "last_usable_lba": 32734,
    "disk_guid": "3f09c9fe-66ea-4c67-b0fb-fd35906b393a",
    "partition_entry_lba": 2,
    "number_of_partition_entries": 128,
    "size_of_partition_entries": 128,
    "partition_entry_array_crc32": 673632436
  },
  "backup_header": {
    "backup": true,
    "signature": "EFI PART",
    "revision": "\u0000\u0000\u0001\u0000",
    "header_size": 92,
    "header_crc32": 727034965,
    "reserved": 0,
    "my_lba": 32767,
    "alternate_lba": 1,
    "first_usable_lba": 34,
    "last_usable_lba": 32734,
    "disk_guid": "3f09c9fe-66ea-4c67-b0fb-fd35906b393a",
    "partition_entry_lba": 32735,
    "number_of_partition_entries": 128,
    "size_of_partition_entries": 128,
    "partition_entry_array_crc32": 673632436
  },
  "partitions": [
    {
      "type_guid": "C12A7328-F81F-11D2-BA4B-00A0C93EC93B",
      "partition_name": "boot",
      "partition_guid": "67ed0675-9d44-46a6-bc29-99a2778e7563",
      "first_lba": 40,
      "last_lba": 4135,
      "alignment": 8,
      "size": 2097152,
      "attribute_flags": []
    },
    {
      "type_guid": "0FC63DAF-8483-4772-8E79-3D69D8477DE4",
      "partition_name": "data",
      "partition_guid": "1a44bc84-bb53-4f9f-b699-1d1268bfdbfa",
      "first_lba": 4136,
      "last_lba": 20519,
      "alignment": 8,
      "size": 8388608,
      "attribute_flags": []
    }
  ]
}

MIT License

Copyright (c) 2021 Scott Wysocki

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gpt-image-0.6.6.tar.gz (13.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gpt_image-0.6.6-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

Details for the file gpt-image-0.6.6.tar.gz.

File metadata

  • Download URL: gpt-image-0.6.6.tar.gz
  • Upload date:
  • Size: 13.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.3 readme-renderer/35.0 requests/2.28.1 requests-toolbelt/0.9.1 urllib3/1.26.11 tqdm/4.64.0 importlib-metadata/4.12.0 keyring/23.7.0 rfc3986/2.0.0 colorama/0.4.5 CPython/3.9.13

File hashes

Hashes for gpt-image-0.6.6.tar.gz
Algorithm Hash digest
SHA256 16adae7eda6e8fcc34231cb9ce6b61954187d533f8740a0184bee135fc693de8
MD5 17028f3c3f87d26a990ffd724ef3ae4b
BLAKE2b-256 6e7ca25e5002767a3f22eede4b6b0e11500359859065aac62aa04e3eca60e722

See more details on using hashes here.

File details

Details for the file gpt_image-0.6.6-py3-none-any.whl.

File metadata

  • Download URL: gpt_image-0.6.6-py3-none-any.whl
  • Upload date:
  • Size: 11.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.3 readme-renderer/35.0 requests/2.28.1 requests-toolbelt/0.9.1 urllib3/1.26.11 tqdm/4.64.0 importlib-metadata/4.12.0 keyring/23.7.0 rfc3986/2.0.0 colorama/0.4.5 CPython/3.9.13

File hashes

Hashes for gpt_image-0.6.6-py3-none-any.whl
Algorithm Hash digest
SHA256 f89e8d2b21d0a2e6624c7718a788b7e8411b494b2453d9997305ceec6d80f415
MD5 af078a8d22187c99aa89853e51f8d781
BLAKE2b-256 f9af2395b3eb6ae0ad7fb589e378beecfd4933933d34ebe8f9ae464faa5fceb7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page