Comments (36)
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.
How did you take the image? It looks like that might be broken
from pishrink.
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.
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.
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
-
Make a copy of a Raspberry Pi SD card that you want to shrink (see instructions here).
-
Using the Terminal, access the directory containing the Raspberry Pi image:
cd ~/Directory-with-RPi-image
- Run PiShrink dockerized:
docker run --privileged=true --rm \
--volume $(pwd):/workdir \
monsieurborges/pishrink \
pishrink -pZv IMAGE_NAME.img NEW-IMAGE_NAME.img
from pishrink.
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.
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.
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.
Working fine on the latest Raspian-stretch for me (Non-NOOBS install).
from pishrink.
NOOBS is a known problem. They do partitioning different than raspbian and it breaks the script
from pishrink.
But that shouldn't break the other image, should it?
from pishrink.
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.
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.
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.
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.
Same happened here, I downloaded the 5.2.0 guest additions and installed them instead and it fixed the issue.
from pishrink.
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.
@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.
from pishrink.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
@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.
I've got the same problem on my Mac os and pishrink in Docker (Debian).
chmod -R 777 my_image_file.img
beforedocker run
and "pishink'ing" helps.
The reason is that when you madepishring 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.
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.
@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.
Has anyone tried swapoff -a
then shutting down their raspberry pi, I'm testing it now to see if it works.
from pishrink.
Can confirm that doesn't work
from pishrink.
Related Issues (20)
- Detect when parted changes PARTUUID
- Add image cleanup support
- Remove current image cleanup code
- Add better detection of existing /etc/rc.local changes HOT 1
- FEATURE REQUEST: BTRFS support HOT 2
- ERROR occurred in line 300: tune2fs failed. Unable to shrink this type of image. HOT 1
- unexpected end of file error HOT 1
- File System not expanding HOT 2
- possibility to add costum scripts to the new iso?
- Raspbian not completly booting - No GUI underscore blinking HOT 3
- Filesystem not expanding if rc.local does not exist
- Option to resize partition to a given size? HOT 1
- Typo in line 394 trunate to truncate
- pishrink writes to stderr instead of stdout
- new shrink image is not running. HOT 3
- After the image is clipped, the power indicator is off after the system is shut down
- ERROR occurred in line 304: tune2fs failed HOT 7
- shrinkPi for Sonoma HOT 2
- [Tip/Idea]: Make Releases to check if update is necessary
- it could shrink the Debian/Ubuntu image on my PC. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pishrink.