Skip to content

Instantly share code, notes, and snippets.

@tomty89
Created June 21, 2021 06:40
Show Gist options
  • Save tomty89/d00ceba86e7437a017bea35cb8df3390 to your computer and use it in GitHub Desktop.
Save tomty89/d00ceba86e7437a017bea35cb8df3390 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e
gpt=$(losetup -f --show /home/$SUDO_USER/$1/gpt.img)
sed "s/\/dev\/loop0/${gpt//\//\\\/}/" /home/$SUDO_USER/$1/table | dmsetup create $1
setfacl -m u:tom:rw /dev/mapper/$1
#!/bin/bash
set -e
loopdev=/dev/$(dmsetup deps -o devname /dev/mapper/$1 | grep -o 'loop[0-9]*')
dmsetup remove $1
losetup -d $loopdev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment