Skip to content

Instantly share code, notes, and snippets.

@schwabix
Created June 6, 2017 07:57
Show Gist options
  • Select an option

  • Save schwabix/6f36bc1a5e2707a32a6fd4d433f5533b to your computer and use it in GitHub Desktop.

Select an option

Save schwabix/6f36bc1a5e2707a32a6fd4d433f5533b to your computer and use it in GitHub Desktop.
#!/bin/sh
losetup -f
# output eg. /dev/loop0
losetup /dev/loop0 my-image-file.img # link image file with loop drive
kpartx -av /dev/loop0 # creates lvm drives for partitions
mount /dev/mapper/loop0p1 /mnt/image # for first partition
# unmount
unmount /mnt/image
kpartx -dv /dev/loop0
losetup -d /dev/loop0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment