Skip to content

Instantly share code, notes, and snippets.

@gtato
Created May 15, 2014 10:03
Show Gist options
  • Save gtato/616015afda175ab909c9 to your computer and use it in GitHub Desktop.
Save gtato/616015afda175ab909c9 to your computer and use it in GitHub Desktop.
Mounting and unmounting raw disk images which have one partition
#/dev/loop0 and /dev/loop1 are assumed to be free, otherwise use 'losetup -f' and store the result
losetup /dev/loop0 disk.img
kpartx -as /dev/loop0
losetup /dev/loop1 /dev/mapper/loop0p1
mkdir disk
mount /dev/loop1 disk
umount disk
losetup -d /dev/loop1
kpartx -ds /dev/loop0
losetup -d /dev/loop0
rmdir disk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment