Skip to content

Instantly share code, notes, and snippets.

@carepack
Forked from gtato/mount.sh
Created March 24, 2020 21:57
Show Gist options
  • Save carepack/9e6857db3f4aa20cf5fc875e47778419 to your computer and use it in GitHub Desktop.
Save carepack/9e6857db3f4aa20cf5fc875e47778419 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