Giter Club home page Giter Club logo

Comments (36)

rmast avatar rmast commented on July 30, 2024 2

I just ran this fork-commit of pishrink.sh without errors on my RPi3-image, hopefully it will grow again when I need it:
https://raw.githubusercontent.com/simonj0/PiShrink/2b4a63299ef25b20142122a2fec9e3209fcd5380/pishrink.sh

from pishrink.

Drewsif avatar Drewsif commented on July 30, 2024 1

How did you take the image? It looks like that might be broken

from pishrink.

aitgelion avatar aitgelion commented on July 30, 2024 1

I have the same problem with ubuntu 16.04.3 (32b) running on Virtualbox (Win10).
I solved it by copying the .img file from shared Virtualbox Folder to Virtual Machine home directory and running the script from there.

from pishrink.

Websteria avatar Websteria commented on July 30, 2024 1

This needs to be fixed. Pishrink is basically broken for any x86 users with the current version. I’ve tried everything and can’t get it to work unless I copy the file into the target machine.

from pishrink.

monsieurborges avatar monsieurborges commented on July 30, 2024 1

Hey @DismissedGuy @vdonchev @Duiesel @sookah you can check out my project PiShrink dockerized | Docker Hub PiShrink:

You can see how I create the Ubuntu Docker image, the installation process is very similar for Debian.

macOS setup

  1. Install Docker Desktop on Mac

  2. Make a copy of a Raspberry Pi SD card that you want to shrink (see instructions here).

  3. Using the Terminal, access the directory containing the Raspberry Pi image:

cd ~/Directory-with-RPi-image
  1. Run PiShrink dockerized:
docker run --privileged=true --rm \
    --volume $(pwd):/workdir \
    monsieurborges/pishrink \
    pishrink -pZv IMAGE_NAME.img NEW-IMAGE_NAME.img

from pishrink.

vdonchev avatar vdonchev commented on July 30, 2024

Have the same problem on latest mint64:

tune2fs: Attempt to read block from filesystem resulted in short read while trying to open /dev/loop0
Couldn't find valid filesystem superblock.
tune2fs: Attempt to read block from filesystem resulted in short read while trying to open /dev/loop0
Couldn't find valid filesystem superblock.
mount: /dev/loop0 is write-protected, mounting read-only
mount: /dev/loop0: can't read superblock
md5sum: /tmp/tmp.AmJQUNDFi9/etc/rc.local: No such file or directory
./pishrink.sh: line 63: [: !=: unary operator expected
umount: /tmp/tmp.AmJQUNDFi9: not mounted
e2fsck: Operation not permitted while trying to open /dev/loop0
You must have r/w access to the filesystem or be root
resize2fs 1.42.13 (17-May-2015)
resize2fs: Operation not permitted while trying to open /dev/loop0
./pishrink.sh: line 136: [[: Couldn'tfindvalidfilesystemsuperblock.: syntax error: invalid arithmetic operator (error token is "'tfindvalidfilesystemsuperblock.")
expr: syntax error
expr: syntax error
expr: syntax error
resize2fs 1.42.13 (17-May-2015)
resize2fs: Operation not permitted while trying to open /dev/loop0
Couldn't find valid filesystem superblock.
ERROR: resize2fs failed...
mount: /dev/loop0 is write-protected, mounting read-only
mount: /dev/loop0: can't read superblock
mv: cannot stat '/tmp/tmp.AmJQUNDFi9/etc/rc.local.bak': No such file or directory
umount: /tmp/tmp.AmJQUNDFi9: not mounted

any ideas?

from pishrink.

malmeloo avatar malmeloo commented on July 30, 2024

I made the image using Win32DiskImager, and afaik that program only makes 1:1 copies. I also tried another image (32 GB) and got exactly the same error.

from pishrink.

malmeloo avatar malmeloo commented on July 30, 2024

By the way: one of the images is a NOOBS dual boot, but since the other one doesn't work either, I don't think that's the problem.

from pishrink.

John-Mc avatar John-Mc commented on July 30, 2024

Working fine on the latest Raspian-stretch for me (Non-NOOBS install).

from pishrink.

Drewsif avatar Drewsif commented on July 30, 2024

NOOBS is a known problem. They do partitioning different than raspbian and it breaks the script

from pishrink.

malmeloo avatar malmeloo commented on July 30, 2024

But that shouldn't break the other image, should it?

from pishrink.

Drewsif avatar Drewsif commented on July 30, 2024

It shouldn't. Have you tried that latest version to see if anything got fixed?

You're running PiShrink on a standard Debian 9 install? I'll try to do it as well and see if I can replicate the error.

from pishrink.

himijendrix24 avatar himijendrix24 commented on July 30, 2024

Same here: sudo pishrink.sh Raspi3_basic.img

Debian Stretch 64 bit (virtualbox with windows 10 host).
There is 35 Gb free disk space for the virtual machine and
the image is accessed via a shared folder on the host system.

tune2fs: Eingabe-/Ausgabefehler beim Versuch, /dev/loop0 zu öffnen
Es kann kein gültiger Dateisystem-Superblock gefunden werden.
mount: /dev/loop0 is write-protected, mounting read-only
mount: wrong fs type, bad option, bad superblock on /dev/loop0,
missing codepage or helper program, or other error
In some cases useful info is found in syslog - try
dmesg | tail or so.
md5sum: /tmp/tmp.lMI5EW1kNW/etc/rc.local: Datei oder Verzeichnis nicht gefunden
/usr/local/bin/pishrink.sh: Zeile 69: [: !=: Einstelliger (unärer) Operator erwartet.
umount: /tmp/tmp.lMI5EW1kNW: not mounted
e2fsck: Die Operation ist nicht erlaubt beim Versuch, /dev/loop0 zu öffnen
Sie benötigen r/w- oder root-Rechte für das Dateisystem.
resize2fs 1.43.4 (31-Jan-2017)
resize2fs: Die Operation ist nicht erlaubt beim Versuch, /dev/loop0 zu öffnen
/usr/local/bin/pishrink.sh: Zeile 142: [[: EskannkeingültigerDateisystem-Superblockgefundenwerden.: Syntaxfehler: Ungültiger arithmetischer Operator. (Fehlerverursachendes Zeichen ist "ültigerDateisystem-Superblockgefundenwerden.").
/usr/local/bin/pishrink.sh: Zeile 148: - EskannkeingültigerDateisystem-Superblockgefundenwerden.: Syntaxfehler: Ungültiger arithmetischer Operator. (Fehlerverursachendes Zeichen ist "ültigerDateisystem-Superblockgefundenwerden.").
resize2fs 1.43.4 (31-Jan-2017)
resize2fs: Die Operation ist nicht erlaubt beim Versuch, /dev/loop0 zu öffnen
Es kann kein gültiger Dateisystem-Superblock gefunden werden.
ERROR: resize2fs failed...
mount: /dev/loop0 is write-protected, mounting read-only
mount: wrong fs type, bad option, bad superblock on /dev/loop0,
missing codepage or helper program, or other error In some cases useful info is found in syslog - try dmesg | tail or so.
mv: der Aufruf von stat für '/tmp/tmp.lMI5EW1kNW/etc/rc.local.bak' ist nicht möglich: Datei oder Verzeichnis nicht gefunden
umount: /tmp/tmp.lMI5EW1kNW: not mounted

from pishrink.

Sunblogger avatar Sunblogger commented on July 30, 2024

I got similar problems to get pishrink.sh running without errors. I created the image files with Win32DiskImager on my Windows 7 from the SD-cards I took out of the Raspberry.
On my Windows 7 PC I run VirtualBox (release 5.2.6).
I've setup 2 virutal PCs, first one contains "Raspberry Pi Desktop" in release 9 (Stretch).
The second one contains Ubuntu 17.10. On both virtual systems the pishrink.sh fails and tells the same error message with "/dev/loop0".
As 3rd try I've used an USB-stick containg the Live-CD called "Desinfec't" 2017 from a german computer magazine and booted my laptop with it. This release is based on Ubuntu "16.04.2 LTS (Xenial Xerus)". With this release I could successfully shrink an image I made today. But even this Ubuntu release failed with an image I made mid of 2017.

On my Raspberry running with Raspian 9 Stretch pishrink works well to shrink imagefiles; this is true for old images and new ones.

For me it looks like that the errors are only coming up on x86/amd64-based installations.

from pishrink.

molehole2003 avatar molehole2003 commented on July 30, 2024

Using Mint 18.3 (Virtualbox with windows 10 host) and the image is accessed via a shared folder on the host system. There appears to be an issue with running PiShrink and the newest version 5.2.8 of Virtualbox Guest additions. When I installed Mint 18.1 and left the pre-installed Guest additions, PiShrink works fine. When I updated VB Guest additions in Mint 18.1 to version 5.2.8, I get the same error messages I was getting in Mint 18.3.

tune2fs: Attempt to read block from filesystem resulted in short read while trying to open /dev/loop0
Couldn't find valid filesystem superblock.
mount: /dev/loop0 is write-protected, mounting read-only
mount: /dev/loop0: can't read superblock
md5sum: /tmp/tmp.IVWSnYvrca/etc/rc.local: No such file or directory
./pishrink.sh: line 69: [: !=: unary operator expected
umount: /tmp/tmp.IVWSnYvrca: not mounted
e2fsck: Operation not permitted while trying to open /dev/loop0
You must have r/w access to the filesystem or be root
resize2fs 1.42.13 (17-May-2015)
resize2fs: Operation not permitted while trying to open /dev/loop0
./pishrink.sh: line 142: [[: Couldn'tfindvalidfilesystemsuperblock.: syntax error: invalid arithmetic operator (error token is "'tfindvalidfilesystemsuperblock.")
./pishrink.sh: line 148: - Couldn'tfindvalidfilesystemsuperblock.: syntax error: invalid arithmetic operator (error token is "'tfindvalidfilesystemsuperblock.")
resize2fs 1.42.13 (17-May-2015)
resize2fs: Operation not permitted while trying to open /dev/loop0
Couldn't find valid filesystem superblock.
ERROR: resize2fs failed
...

I am no Linux or Virtualbox expert, but this seems like another clue to some of the problems listed above.

from pishrink.

steeeb avatar steeeb commented on July 30, 2024

Same happened here, I downloaded the 5.2.0 guest additions and installed them instead and it fixed the issue.

from pishrink.

PatiB87 avatar PatiB87 commented on July 30, 2024

Hey, I got the same issues. I tried Linux MINT and Debian on Windows 10 Host and MacOS Host, I tried having the image on an external HDD connected to the VM and also tried to copy the image to the virtual disk of the VM. It all resulted in the same errors as described above. "Bad superblock" etc...
What is going on? Is PiShrink broken by now?
I used it successfully about a year ago, what changed?

from pishrink.

bjcerveny avatar bjcerveny commented on July 30, 2024

@PatiB87 I just performed a pishrink today in Ubuntu 18.04 on my Mac. It worked fine after copying the image to the virtual disk.

from pishrink.

PatiB87 avatar PatiB87 commented on July 30, 2024

from pishrink.

bjcerveny avatar bjcerveny commented on July 30, 2024

I made two images while debugging. One using 'dd' on my Mac and one directly from Ubuntu. They both work when copied to the VM's filesystem. Neither work when accessed via a share on the host Mac.

from pishrink.

PatiB87 avatar PatiB87 commented on July 30, 2024

Interesting! Did you use the /rdisk or the /disk path with dd on the mac? Did you modify the block size as well?
But your Ubuntu is 64 bit? And english? (I somehow suspect that maybe my German installation might be the reason why...)

from pishrink.

bjcerveny avatar bjcerveny commented on July 30, 2024

I used /disk set a block size with dd on the Mac. I did not try it without.
dd if=/dev/disk3 of=raspi.img bs=4m

And yes, my installation is 64 bit Ubuntu and English.

from pishrink.

PatiB87 avatar PatiB87 commented on July 30, 2024

Tried it exactly as you said. Same command under Mac, image making went fine, copied it to my freshly installed Ubuntu 64-bit English in VirtualBox, ran latest pishrink and got this:
https://pictr.com/image/0aCAQ1

All this for nothing.

Could it be that your Ubuntu is still old and there IS in fact a problem with PiShrink on newer Linux version as suggested by so many bug reports and forum entries?

from pishrink.

bjcerveny avatar bjcerveny commented on July 30, 2024

It is a fresh install of 18.04. I do not have another version I will be making a new image later this week.
I do use Parallels, not VirtualBox.

from pishrink.

ab316 avatar ab316 commented on July 30, 2024

Worked from me after installing Virtual Box Guest Additions 5.2.0 and moving the image from the shared folder to inside the machine.

from pishrink.

PatiB87 avatar PatiB87 commented on July 30, 2024

I have now followed this guide:
https://softwarebakery.com/shrinking-images-on-linux

and it seemed to work!

So for everyone else having trouble with this s*** (sorry, being angry like this is usually not my style but this fing s cost me days of frustration!!!) I did the following:

  • created image with dd
  • mounted it as loop device
  • shrinked the large partition using gparted
  • shaved the image using truncate

all the steps except the first are explained in the link above.
This worked besides everything else (like fsck) telling me that my image was broken! Which I am now again sure is not true but rather some SUPER ANNOYING bug somewhere!!!! oO Don't know, don't care, wasted enough time on this!!! >:(

from pishrink.

MapledLeif avatar MapledLeif commented on July 30, 2024

I was getting the "Couldn't find valid filesystem superblock" error on virtual machines running Mint and Ubuntu with the host on my Win10 as well as Mac Mojave utilizing shared folders. Only when copying into the virtual machine would it work.

Finally I just connected a large enough HDD via powered USB hub to my RPi running Raspbian Stretch and it worked like a charm the first try. No fuss, no muss, and shrunk a 128GB card from 127.84 to just over 109 in about 10 minutes.

from pishrink.

sshanky avatar sshanky commented on July 30, 2024

I was having trouble using Ubuntu 16.04 in Parallels on my Mac via a shared filesystem. Once I copied the image file off the Mac's filesystem onto the local Ubuntu filesystem, it worked perfectly, going from nearly 8GB down to 3.7. Awesome. Thanks everyone.

from pishrink.

Duiesel avatar Duiesel commented on July 30, 2024

I've got the same problem on my Mac os and pishrink in Docker (Debian).
chmod -R 777 my_image_file.img before docker run and "pishink'ing" helps.
The reason is that when you made pishring file.img you trying to rewrite files in mounted image file so pishrink can't do so on read-only mount.
Good luck!

from pishrink.

galosre avatar galosre commented on July 30, 2024

Me i am getting:!!
Tune2fs: Bad magic number in super-block while trying to open /dev/loop0
/dev/loop0 contain a swap file system
pishrink.sh: ERROR occurred in line 289: tune2fs failed. Unable to shrink this type of image

from pishrink.

Drewsif avatar Drewsif commented on July 30, 2024

@galosre your image is not shrinkable with PiShrink. The last partition needs to be the root partition and yours is the swap partition. What distro are you using on the pi?

from pishrink.

sookah avatar sookah commented on July 30, 2024

I've got the same problem on my Mac os and pishrink in Docker (Debian).
chmod -R 777 my_image_file.img before docker run and "pishink'ing" helps.
The reason is that when you made pishring file.img you trying to rewrite files in mounted image file so pishrink can't do so on read-only mount.
Good luck!

@Duiesel I am doing this exactly right now on docker ubuntu on MacOS. What do you mean by before docker run, care to explain it a bit better would really help me right now.

What i did was docker cp <file> <destination>. to copy the image into the container and than run pi shrink there. Failed with the above error. I also chmod 777 the pi.img file

from pishrink.

apicole avatar apicole commented on July 30, 2024

I just ran this fork-commit of pishrink.sh without errors on my RPi3-image, hopefully it will grow again when I need it:
https://raw.githubusercontent.com/simonj0/PiShrink/2b4a63299ef25b20142122a2fec9e3209fcd5380/pishrink.sh

This helped me to transform a Kali 64 bits image of 60Gb to a 20Gb img file btu as well my pi photobooth based on rasbpian from 30G to 5.9G

from pishrink.

dogarcar avatar dogarcar commented on July 30, 2024

@galosre your image is not shrinkable with PiShrink. The last partition needs to be the root partition and yours is the swap partition. What distro are you using on the pi?

I have indeed the same issue. I'm using PiShrink to fit a backup sd card image into a new (slightly smaller) sd card. It's a customized RetrOZ image. I reduced the size of the image (the rom partition) as it was plenty of space not used and now I'm trying to shrink it, but it does not work.

I'm using the ubuntu system (version 2) installed in windows 10.

Any help to make it work? Thanks!!!

from pishrink.

AndreCox avatar AndreCox commented on July 30, 2024

Has anyone tried swapoff -a then shutting down their raspberry pi, I'm testing it now to see if it works.

from pishrink.

AndreCox avatar AndreCox commented on July 30, 2024

Can confirm that doesn't work

from pishrink.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.