4

I'm trying to shrink my raspberry pi images following this tutorial: https://softwarebakery.com/shrinking-images-on-linux

root@host:~# modprobe loop      # no errors returned
root@host:~# lsmod | grep loop  # returns nothing - this is strange…
root@host:~# ls /dev/loop*
/dev/loop0  /dev/loop2  /dev/loop4  /dev/loop6  /dev/loop-control
/dev/loop1  /dev/loop3  /dev/loop5  /dev/loop7
root@host:~# sudo losetup -f
/dev/loop0
root@host:~# losetup /dev/loop0 myimage.img
losetup: myimage.img: failed to set up loop device: Operation not permitted

Why?? What am I doing wrong?

EDIT: Spending a couple days googling I've found no hints what could be a problem here. But I've noticed that some .img files are working just fine, while others giving "Operation not permitted".

Any clues what can be wrong with the image and possible fix solutions?

Drew
  • 225

1 Answers1

4

Finally found the answer myself.

I used the Ubuntu VM to shrink my pi images. The host machine - OSX. The image file was in shared folder (host-VM)

In order to be able to mount the .img as loop device make sure to set the permissions of the .img file to 766 or 666.

Drew
  • 225