Last active
January 16, 2023 14:32
-
-
Save jowagner/b36024636140ddf453c12eaf6e590b5d to your computer and use it in GitHub Desktop.
Make snapshot of non-busy block device with device mapper in Linux
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Hi,
I tried this recipe (and many more from the net) but I get always the same error:
"device-mapper: reload ioctl on snap-sdb1 (253:0) failed: Device or resource busy
Command failed."
and "dmsetup status" says "No devices found". This is on a debian11 VirtualBox PC.
As always: any help appreciated, Hans
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.
Hi Joachim,
thank's a lot, it now works.
Kind regards & seasons greetings, Hans
On 21.12.2022 14:23, Joachim Wagner wrote:
@jowagner commented on this gist.
-------------------------
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.
--
Reply to this email directly, view it on GitHub [1] or unsubscribe [2].
You are receiving this email because you commented on the thread.
Triage notifications on the go with GitHub Mobile for iOS [3] or
Android [4].
Links:
------
[1]
https://gist.github.com/b36024636140ddf453c12eaf6e590b5d#gistcomment-4409784
[2]
https://github.com/notifications/unsubscribe-auth/AAGQM4K5QXJQRL7XZLT2G2LWOMAFLBFKMF2HI4TJMJ2XIZLTSKBKK5TBNR2WLJDHNFZXJJDOMFWWLK3UNBZGKYLEL52HS4DFQKSXMYLMOVS2I5DSOVS2I3TBNVS3W5DIOJSWCZC7OBQXE5DJMNUXAYLOORPWCY3UNF3GS5DZVRZXKYTKMVRXIX3UPFYGLK2HNFZXIQ3PNVWWK3TUUZ2G64DJMNZZDAVEOR4XAZNEM5UXG5FFOZQWY5LFVEYTCMRYGE4TINZWU52HE2LHM5SXFJTDOJSWC5DF
[3]
https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675
[4]
https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
N = not persistent, will not survive reboot
16 = chunk size in sectors for CoW, here 8 KiB
Query status:
dmsetup status $NAME
Remove snapshot:
dmsetup remove $NAME
The backing device must not be "busy". Testing confirms this includes "mounted" but may also include other uses such as being an active PV of LVM, opened with
cryptsetup
or a MD RAID member.References: