Closed FluffyPanda69 closed 10 months ago
Thank you fore creating an issue! :)
This has actually been on my mind since I created the script, it is just that nobody has ever complained about it so I never dealt with it, the loop is hardcoded.
Let me look if I can just do a normal losetup that sets the next free loop instead and set that to the variable. I will do these changes on the testing branch and will let you know when they are ready for you.
It should work with the testing branch now, BUT I would honestly recommend you to just change the line in the script yourself because I will not push testing to stable since I am still working with the btrfs functionality there and it quite frankly is a mess. The script will work, but I think it is better you do edit line 267 in your shrink-backup
- LOOP='/dev/loop0'
+ LOOP=$(losetup -f)
Please let me know if it fixed it for you. :)
Edit I just realized, more changes needed.
So, I still recommend you do the changes yourself until I have pushed them to stable instead of using testing as of now (there might be bugs since I mess around with btrfs there) And it might take a while before a new version will become available on stable, I simply do not have much time right now. :(
Line 52:
- if losetup /dev/loop0 &>/dev/null; then
+ if losetup "$LOOP" &>/dev/null; then
- losetup -d /dev/loop0
+ losetup -d "$LOOP"
- debug 'DEBUG' 'Removing loop0 in cleanup function: losetup -d /dev/loop0'
+ debug 'DEBUG' "Removing loop in cleanup function: losetup -d $LOOP"
fi
- if losetup /dev/loop1 &>/dev/null; then
- losetup -d /dev/loop1
- debug 'DEBUG' 'Removing loop1 in cleanup function: losetup -d /dev/loop1'
- fi
Line 267:
- LOOP='/dev/loop0'
+ LOOP=$(losetup -f)
debug 'DEBUG' "LOOP=$LOOP"
if [ $(lsblk | grep -c 'boot') -ne 0 ]; then
debug 'INFO' 'Separate boot partition detected'
debug 'DEBUG' "Running: cat /etc/fstab | grep '/boot' | awk '{print \$2}'"
BOOT_PATH=$(cat /etc/fstab | grep '/boot' | awk '{print $2}')
- IMG_DEV_BOOT_PATH='/dev/loop0p1'
+ IMG_DEV_BOOT_PATH="${LOOP}p1"
- IMG_DEV_ROOT_PATH='/dev/loop0p2'
+ IMG_DEV_ROOT_PATH="${LOOP}p2"
debug 'DEBUG' "BOOT_PATH=$BOOT_PATH | IMG_DEV_BOOT_PATH=$IMG_DEV_BOOT_PATH | IMG_DEV_ROOT_PATH=$IMG_DEV_ROOT_PATH"
else
debug 'INFO' 'No boot partition detected'
- IMG_DEV_ROOT_PATH='/dev/loop0p1'
+ IMG_DEV_ROOT_PATH="${LOOP}p1"
debug 'DEBUG' "IMG_DEV_ROOT_PATH=$IMG_DEV_ROOT_PATH"
fi
Please let me know if it works. :)
Thanks for the quick answer and fix, this works perfectly!
Describe the bug The script simply assumes
/dev/loop0
is unused, which is not always the case, particularly on systems wheresnap
packages are installed.Changing the
LOOP
variable to something like/dev/loop999
along with settingIMG_DEV_BOOT_PATH
,IMG_DEV_ROOT_PATH
and cleanup parameters accordingly does fix the problem for me, but perhaps you'd like to implement a more elegant solution.Harware (please complete the following information):
Additional context shrink-backup.log