Skip to content

Instantly share code, notes, and snippets.

@jowagner
Last active January 16, 2023 14:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jowagner/b36024636140ddf453c12eaf6e590b5d to your computer and use it in GitHub Desktop.
Save jowagner/b36024636140ddf453c12eaf6e590b5d to your computer and use it in GitHub Desktop.
Make snapshot of non-busy block device with device mapper in Linux
NAME=nameofsnapshot
DEVRO=/dev/read-only-backing-device
DEVCOW=/dev/space-for-writing-changes
SECTORS=$(blockdev --getsz $DEVRO)
TABLE=$(mktemp)
echo 0 $SECTORS snapshot $DEVRO $DEVCOW N 16 >> $TABLE
echo "Setting up $NAME with"
head $TABLE
dmsetup create $NAME < $TABLE
rm $TABLE
@jowagner
Copy link
Author

Thanks for reporting the issue. Trying it with and without mounting the backing device I get the same error message when the device is mounted, suggesting that dmsetup create cannot use mounted block devices. "Busy" probably also applies to other scenarios such as the backing device being part of an active software RAID. Will update the description.

@hwk
Copy link

hwk commented Dec 22, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment