Mount and edit SD card image with ext4 partitions on Mac using Docker
source link: https://gist.github.com/svet-b/6453f9eee38791cfb42f779343be82c6
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Mount and edit SD card image with ext4 partitions on Mac using Docker · GitHub
Instantly share code, notes, and snippets.
Save svet-b/6453f9eee38791cfb42f779343be82c6 to your computer and use it in GitHub Desktop.
Go to the directory with the image you want to work with. Run a Docker container with that directory mounted:
docker run -it --privileged -v /dev:/dev -v (pwd):/tmp --workdir /tmp ubuntu bash
(replace (pwd)
with "$PWD"
if using bash instead of fish)
See this thread for an explanation of why --privileged
and -v /dev:/dev
are required. The need for the latter can be avoided with this alrternative workaround.
In the container, assuming that $IMAGE_FILE
is the name of your image file:
losetup -Pf --show $IMAGE_FILE
will output the name of the loop device with which the image is associated, e.g. /dev/loop0
.
ls /dev/loop0*
should show all the partitions contained in the image file.
You can mount these and access the files with e.g.
mkdir p1
mount /dev/loop0p1 p1
Note that the partition contents will only be accessible inside the Docker container, and not on the host (i.e. across Docker's volume map).
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK