Skip to content

Instantly share code, notes, and snippets.

@rayantony
Created November 26, 2016 03:16
Show Gist options
  • Save rayantony/a5ce778dec4f72b662cf048dd628173f to your computer and use it in GitHub Desktop.
Save rayantony/a5ce778dec4f72b662cf048dd628173f to your computer and use it in GitHub Desktop.
Disk Mounting Cheatsheet

#Disk Mounting

Disk Mounting cheatsheet

method 1: assign available loop device to image then mount

sudo losetup /dev/loop1
sudo losetup /dev/loop1 /media/KINGSTON/2GBMEXSD.img
sudo mount -t vfat /dev/loop1 /mnt/tmp/

dismount

sudo umount /dev/loop0                                                                        
sudo losetup -d /dev/loop0  

method 2: mutiply starting sector by 512 for offset and mount as loop

fdisk -u -l /opt/sdcardrecent.img
echo $((512*9510912))
sudo mount -o loop,offset=4869586944 /opt/sdcardrecent.img /mnt/sdimage/
lsa /mnt/sdimage

dismount

sudo umount /mnt/sdimage

from stackexchange: if your goal is to explore or modify the content of a partition (file system), this command line will mount the file system of the sd card dump my_sdcard_dump.img into the directory mount_dir.

part_id=2; INFILE=my_sdcard_dump.img; MOUNTPT=mount_dir PARTITION=${part_id}; sudo mount "$INFILE" "$MOUNTPT" -o loop,offset=$[ `/sbin/sfdisk -d "$INFILE" | grep "start=" | head -n $PARTITION | tail -n1 | sed 's/.*start=[ ]*//' | sed 's/,.*//'` * 512 ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment