Skip to main content

Cross-platform disk image mounting — strategy selector (sudo losetup, udisksctl, guestmount, hdiutil)

Project description

mount-image

PyPI version Python License OS

CI codecov

Downloads total Downloads/month Downloads/week

Cross-platform disk image mounting via loop devices (Linux) or hdiutil (macOS).

Features

  • mount_image — attach a disk image as a loop device and mount it: Linux uses losetup + mount, macOS uses hdiutil attach + mount
  • umount_image — unmount and detach a disk image
  • attach_image — attach a disk image as a block device without mounting (for raw block I/O)
  • detach_image — detach a raw block device

Quick start

from mount_image import mount_image, umount_image

# Mount a disk image
device, mount_point = mount_image('/path/to/disk.img')
print(f'Mounted {device} at {mount_point}')

# ... do work with the mounted filesystem ...

# Unmount and detach
umount_image(device, mount_point)

Raw device access (no mount)

from mount_image import attach_image, detach_image

dev = attach_image('/path/to/disk.img')
# Read/write raw blocks via /dev/loop0 or /dev/disk5
detach_image(dev)

Note: All functions require sudo for losetup/mount (Linux) or hdiutil/mount (macOS).

License

GPL-3.0-only

Project details


Download files

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

Source Distribution

mount_image-0.5.0.tar.gz (19.5 kB view details)

Uploaded Source

Built Distribution

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

mount_image-0.5.0-py3-none-any.whl (16.7 kB view details)

Uploaded Python 3

File details

Details for the file mount_image-0.5.0.tar.gz.

File metadata

  • Download URL: mount_image-0.5.0.tar.gz
  • Upload date:
  • Size: 19.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mount_image-0.5.0.tar.gz
Algorithm Hash digest
SHA256 52101c622d879152023b71722a01fe3fe5c509774dbe8b9d8c08eeaf4046456b
MD5 9f8aab69650271470d88d2ea7088d224
BLAKE2b-256 7ae24483f685d132a820255463a8cda0f30f0dcbfba6fc6e403e3372e5f0d519

See more details on using hashes here.

Provenance

The following attestation bundles were made for mount_image-0.5.0.tar.gz:

Publisher: publish.yml on MBanucu/mount-image

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mount_image-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: mount_image-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 16.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mount_image-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ab4ae0c2bf2fae0629af9caddf3068ff6c2ceeea12027fa12de71e7185fbbe00
MD5 38cf26855d3d0d2c41053322d0658429
BLAKE2b-256 c80f5a525f1c9a6df908457e3f20abe360d62b805140387aa99a8832f212483f

See more details on using hashes here.

Provenance

The following attestation bundles were made for mount_image-0.5.0-py3-none-any.whl:

Publisher: publish.yml on MBanucu/mount-image

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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