Created
September 7, 2018 07:58
-
-
Save thizmo/20470f94e5c81d30e19ff8bdb4681ec0 to your computer and use it in GitHub Desktop.
How to create and mount an SD-Card image with dd
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# 07.09.2018 | |
# Can be used a script or just as cli-oneliner | |
# First declare some variables | |
SDCARD=/path/to/sd-card | |
#[Example: SDCARD=/dev/mmcblk0] | |
IMG=/path/to/your/image | |
#[Example: IMG=/home/user1/my-sdcard.img] | |
MTP=/path/to/your/mountpoint | |
#[Example: MTP=/media/mountpoint] | |
#[Hint: Needs to be there already] | |
## Now the script/oneliner itself | |
# Create the complete image with all partitions | |
[sudo] dd if=${SDCARD} of=${IMG} | |
# Show the details of the partitions | |
[sudo] parted ${IMG} unit s print | |
# Calulate the offset for the loop mount | |
# Use Start Value, here as example was/is (8192s) * 512 | |
# Mount the partition as loop device | |
[sudo] mount -o loop,offset=4194304 ${IMG} ${MTP} | |
# Go to the mount partition | |
[sudo] cd ${MTP} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment