{"id":21034638,"url":"https://github.com/lpenz/disk-img-tool","last_synced_at":"2026-02-08T09:05:27.174Z","repository":{"id":188046646,"uuid":"678005206","full_name":"lpenz/disk-img-tool","owner":"lpenz","description":"Resize, list/get/put files and shell into raw disk images, including Raspberry Pi OS release","archived":false,"fork":false,"pushed_at":"2024-09-28T11:57:06.000Z","size":40,"stargazers_count":2,"open_issues_count":6,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-27T17:48:29.797Z","etag":null,"topics":["disk-image","raspberry-pi"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lpenz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS","dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-08-13T11:31:32.000Z","updated_at":"2024-09-29T16:52:52.000Z","dependencies_parsed_at":"2023-12-13T23:29:29.366Z","dependency_job_id":"90e36150-91e5-427a-9293-eb1a3204c1b5","html_url":"https://github.com/lpenz/disk-img-tool","commit_stats":null,"previous_names":["lpenz/disk-img-tool"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/lpenz/disk-img-tool","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lpenz%2Fdisk-img-tool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lpenz%2Fdisk-img-tool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lpenz%2Fdisk-img-tool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lpenz%2Fdisk-img-tool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lpenz","download_url":"https://codeload.github.com/lpenz/disk-img-tool/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lpenz%2Fdisk-img-tool/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29225732,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-08T06:05:31.539Z","status":"ssl_error","status_checked_at":"2026-02-08T05:58:33.853Z","response_time":57,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["disk-image","raspberry-pi"],"created_at":"2024-11-19T13:07:48.786Z","updated_at":"2026-02-08T09:05:27.169Z","avatar_url":"https://github.com/lpenz.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![CI](https://github.com/lpenz/disk-img-tool/actions/workflows/ci.yml/badge.svg)](https://github.com/lpenz/disk-img-tool/actions/workflows/ci.yml)\n[![docs](https://readthedocs.org/projects/disk-img-tool/badge/?version=latest)](https://disk-img-tool.readthedocs.io/en/latest/?badge=latest)\n[![coveralls](https://coveralls.io/repos/github/lpenz/disk-img-tool/badge.svg?branch=main)](https://coveralls.io/github/lpenz/disk-img-tool?branch=main)\n[![PyPI](https://img.shields.io/pypi/v/disk-img-tool)](https://pypi.org/project/disk-img-tool/)\n[![github](https://img.shields.io/github/v/release/lpenz/disk-img-tool?logo=github)](https://github.com/lpenz/disk-img-tool/releases)\n\n\n# disk-img-tool\n\n**disk-img-tool** can be used to resize, list/get/put files and shell\ninto raw disk images, including Raspberry Pi OS release and other\nLinux releases.\n\n\n## Usage\n\n- `disk-img-tool [-v] *image* list`\n\n  List all files in image\n\n- `disk-img-tool [-v] *image* enter`\n\n  Start a shell inside the image\n\n- `disk-img-tool [-v] *image* get *source* *dest*`\n\n  Get a file *source* from the image and write it to *dest* in the\n  outer filesystem.\n\n- `disk-img-tool [-v] *image* put *source* *dest*`\n\n  Put a file *source* from the outer filesystem into the image,\n  writing it to the path *dest*.\n\n\n## Examples using the Raspberry Pi OS image\n\nFor the sake of having an example, we can download one of the\ninstallation images from the\n[Raspbery Pi download page](https://www.raspberrypi.com/software/operating-systems)\nand decompress it with `xz -d raspios-bullseye-arm64.img.xz`. That\nleaves us with a *raspios-bullseye-arm64.img* file that we can then\nuse with the commands below.\n\nIn fact, the Raspberry Pi OS supports the injection of a `custom.toml`\nfile into its installation media which allows us to define the\nhostname, initial user with ssh public keys, wlan configuration,\netc. Here's a sample with more documentation: [`custom.toml`]\n\nNote: most of these need *sudo* to work due to the need to *mount*\ndirectories. We can use the `-v` flag before the image name to ask the\ntool to print all commands used.\n\n- List files in the image's inner filesystem:\n  ```sh\n  $ sudo disk-img-tool raspio-bullseye-arm64.img list\n        661      4 -rw-r--r--   1 root     root           12 May  3 03:53 ./etc/hostname\n  ...\n  ```\n- \"Enter\" the image - i.e. mount its filesystem, chroot to it and start a shell:\n  ```\n  $ sudo disk-img-tool -v raspio-bullseye-arm64.img enter\n  diskimgtool: + kpartx -a -v raspio-bullseye-arm64.img\n  diskimgtool:   add map loop0p1 (254:0): 0 524288 linear 7:0 8192\n  diskimgtool:   add map loop0p2 (254:1): 0 3571712 linear 7:0 532480\n  diskimgtool: + mount -t auto /dev/mapper/loop0p2 $PWD/tmp1vxc8gvg\n  diskimgtool: + mount -t auto /dev/mapper/loop0p1 $PWD/tmp1vxc8gvg/boot\n  diskimgtool: + mount -t devtmpfs dev $PWD/tmp1vxc8gvg/dev\n  diskimgtool: + mount -t devpts devpts $PWD/tmp1vxc8gvg/dev/pts\n  diskimgtool: + mount -t tmpfs tmpfs $PWD/tmp1vxc8gvg/dev/shm\n  diskimgtool: + mount -t proc proc $PWD/tmp1vxc8gvg/proc\n  diskimgtool: + mount -t sysfs sysfs $PWD/tmp1vxc8gvg/sys\n  diskimgtool: + mount -t tmpfs tmpfs $PWD/tmp1vxc8gvg/run\n  diskimgtool: + mkdir -p $PWD/tmp1vxc8gvg/run/lock $PWD/tmp1vxc8gvg/run/shm\n  diskimgtool: + chroot $PWD/tmp1vxc8gvg /bin/bash -i\n  root@raspberrypi:/#\n  ```\n  (depends on proper qemu configuration)\n- Get a file from the image's inner filesystem:\n  ```\n  $ sudo disk-img-tool -v raspio-bullseye-arm64.img get /etc/hostname hostname\n  diskimgtool: + kpartx -a -v raspio-bullseye-arm64.img\n  diskimgtool:   add map loop0p1 (254:0): 0 524288 linear 7:0 8192\n  diskimgtool:   add map loop0p2 (254:1): 0 3571712 linear 7:0 532480\n  diskimgtool: + mount -t auto /dev/mapper/loop0p2 $PWD/tmp6e21wrf3\n  diskimgtool: + mount -t auto /dev/mapper/loop0p1 $PWD/tmp6e21wrf3/boot\n  diskimgtool: Getting /etc/hostname from image as hostname\n  diskimgtool: + umount $PWD/tmp6e21wrf3/boot\n  diskimgtool: + umount $PWD/tmp6e21wrf3\n  diskimgtool: + kpartx -d raspio-bullseye-arm64.img\n  diskimgtool: + sync\n  ```\n- Put a file in the image's inner filesystem:\n  ```\n  $ sudo disk-img-tool -v raspio-bullseye-arm64.img put custom.toml /boot/\n  ```\n\n\n## Installation\n\n\n### Releases\n\ndisk-img-tool can be installed via [pypi]:\n\n```\npip install disk-img-tool\n```\n\nFor [nix] users, it is also available as a [flake].\n\n\n### Repository\n\nWe can also clone the github repository and install disk-img-tool from it with:\n\n```\npip install .\n```\n\nWe can also install it for the current user only by running instead:\n\n```\npip install --user .\n```\n\n\n## Development\n\ndisk-img-tool uses the standard python3 infra. To develop and test the module:\n- Clone the repository and go into the directory:\n  ```\n  git clone git@github.com:lpenz/disk-img-tool.git\n  cd disk-img-tool\n  ```\n- Use [`venv`] to create a local virtual environment with\n  ```\n  python -m venv venv\n  ```\n- Activate the environment by running the shell-specific `activate`\n  script in `./venv/bin/`. For [fish], for instance, run:\n  ```\n  source ./venv/bin/activate.fish\n  ```\n- Install disk-img-tool in \"editable mode\":\n  ```\n  pip install -e '.[test]'\n  ```\n- To run the tests:\n  ```\n  pytest\n  ```\n  Or, to run the tests with coverage:\n  ```\n  pytest --cov\n  ```\n- To generate the documentaion:\n  ```\n  pip install -r docs/requirements.txt\n  sphinx-build -b html docs/ _docs\n  ```\n  And open *_docs/index.html* in a browser.\n- Finally, to exit the environment and clean it up:\n  ```\n  deactivate\n  rm -rf venv\n  ```\n\n\n[pypi]: https://pypi.org/project/disk-img-tool/\n[nix]: https://nixos.org/\n[flake]: https://nixos.wiki/wiki/Flakes\n[`venv`]: https://docs.python.org/3/library/venv.html\n[`custom.toml`]: https://gist.github.com/lpenz/ef21bb38a7aa12ebde17fa719a8546b5\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flpenz%2Fdisk-img-tool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flpenz%2Fdisk-img-tool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flpenz%2Fdisk-img-tool/lists"}